#clojure log - Aug 24 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:01 jjddb: clojure.java.io says: (defn- ^String encoding [opts] (or (:encoding opts) "UTF-8"))

0:01 is such a thing as :encoding "binary" recognized?

0:02 a complete list of accepted encodings aren't in the clojure docs

0:02 srid: afaik, slurp always return string (never byte-array). and the 'encoding' parameter controls how to convert the incoming bytes to the to-be-returned String

0:03 jjddb: ah

0:03 srid: (slurp (-> url (URL.) (.openConnection) (.getInputStream) (GZIPInputStream.))])

0:03 minus the GZIPInputStream part.

0:03 no

0:04 (to-byte-array (-> url (URL.) (.openConnection) (.getInputStream)))

0:04 jjddb: can spit write the byte-array?

0:14 ugh, I didn't have contrib in my classpath :/

0:25 jli: my classpath solution is just to include ~/.clojure/* in CLASSPATH in my bash config, and then symlink everything I could ever want in that directory

0:25 is that dumb? it's been working for me so far

0:26 srid: has anyone integrate lein with http://martiansoftware.com/nailgun/ ? for faster JVM startup

0:26 jjddb: I think I've heard of it being done

0:27 but I believe a tool called fark seeks to fill that void

0:27 is clojure.contrib 1.2 compatible with clojure 1.3beta1?

0:28 I'm getting: IllegalStateException Can't dynamically bind non-dynamic var: clojure.contrib.io/*append* clojure.lang.Var.pushThreadBindings (Var.java:339)

0:29 should I be using the contrib.io version of to-byte-array or the duck-streams version?

0:29 its a shame clojure.java.io doesn't have to-byte-array

0:32 scottj: srid: jjddb might have meant jark, which does something like nailgun not sure if it uses nailgun. there's also cake and lein interactive

0:32 jjddb: scottj: right, my fault. jark uses nailgun

0:33 scottj: I use jark for my scripts, it supports #!

0:33 cake does too I think (with persistent vm also)

0:36 dnolen: crazy ascii art? https://gist.github.com/1167317 - nope, output from match for a red-black tree balance checker. something to work on ...

0:39 jli: dnolen: nice. is that a bug? or does it just not do something smart for recursive matches (assuming that's what's going on?)?

0:39 all the "(cond)"s are interesting

0:40 amalloy: jli: i like (cond :else (let [] :invalid)), personally

0:42 dnolen: jli: we haven't applied any of the suggested heuristic which should some with code size. even so, this code once generated compiles instantaneously. And it verifies balanced trees very, very quickly.

0:43 some -> help some.

0:45 jli: the more troubling thing is how long it takes to actually generate the source.

0:45 michaelr525: hello

0:47 dnolen: jli: just means there's more work to do. however if we can get the code size down some and really shrink compile times this will be a powerful match library indeed. still the fact that it works at all having only worked on this lib in a highly focused manner for about a month … I'm optimistic.

0:49 jjddb: amalloy: srid: I remember why I was using http.async.client now... I need something that can handle cookies.

0:49 I've been using the selenium wrapper to automate some downloading processes

0:50 I've been fairly successful crawling to the necessary pages and elements, now I just need to download the files and the wrapper doesn't have great "wget" functionality

0:51 when it "clicks" on the link, a 'save as' dialog box pops up -- which I don't want, obviously.. I'm trying to automate the whole thing.

0:52 amalloy: jjddb: is there a java binding for libcurl? it's pretty good

0:53 jjddb: as a matter of fact there is

0:54 at that rate though I could just shell-out to curl or wget

0:55 was trying to keep it all in one jar

1:00 dnolen: heh Racket generates about the same amount of code for the red-black tree test

1:00 so all we gotta do is not take so long to generate it.

1:01 khaliG: dnolen, what's that for?

1:01 dnolen: khaliG: ?

1:01 khaliG: is it for a benchmark?

1:03 amac: o/

1:03 dnolen: khaliG: the benchmark of "I will/won't use this for anything in Clojure" yes :)

1:04 khaliG: ah

1:04 amac: dnolen: watched your talk on patern matching, very cool

1:05 dnolen: in fact using Java arrays to representing the red-black trees this could be one of the fastest red-black balance checkers out there.

1:05 jjddb: how does one spit a byte-array?

1:05 dnolen: amac: thx

1:07 amalloy: &(require 'clojure.java.io)

1:07 lazybot: ⇒ nil

1:07 amalloy: &(doc clojure.java.io/copy)

1:07 lazybot: ⇒ "([input output & opts]); Copies input to output. Returns nil or throws IOException. Input may be an InputStream, Reader, File, byte[], or String. Output may be an OutputStream, Writer, or File. Options are key/value pairs and may be one of :buffer-size buffer size ... http://gist.github.com/1167347

1:07 amalloy: jjddb: ^

2:38 peteriserins: I'm running lein repl in my lein project. How to reload my clojure files without reloading the lein repl?

2:39 tomoj: use and require take :reload and :reload-all options

2:39 e.g. (use 'foo.bar :reload-all)

2:39 the -all version reloads all dependent namespaces too

2:40 (doc require)

2:40 clojurebot: "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of Cloju

2:40 tomoj: hmm

2:40 Guest48164: need help chaining multiple lazy-seq's into one lazy-seq

2:40 tomoj: chaining?

2:41 Guest48164: have:

2:41 (doseq [content (client/string response)] (doseq [line (re-seq #".+\r\n" content)] (let [record (json/read-json line)] (f record)))))))

2:41 want one lazy-seq back instead of (doseq ... (doseq ... (do something

2:42 Trying to get content from http stream and pass back a seq that a I can (doseq on

2:43 Getting 1 lazy-seq from (client/string, then getting another lazy-seq from re-seq

2:44 tomoj: https://gist.github.com/d58de88cc6db11bd1122

2:45 untested

2:45 but I think something like one of those should work

2:45 easier to get help if you show a simple extracted example that works by itself

2:45 (also, paste those to gist or pastebin or something, not here)

2:45 Guest48164: Nice, I'll try it out

2:45 Yeah, sorry about that

2:45 tomoj: yours was short enough this time

2:46 I just tend to warn people because some people have no clue and will paste huge blobs of code :)

2:46 mapcat is one way of chaining

2:47 it's just like map (you know map?) but concatenates the result seqs into one seq

2:48 and do you know ->>? less confusing way of writing records is (map json/read-json (mapcat #(re-seq #".+\r\n" %) (client/string response)))

2:48 amalloy: Guest48164: fwiw, doseq allows multiple bindings, which it processes in a nested fashion

2:48 (doseq [content (...), line (...content...)] ...)

2:48 tomoj: I wouldn't think that would do what you want

2:49 amalloy: tomoj: it would do the same thing as the nested doseqs

2:49 whether that's what he wants i won't speculate on

2:49 tomoj: oh, right

2:49 and you just ignore the bindings

2:49 which is why they fall out :)

2:49 amalloy: ?

2:50 tomoj: I mean, only line is used inside the body

2:50 which makes doseq over cross-product seem wrong to me, even though it's actually what nested doseq does...

2:50 jli: content is used to define line, no?

2:50 khaliG: is there a nicer way to write (.setEnabled foo (not (nil? foop)))

2:51 tomoj: I mean in the body of the unified doseq

2:51 Guest48164: Here's the paste: http://pastebin.com/QkL0Gysb

2:51 tomoj: khaliG: if foop is false, you want to enable foo?

2:51 otherwise (boolean foop)

2:53 khaliG: tomoj, ops, right, (boolean foop) is what I'm after

2:53 amalloy: tomoj: i don't understand what you're getting at re: falling out/ignoring. are you worried about holding onto something's head?

2:53 tomoj: I mean, the binding of content is unnecessary

2:54 so it 'falls out' when you get rid of the doseqs and use mapcat

2:54 amalloy: i see

2:54 interesting way of thinking about it

2:54 tomoj: guess it's still there though

2:54 just became anonymous

2:54 amalloy: right. it's bound in each invocation of f in (mapcat f ...)

2:55 tomoj: but if you use it in the body, my code doesn't work

2:55 amalloy: which i think is pretty close to what for/doseq translates to, eventually

2:55 tomoj: well, sure it does, you just have the seq return [content line] pairs, just like doseq..

2:56 amalloy: Guest48164: your goal is to return a seq instead of using a doseq inside subscribe? i approve of that goal, and it's a pretty easy change

2:57 tomoj: aww

2:57 Guest48164: amalloy: right

2:57 * amalloy <3 `for`

2:57 Guest48164: amalloy: Can't get my head around it though

2:58 tomoj: do you find mapcat/partial/->> easier? O_o

2:58 Guest48164: tried 'for' but things get stuck

2:58 tomoj: just curious, how do you generate the stream seq?

2:58 Guest48164: trying the mapcat/partial... was not intuitive to me

2:58 amalloy: Guest48164: https://gist.github.com/1167449

2:58 oh, but then you run into trouble with with-open closing the stream before you're done

2:59 Guest48164: http.async.client/stream-seq

2:59 tomoj: bleh

2:59 I didn't even notice the with-open

2:59 amalloy: tomoj: yeah

2:59 Guest48164: ahhhh

2:59 amalloy: Guest48164: so the problem with my gist is that the stream gets closed as soon as aubscribe returns, but the data inside it is read lazily

2:59 Guest48164: Have to process everything inside the with-open, right?

3:00 raek: (doall (for ...)) ?

3:00 Guest48164: No way around it, I guess?

3:00 amalloy: those seem to be the two options :P

3:00 tomoj: I don't think you want to synchronously process your async stream

3:01 Guest48164: Would need to have the with-open outside of that subscribe routine

3:01 Got it

3:01 Thanks for the help

3:01 tomoj: maybe you do.. I guess it at least gives you a lazy seq over a streaming response?

3:02 robbe-: Hmm, agents with data structures including refs kind of mis the point of using agents in the first place - except they are asynchronous - or am I still missing something?

3:02 tomoj: https://github.com/ztellman/aleph/wiki/Consuming-and-broadcasting-a-Twitter-stream

3:02 Guest48164: ^

3:03 Guest48164: tomoj: yeah, played around with aleph first

3:03 tomoj: may be relevant to your interests, didn't play with http.async.client for more than a day so I don't know how it compares

3:04 Guest48164: aleph seems to have a very different and unique model about stuff, what with the channels and all

3:04 tomoj: yeah, didn't really think about that..

3:04 the receive-all version looks great to me and the pipeline stuff you could do on it too

3:04 but it's ..different

3:04 and too much to learn on top of clojure

3:06 michaelr525: ,(map #(%1) ({:a 1}{:b 2}))

3:07 clojurebot: ()

3:07 michaelr525: what am I doing wrong?

3:07 I just want to iterate this list of maps and return a new list of maps

3:07 Guest48164: btw, what's the * in "function*" convention mean?

3:08 michaelr525: internal to namespace i think

3:08 tufflax: ,({:a 1}{:b 2})

3:08 clojurebot: nil

3:08 amalloy: &(:a)

3:08 lazybot: java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a

3:08 Guest48164: thought that was function-

3:08 michaelr525: or internal for macro use

3:08 amalloy: oops. tufflax beat me to it with my dreadful copy/paste skills

3:08 Guest48164: ahh

3:08 michaelr525: a macro with the same name

3:08 raek: ,(map #(assoc % :x 3) (list {:a 1}{:b 2}))

3:08 clojurebot: ({:x 3, :a 1} {:x 3, :b 2})

3:09 amalloy: michaelr525: your #(%1) is also highly suspicious, once you've fixed tufflax's suggestion

3:09 michaelr525: shit, brb

3:10 robbe-: Doe we have a nice repl with line-editing capabilities for clojure?

3:10 Do*

3:10 amalloy: $google rlwrap

3:10 lazybot: [rlwrap - utopia.ision.nl] http://utopia.knoware.nl/~hlub/rlwrap/

3:10 robbe-: ty

3:10 amalloy: really? what a bizarre google result. anyway, installing rlwrap requires the least effort, but in the long run you want to use lein or cake

3:12 robbe-: Okay, I just experimenting a bit now, but I better jot it down for when I revisit closure in a more serious context. :-)

3:15 jli: amalloy: lein adds line editing?

3:15 amalloy: *nod* it detects rlwrap, and either uses it or falls back on jline

3:17 jli: huh, cool.

3:17 thorwil: i'm not aware of any relevant changes, but suddenly i get: "java.lang.NoClassDefFoundError: Could not initialize class tlog.core__init (NO_SOURCE_FILE:0)" when trying to bring up my project

3:18 raek: thorwil: check for old files in classes/

3:18 or perhaps do a lein clean

3:19 amalloy: raek: or take a flamethrower to them, without first checking to see if there are any :P

3:20 MasseR: I'm trying to use (:import (java.util Random)) in the ns macro, but I get an error about class java.util not existing

3:20 raek: Alien II: In space no one can hear you clean

3:21 MasseR: that looks right. what does your ns form look like? like (ns some-ns (:import (java.util Random))) ?

3:22 (watch out for quotes)

3:22 MasseR: http://pastebin.com/9SagAatP

3:22 Like that

3:22 thorwil: raek: just clearing it did the trick, thanks. so far i thought this problem would only come up on changing version numbers of deps in the project file. not the case, here

3:23 raek: MasseR: any reasons you have both duck-streams and java.io? (since the latter replaces the former)

3:24 MasseR: raek: to-byte-array wasn't in io

3:24 raek: MasseR: that ns form works for me. are you sure this is not something simple like forgetting to save the file?

3:24 thorwil: MasseR: there's no need to repeat :require. (i'm suprised that works, even)

3:25 MasseR: raek: The file is saved, and I just restarted the repl. No go

3:25 ibdknox: sweet

3:26 raek: MasseR: and you are sure the error is caused by these lines?

3:26 MasseR: raek: -.- I'm an idiot :D

3:26 Thanks

3:26 ibdknox: I have the base of a d3-like data visualization library for cljs :)

3:26 thorwil: MasseR: http://pastebin.com/R9SqQcMY

3:26 MasseR: thorwil: Thanks

3:27 thorwil: np

3:31 oh well, the only data i have to visualize right now are nested comments :)

3:37 ibdknox: heh

3:37 that's the best kind to visualize ;)

3:37 useless data haha

3:38 jli: MasseR: ooh, what's a reddit wallpaper?

3:39 thorwil: shouldn't i be able to call a function from within itself, without using declare?

3:39 jli: thorwil: recursively? yeah.

3:39 amalloy: thorwil: yes. are you trying to do something like (let [f (fn [] (f ...))])?

3:39 jli: oh

3:40 MasseR: jli: A while back I wrote in haskell a script that takes a random wallpaper from r/wallpaper

3:40 I'm trying to port it to clojure as a learning experience

3:41 jli: MasseR: ah, cool

3:43 khaliG: hm getting a bit tired of switching to the slime repl to type (-main) after making some changes, is there an easier way?

3:44 jli: I've never seem /r/wallpaper before - these are pretty good :)

3:44 thorwil: amalloy, jli: http://paste.pocoo.org/show/463493/

3:45 jli: khaliG: a script that runs it your clj automatically when the modtime changes?

3:45 khaliG: jlf_, was thinking a shortcut, like press F5

3:45 i wouldn't know how to do that though

3:46 fhd: Any ClojureScript gurus around? I need some help here.

3:46 khaliG: jli, even, sorry

3:46 jli: khaliG: you could record a hacky macro

3:47 ibdknox: fhd: dunno if I'm a guru, but I may be able to help

3:47 khaliG: jli, emacs macro? i'll look into it now

3:47 jli: something like: M-x slime-repl RET (-main) RET C-x b RET

3:47 fhd: ibdknox: I'm using the dom-helpers from the twitterbuzz sample, dom-helpers/build in particular

3:47 robbe-: Hmm, any good rlwrap completion files? Maybe some tool that parses clojure source files for function definitions and add them too the completion list? :D

3:47 jli: that would switch to the repl, enter "(-main)", and switch back (I think)

3:47 robbe-: sounds like you need slime

3:48 khaliG: jli, looks good. how do i tell emacs to run that sequence though?

3:48 robbe-: jli: Not an emacser ;)

3:48 fhd: ibdknox: However, when I write code like this: (dom/build [:h1 "Hello, World!"]), all I get from Chrome is: "Uncaught TypeError: Object i.'h1 has no method 'appendChild'"

3:48 jli: khaliG: do you know how te record macros?

3:49 robbe-: (although it's on the todo list)

3:49 khaliG: jli, nope, reading about it now. will i be able to store the macro for reuse?

3:50 fhd: ibdknox: Tried this with the latest clojurescript on two different boxes. The twitterbuzz example works fine

3:50 ibdknox: fhd: and you're only executing that code?

3:50 jli: khaliG: after you record it, you can do name-last-kbd-macro to give it a name, and then insert-kbd-macro <name-you-gave-it>, which will dump the elisp for the macro

3:50 amalloy: thorwil: that looks fine. is line 181 the last line of comments-rendition-recur?

3:50 fhd: yeah, just a sec

3:50 ibdknox: I'll put the post in a pastebin

3:50 khaliG: jli, sounds good. thank you!

3:50 jli: yup

3:51 thorwil: amalloy: yes

3:51 robbe-: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap ; explains what I was asking

3:51 fhd: ibdknox: http://pastebin.com/QuhGytfv

3:52 ibdknox: Wait, that was old, here: http://pastebin.com/dvrB3nUR

3:52 amalloy: then i don't really see any reason it wouldn't work

3:52 fhd: ibdknox: dom-helpers is copied from the twitterbuzz sample, latest revision. I just changed the namespace.

3:52 MasseR: Hmm.. My haskell solution took 82 lines, and clojure 38

3:53 ibdknox: fhd: mkay

3:53 jli: thorwil: can you paste the whole file? or whittle it down to a small complete failcase?

3:53 ibdknox: fhd: try without the text

3:54 fhd: ibdknox: Just [:h1] ?

3:54 ibdknox: fhd: yep

3:55 thorwil: jli: sure i could paste more, but the failcase is ... compilation

3:55 fhd: ibdknox: Same

3:56 ibdknox: fhd: not that this should really make a difference, but try (dom/append (.body js/document) (dom/build [:h1]))

3:56 fhd: I'm not overly familiar with the dom-helpers they wrote, since I wrote a port of hiccup for CLJS

3:56 fhd: ibdknox: Still the same

3:57 thorwil: jli: the whole set of related fns: http://paste.pocoo.org/show/463499/

3:57 fhd: ibdknox: I must be missing something that twittbuzz does, but I just can't figure out what

3:57 ibdknox: fhd: well, I've been reading through the dom-helpers code

3:57 fhd: that *should* work

3:58 fhd: ibdknox: Yeah, works fine for twittbuzz, so I don't thing there's a problem with dom-helpers

3:58 ibdknox: fhd: try (dom/append (.body js/document) (dom/html "<h1>hey</h1>"))

4:00 fhd: ibdknox: That works.

4:01 ibdknox: BTW, I refreshed the wrong page earlier. When we removed the text from h1, the error message changed: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8

4:01 ibdknox: fhd: hah

4:01 fhd: I don't think this is very robust :)

4:02 fhd: ibdknox: And "this" would be?

4:02 ibdknox: ClojureScript?

4:02 ibdknox: fhd: no, dom-helpers

4:02 fhd: (dom/append (.body js/document) (dom/build [:h1 [:em "hello"]]))

4:03 fhd: ibdknox: Uncaught TypeError: Object i.'em has no method 'appendChild'

4:04 jli: thorwil: weird, I don't know. declare should only be necessary for forward declarations, when you want to call a function that's defined below.

4:05 thorwil: what's defhtml from?

4:05 fhd: ibdknox: Also tried (dom/append (.body js/document) (dom/build [:h1 (dom/html "<em>Hello</em>")]))

4:05 thorwil: jli: hiccup

4:05 fhd: ibdknox: That gives me "...h1 has no method 'appendChild'" again

4:05 ibdknox: fhd: I'm not sure, there's no obvious reason why it would fail. I'm fairly certain it's not correctly creating and holding onto the dom object

4:06 fhd: but without stepping through it, I couldn't tell you where it's doing that

4:06 fhd: ibdknox: I could create a small GitHub project for this, if you're willing to investigate the issue

4:07 ibdknox: sure, though I need to sleep. I'd be happy to check it out tomorrow :)

4:07 In the mean time, you could play around with pinot if you just want to mess around: http://github.com/ibdknox/pinot

4:08 fhd: ibdknox: As an alternative to dom-helpers?

4:08 ibdknox: Yeah, sounds good.

4:08 ibdknox: fhd: yessir, though the goal is more of a fullservice client side library

4:09 fhd: ibdknox: I'll use that then. Although dom manipulation would be cool enough to become its own project :)

4:10 ibdknox: I suspect in the long term many pieces of it will spawn off

4:10 like the visualization stuff I was working on tonight :)

4:10 michaelr525: you

4:10 yo!

4:15 fhd: ibdknox: I really want to figure this out though, I'll play around some more

4:19 michaelr525: ,{:a 1}

4:19 clojurebot: {:a 1}

4:20 michaelr525: (#({:a 1}))

4:20 ,(#({:a 1}))

4:20 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap>

4:21 michaelr525: why in the first case the map evaluates to a map and in the second case it tries to evaluate it as a function

4:21 ?

4:22 ordnungswidrig1: michaelr525: #() adds parens around its body

4:22 ,(#(1))

4:22 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

4:23 ordnungswidrig1: so #(1) is like (fn [] (1))

4:23 jli: michaelr525: that was equivalent to ,((fn [] {:a 1}))

4:24 ,((fn [] {:a 1}))

4:24 clojurebot: {:a 1}

4:24 jli: er, no, fail.

4:24 michaelr525: :)

4:24 tufflax: ,(macroexpand '#({1 2}))

4:24 clojurebot: (fn* [] ({1 2}))

4:24 tufflax: jli looks like you are wrong :p

4:24 michaelr525: macros, they caught us again ;)

4:24 ordnungswidrig1: michaelr525: you can either to (fn [] {:a 1}) or #(constantly {:a 1})

4:25 michaelr525: ordnungswidrig1: or identity?

4:25 ordnungswidrig1: michaelr525: or itendity

4:25 michaelr525: ,#(identity {:a 1})

4:25 clojurebot: #<sandbox$eval7746$fn__7747 sandbox$eval7746$fn__7747@a0f411>

4:27 tufflax: michaelr525 what are you really trying to do?

4:28 michaelr525: i would like to take a list of records (maps) and transform to another list of maps with one property's name changed

4:28 ({:a 1}) -> ({:b 1})

4:30 ordnungswidrig: ,(map #(clojure.set/rename-key % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}])

4:30 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set>

4:30 ordnungswidrig: rename, not rename-key but you get the idea

4:31 michaelr525: would it be faster than mapping to a new list?

4:31 ah

4:31 ordnungswidrig: michaelr525: it maps to a new list :-)

4:31 michaelr525: you are mapping to a new list

4:32 tufflax: ,(require 'clojure.set)

4:32 clojurebot: nil

4:32 tufflax: ,(map #(clojure.set/rename-keys % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}])

4:32 clojurebot: ({:x 1, :c 3, :b 2} {:x 3, :f 4})

4:32 michaelr525: ok, would it be faster than creating a new map, considering each record has only two properties

4:32 ?

4:32 tufflax: it is creating a new map

4:33 for each map

4:33 michaelr525: ok, i think i get it.

4:33 ordnungswidrig: and a new list of the new maps

4:33 tufflax: actually a seq

4:33 but, yeah

4:34 michaelr525: thanks!

4:34 tufflax: I don't know what is the fastest way to do it, if it really matters you have to test it :P

5:08 gilecham: template newbie getting tied in knots: How would I do a non-recursive `apply-template' so as to replace all occurrences of n with (modify n) in (apply-template '[n] '(+ n 5) '[ (modify n) ])

5:29 MasseR: I created an uberjar, and I am able to run it fine. However the jvm is still running for many more seconds after the last line of code is executed

5:30 http://pastebin.com/sBHF8RvP

5:30 What on earth is it doing the rest of the time

5:38 java -jar redditwallpaper-0.0.1-standalone.jar 2.71s user 0.34s system 4% cpu 1:03.15 total

5:46 raek: MasseR: btw, there is a copy function in clojure.java.io

5:47 MasseR: raek: Doesn't handle binary files

5:47 At least from web

5:47 At least I wasn't able to make it work

5:48 raek: I think it should be possible to replace (.write out (duck/to-byte-array in)) with (copy in out)

5:49 io/copy, that is

5:49 MasseR: raek: That was my first try, file said 'data' instead of 'jpeg data', and if I understood correctly it copied it as text

5:50 (But I'll try again. It's not the first time I think I've tried something, but it was with a slight variation)

5:50 pyr: MasseR: also, for getting a random one, i would (first (shuffle list))

5:50 raek: (io/copy (io/input-stream uri) (io/output-stream fname)) uses input/ouput-streams, which are binary

5:52 MasseR: raek: Yep. I did it somehow differently apparently :D. Hmm.. I think it was (io/copy (io/to-byte-array (reader uri)...

5:52 raek: reader is like input-stream, but for text streams

5:53 MasseR: Mm. I figured it out. Didn't think of using input-stream/output-stream with copy though

5:53 raek: also, io/copy won't read the whole file into memory in one piece

5:54 MasseR: Damn you're helpful

5:55 I really appreciate it

5:55 raek: MasseR: you might need to call shutdown-agents before your application exits

5:57 MasseR: raek: It helped

5:57 raek: but if that was the problem your app would just freeze and don't shut down

5:57 MasseR: java -jar redditwallpaper-0.0.1-standalone.jar 4.08s user 0.30s system 153% cpu 2.862 total

5:58 mrBliss: https://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of Interrupt Handler" (see ToC).

5:58 MasseR: raek: Another problem. Seems like it can't download the entire picture before setting it up. I get a bit of grey area in the pictrues

6:00 tufflax: gilecham apply-template uses prewalk-replace, your example works with postwalk-replace: (postwalk-replace (zipmap '[n] '[(modify n)]) '(+ n 5)) => (+ (modify n) 5)

6:00 MasseR: raek: And does it close the streams?

6:00 raek: is the picture cut in half?

6:00 MasseR: raek: No. Like a couple of rows wen't missing

6:00 raek: MasseR: copy does not close them, but with-open does

6:01 so the "bare" copy call without with-open is probably not a good idea...

6:02 MasseR: I have to go, but good luck!

6:07 gilecham: tufflax: thanks for that. I appear to be getting a similar result using core/replace. Is the only difference the greater range of data structures supported by walk?

6:12 tufflax: gilecham replace only replaces things in the list you give it, not recursively in sublists

6:12 but postwalk does

6:12 ,(require 'walk)

6:12 clojurebot: #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate walk__init.class or walk.clj on classpath: >

6:13 tufflax: ,(require 'clojure.walk)

6:13 clojurebot: nil

6:13 tufflax: ,(walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5))

6:13 * khaliG knows he's been writing too much clojure after trying to C-c C-k a TODO text file

6:13 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: walk, compiling:(NO_SOURCE_PATH:0)>

6:13 tufflax: ,(clojure.walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5))

6:13 clojurebot: (+ (+ n 1) 5)

6:14 tufflax: ,(clojure.walk/postwalk-replace {'n '(modify n)} '(+ (+ n 1) 5))

6:14 clojurebot: (+ (+ (modify n) 1) 5)

6:14 tufflax: there

6:14 ,(replace {'n '(modify n)} '(+ (+ 1 n) 5))

6:14 clojurebot: (+ (+ 1 n) 5)

6:16 tufflax: but you probably understood without all that... :p

6:17 btw i didn't know anything about apply-template, i just read the source :P

6:20 gilecham: tufflax: Thanks I'll go and play.

6:20 tufflax: np

6:42 robbe-: Does clojure have some kind of module system? I'm thinking about erlang and swi prolog modules; What I want to do is export some functions, and keep some helper functions private.

6:42 tufflax: khaliG there is no such thing as too much clojure :p

6:43 khaliG: tufflax, ha :)

6:44 opqdonut: robbe-: namespaces

6:44 tufflax: robbe- i don't know much about erlang or prolog, but yes: there are namespaces that you typically put in a file per namespace, and then there is defn- to define private functions

6:45 robbe-: Okay thanks, I'll look up namespaces.

6:51 Hm, defn- but no def- ? :-)

6:52 opqdonut: yeah, that's weird IMO too

6:52 but you can do (def ^{:private true} private-constant ...)

6:52 cemerick: All the foo- variants are an anachronism

6:52 Just ^:private in 1.3.0

6:53 manutter: and it would be pretty trivial to write a def- macro, I should think.

6:53 tufflax: robbe- http://pastebin.com/7XXLfCzw

6:54 manutter: Well, looks like our 3rd-party corporate email provider is hosed again--today should be interesting *sigh*

6:54 robbe-: Okay, thanks for the info. Was defining simple functions like (def foo #(+ 1 %))

6:55 pyr: i stopped using :private, it made my testing much harder

6:55 am i doing things wrong ?

6:56 opqdonut: pyr: hint: #'

6:56 tufflax: pyr you can use this maybe http://pastebin.com/jw5D3Aw0

6:56 manutter: pyr: I think functional programming does more to protect you from bugs than private vars do.

6:56 tufflax: if that's your problem...

6:56 manutter: fwiw...

6:57 opqdonut: for private functions you can do: (let [function-to-test #'name.space/function-to-test] test-it-here)

6:57 and IMO private functions are good for structuring large programs, they keep interfaces simple

6:57 and avoid namespace pollution with use

6:58 tufflax: maybe that docstring in my paste is wrong? doesn't seem do be every var

6:59 pyr oh, you _stopped_ using private

6:59 i misread

6:59 pyr: yes

7:00 manutter: Hmm, if namespace foo.b uses foo.a, and then some other program uses foo.c, will the vars from foo.a be imported into foo.c?

7:01 sorry, I meant if foo.c uses foo.b

7:01 (need coffee, just woke up...)

7:01 tufflax: or maybe not: it's not clear what you mean. Was it private that made testing harder or that you stopped using it that made testing harder

7:02 pyr: tufflax: i meant

7:02 tufflax: i stopped using private functions because it required kludges (#' trick) in tests

7:03 tufflax: ok, then use the refer-prvate function!

7:03 best of both worlds, or something

7:04 pyr: yes, refer-private is nice, thanks for the tip

7:05 Scorchin: If I have a list of maps, how can I remove maps from the list if one of the keys doesn't match what I want it to? Is it something like (remove (fn [x] (not= "expected" x) my-list-of-maps) ? I can't quite figure it out

7:06 but I don't want to check it on "x" but a key within x

7:06 robbe-: how would I include that macro def in every file, load-file or is there something more idiomatic, or better?

7:06 tufflax: robbe- :use within the ns macro

7:07 Scorchin (fn [m] (not= (:key m) something))

7:10 or (m key) is key is not a keyword

7:10 opqdonut: or (get m key) to be sure

7:10 tufflax: if key

7:11 opqdonut hm is that better somehow?

7:12 opqdonut: well suppose it somehow happend that m isn't a map

7:12 that way you catch it earlier

7:12 err, isn't a collection, rather

7:13 tufflax: ,(get 1 1)

7:13 clojurebot: nil

7:13 opqdonut: oh, what? get doesn't throw an exception any more...

7:13 I could've sworn

7:13 I just tested it myself

7:13 tufflax: hehe

7:14 opqdonut: FFS

7:17 tufflax: if get would have resulted in an error unless used on something associative, it seems to me that it would have been just like using the map or whatever as a function. now at least get has slightly different behaviour :p

7:19 opqdonut: well vectors aren't functions etc

7:19 tufflax: ,([1 2 3] 0)

7:19 clojurebot: 1

7:19 tufflax: no?

7:19 opqdonut: wtf

7:20 my assumptions are so out of date

7:20 tufflax: hehe

7:20 opqdonut: maybe I'll just be quiet

7:37 raek: the behaviour get has when you pass it something "non-lookup-able" has always puzzled me

7:38 Scorchin: Is there a simple way to remove a key (or set of keys) from a list of maps?

7:39 tufflax: (map (partial dissoc key1 key2) list-of-maps)

7:39 Scorchin: thanks tufflax

7:39 tufflax: or no

7:39 Scorchin: oh?

7:39 tufflax: that does not work

7:40 (map #(dissoc % key1 key2) list-of-maps)

7:40 that works better

7:40 raek: Scorchin: to remove a key, use 'dissoc'. for each thing in a sequence, use 'map'. and voilà: ##(map #(dissoc % :x) [{:a 1, :x 0}, {:b 2, :x 3}])

7:40 lazybot: ⇒ ({:a 1} {:b 2})

7:40 Scorchin: yup, that did it, thanks!

7:41 raek: why the extra hashes?

7:41 tufflax: its for the bot

7:41 raek: Scorchin: that is the syntax to tell lazybot to evaluate something in the middle of an utterance

7:41 Scorchin: :)

7:42 thought it was some extra sugar I'd have to learn like the '(stop me from evaluating) ticks thing

7:57 manutter: Cool, you can hide both vars and functions by putting them in a separate ns

7:58 Put private stuff in foo.impl, then have foo.public implement the public api and (:use) foo.impl

7:58 and then for testing you can use foo.impl too (so no #' trick)

7:59 pyr: ^^^

9:59 justicefries: what's everybody's IDE/editor preference for clojure?

10:01 dnolen: justicefries: there's a lot. Emacs dominates. I recommend clooj if you just want to see what Clojure is about w/o any hassle. It's like Python's IDLE but for Clojure.

10:02 justicefries: ahh. yeah I use vim with ruby and XCod

10:02 Xcode.

10:02 coopernurse: justicefries: I enjoy IntelliJ w/La Clojure - community edition is free

10:03 justicefries: was reading about that. works well?

10:03 dnolen: justicefries: Vim is popular too.

10:03 justicefries: vimclojure and slimv

10:05 mprentice: i'm trying to like eclipse

10:06 babilen: justicefries: I would also recommend to use leiningen (https://github.com/technomancy/leiningen) to install clojure. If you use vimclojure I also found it nice to have the lein-vimclojure plugin installed (lein plugin install org.clojars.oskarkv/lein-vimclojure "1.0.0-SNAPSHOT") which enables you to start the nailgun server with "lein vimclojure &"

10:06 coopernurse: justicefries: IntelliJ? Yes, I like it. It also works well with lein. But I already used IntelliJ for Java, so it was a natural choice for me

10:07 justicefries: i used hombrew to install clojure and then installed lein

10:08 coopernurse: that's a good start

10:08 do you already know emacs?

10:08 justicefries: nope.

10:09 just vim.

10:09 TimMc: Is there a paredit for vim?

10:09 coopernurse: ah, you might try vimclojure then (I haven't used it).

10:09 but if you decide to try intellij, ping me if you have problems

10:10 babilen: justicefries: If you know and like vim vimclojure or slimv are good choices (IMHO) -- Install both as slimv comes with a nice paredit implementation.

10:10 justicefries: sure.

10:10 ah cool. I think janus (github.com/carlhuda/janus) comes with vimclojure at least, but I don't think slimv.

10:10 i've heard emacs comes with a built in productivity boosts for LISP family languages

10:12 babilen: I have no idea what learning EMACS and using it would do to your productivity, but I am pretty happy with vimclojure and my vim setup. Not sure if anybody actually knows both worlds well enough to be able to comment on the merits/problems of both.

10:12 justicefries: okay.

10:15 dnolen: justicefries: I mostly use Emacs because the quality of modes for various languages that influenced Clojure is so high. Amazing modes for Standard ML, Prolog, Haskell, Scheme. But such polyglot-ism might not be your cup of tea.

10:15 justicefries: yeah. so far Clojure is ruining Ruby for me. :)

10:19 babilen: dnolen: Indeed -- Even though the support for Clojure is very good in vim, the quality of the Scala, Haskell and Erlang ones seems to be ages behind Emacs. (or were when I last had a look)

10:20 pyr: is there a way to define dependencies for lein plugins defined inside a project ?

10:20 wastrel: vim <3

10:20 MasseR: babilen: Haskell support is great

10:20 I'd say way better than clojure

10:20 pyr: when you define lein plugins externally

10:21 babilen: MasseR: Ah, thanks for mentioning that - seems as if I remembered it wrong. (I use Emacs/viper and vim, but prefer vim where possible)

10:22 MasseR: babilen: The haskell-mode plugin is quite sensitive, and small changes to your configurations can hurt a lot, but by being careful, it's great. :)

10:23 babilen: MasseR: I must have messed it up then :) -- Do you have your configuration online somewhere?

10:23 MasseR: babilen: github MasseR/dotvim

10:24 babilen: MasseR: thanks, prepare to be cloned and diassembled ;)

10:29 pyr: answer is yes, by using dev-dependencies

10:30 (corollary, don't forget to lein deps which was my mistake)

11:44 robbe-: Any specific reason why nested #('s are not allowed?

11:45 Or "#()s" as they are written by the compiler. :)

11:47 tufflax: robbe- maybe because the argument names would get used up

11:49 thorwil: ,(macroexpand-1 '#(identity %))

11:49 clojurebot: (fn* [p1__8138#] (identity p1__8138#))

11:49 arohner: gah. Why is there no way to concat regexes?

11:50 thorwil: hmm, not enlightened. but it has to be about the argument names

11:50 robbe-: tufflax: Fair enough I guess, price payed for the shorthand. (cfr scheme lambda for example)

11:52 tufflax: arohner ##((comp re-pattern str) #"," #".")

11:52 lazybot: ⇒ #",."

11:52 arohner: tufflax: thanks

11:57 abedra: chouser, I am moving c.c.zip-filter into data.zip

11:58 chouser, do you mind if I turn the asserts and comments at the bottom into actual tests?

12:03 chouser: abedra: that would be awesome, thanks!

12:05 abedra: chouser, cool, consider it done

12:11 arohner: abedra: there's one bug fix that should go in to c.c.zip-filter / data.zip

12:12 abedra: in zip-filter.xml/tag=, the line containing ((zip/node %) :tag) should be flipped to (:tag (zip/node %))

12:12 abedra: that allows data.xml to work with zip-filter

12:44 icey: If anyone is bored, how can I make this code better? https://gist.github.com/1164308

12:45 I think I'm going to use dnolen's Enlive tutorial to replace hiccup for this

12:51 thorwil: icey: i think enlive is only worth the effort if you work in a setting where someone who does not touch the code works on the html templates

12:52 icey: thorwil: interesting; do most people use hiccup for smaller projects like this?

12:52 thorwil: if you do it all yourself, you will just write _more_ with enlive instead of hiccup

12:52 icey: i have no statistics on that ;)

12:52 icey: thorwil: hah, fair enough

12:53 thorwil: defn- ?

12:57 icey: thorwil: i'm not sure where i picked that habit up from; is it not normal to create private functions in projects?

12:59 thorwil: icey: you probably do right, it's just i never noticed defn- before 0.o

13:33 amalloy: Scorchin: i like (remove (comp #{something} :key) list-of-maps)

13:44 r0man: hello. does someone know a fn in contrib/contrib that takes 2 seqs that represent

13:44 argument lists (that may include destructuring) and returns a somehow

13:44 "combined" argument list? something like: (merge-args '(a1 & {:keys [b1 b3]}) '(a2 & {:keys [b2]}))

13:44 ;=> '(a1 a2 & {:keys [b1 b2 b3]})

13:48 amalloy: r0man: the connection between those two inputs and the output is quite tenuous. i would be extremely surprised if anyone had written that already

13:50 r0man: i'm doing some macro stuff where i need to combine two argument lists and thought this is maybe a common pattern when defining new fns via a macro ...

13:58 amalloy: the number of reasonable ways to combine them is just too large, and it's not clear how you would use the combined argument list effectively anyway; i don't think you can expect any macro to be smart enough to do the combination for you in a general way, so write your own for the specific case you want

13:59 or, better, make the user pass in the new arglist they want

14:37 abedra: arohner, cool, I'll file that as soon as the library is converted

14:42 robbe-: Hmm, I'm confused about refs and dosync. I understand that if a 'state change' actually involves changing multiple refs, you do that in a dosync block to avoid exposing intermediate state. But what about for example summing all elements of a list implementation with refs. Will reading all values in one dosync block make it sum exactly one version of the list?

14:42 I'm confused because the tail of the list may change wile summing and then you're summing some version of the head and a newer version of the tail, of you wold deref outside of the dosync block.

14:43 raek: all reads from refs inside a transaction will happen as if they all happened at the same point in time

14:43 the STM takes care of this

14:44 dabd: I'd like to parse an html page using clojure.xml/parse. The following code does not work (clojure.xml/parse "http://www.google.com/&quot;) What is the proper way to do it?

14:44 arohner: dabd: you need an HTML to XML parser, like tagsoup

14:44 dabd: The docs say clojure.xml/parse accepts an uri

14:44 ibdknox_: dabd: use tag soup ;)

14:45 dabd: ok let me check

14:45 there is a library called enlive does it work for this?

14:46 arohner: dabd: https://gist.github.com/1168833

14:46 ibdknox_: depends on what you're trying to do

14:46 arohner, dabd: or better than that: https://github.com/nathell/clj-tagsoup

14:47 dabd: ibdknox I am getting it from clojars thx

14:47 clj-tagsoup seems to simplify using tagsoup

14:59 abedra: chouser, ok data.zip just had a 0.1.0 release

14:59 chouser, the comments were all converted to tests

14:59 there were two that were testing things that didn't exist anymore

14:59 chouser, and two that are failing

14:59 I left those in place with a comment

14:59 feel free to cut them if necessary

15:00 mrBliss`: abedra: https://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of "Interrupt Handler", like in the ToC

15:01 abedra: mrBliss`, thanks for the heads up

15:03 ldh: speaking of enlive, given input like the markup here https://gist.github.com/1168880, how can i select only the first img tag? (html/select markup [:img html/first-of-type]) does not work

15:06 thorwil: ldh: nth-of-type?

15:09 in my now left to rot enlive-using code, i have selectors like this: [[:span (html/nth-of-type 1)]]

15:10 ldh: thorwil: no luck with (html/select markup [:img (html/nth-of-type 1)]), which is what first-of-type is an alias for. can you explain the double [[ ]]?

15:11 i'm not sure when or if to use those, nor can I seem to discover any explanation of how the "selector-step" component of the selector works

15:11 thorwil: ldh: i don't recall the why, but i think the [[ ]] is what you should try ;)

15:11 ibdknox_: I love the idea of enlive, but I feel like the syntax needs to be simpler

15:12 ldh: thorwil: weirdly, (html/select markup [[:img (html/nth-of-type 1)]]) returns BOTH images

15:12 ibdknox_: ideally it would just follow the standard selector syntax, and it could parse it into those vectors as an implementation detail

15:12 thorwil: ldh: this is the single place where i used nth-of-type: http://paste.pocoo.org/show/463819/

15:12 ldh: ibdknox_: agreed. maybe it's just that i haven't wrapped my head around the details, but there seems to be a layer of foggy magic which prevents me from fully grokking it

15:14 thorwil: ibdknox: well, much of the selectors is just like CSS

15:14 where you might see things like: [:ul#stored-items :> :li]

15:15 ibdknox_: thorwil: yes, but you lose something by not having it in a string

15:15 thorwil: and the way you use that selector is a far cry from the simplicity of something like jquery

15:15 thorwil: ldh: it helped me to look at enlive code and especially to look at how enlive represents the html. that also opens the possibility for some inbretween manipulation

15:15 ldh: thorwil: your example doesn't seem to work for me. i wonder if there's a bug in 1.0.0

15:16 now i am left to wonder why selectors *aren't* just strings

15:16 ibdknox_: hehe

15:17 exactly

15:17 thorwil: ldh: maybe your html structure is not what you think it is, or more likely, enlive has a differnt idea of what you are asking for

15:17 what can i say, after all i switched from enlive to hiccup :)

15:18 ibdknox_: hehe

15:18 ldh: with such a simple toy example that does not bode well.

15:19 thorwil: ldh: i'm not sure anymore, but nth-of-type is not global, but looks for siblings, perhaps?

15:19 ibdknox_: if only I didn't already have such a huge list of things to work on...

15:19 ldh: i'm actually trying enlive after using hiccup. i like the idea of unobtrusively modifying existing markup, especially when collaborating with others

15:19 thorwil: interesting thought, that would possibly explain the behavior i'm seeing

15:20 thorwil: don't make the mistake of testing right in the browser

15:20 ldh: hmm, but how to select without matching child elements as well

15:20 no, i'm running it at the REPL

15:22 thorwil: yes, if someone else is responsible for the templates, enlive might be worth it. even then, you would likely end up with selection code that is tightly coupled to the templates ...

15:22 ibdknox: just use mustache! :D

15:22 https://github.com/davidsantiago/stencil

15:29 dabd: how do I exec a command such as 'echo 56.8 + 77.7 | bc' with clojure.java.shell? I tried (sh "echo" "56.8 + 77.7" "|" "bc") but it doesn't work

15:35 acagle: ibdknox: I was wondering how long it would be before mustache got migrated to Clojure. The Sproutcore folks are doing some nice things integrating Handlebars (a mustache variant) into their framework.

15:35 ibdknox: acagle: we're using stencil and handlebars :)

15:36 duck1123: I seem to be having an issue with lein. I specify 1.3.0-beta1 in my project.clj, but it still insists on pulling in 1.2. Has anyone else seen this issue?

15:36 ibdknox: acagle: though handlebars didn't adhere to the mustache spec :(

15:38 hiredman: duck1123: one of your other dependencies is pull it in

15:39 duck1123: that's what I figured, but wouldn't my explicit dependency override it?

15:40 ibdknox: duck1123: they're not both there?

15:40 duck1123: ibdknox: no, just 1.2.0

15:41 ibdknox: gist of your project file?

15:41 cemerick: duck1123: version numbers are actually just "preferences". If you want to override, you'll have to use a version range like "[1.3.0-beta1,)".

15:43 amalloy: dabd: c.j.shell just executes a command and passes it args; the | syntax is something bash (and most shells) do for you

15:44 dabd: amalloy: thx

15:45 amalloy: dabd: you can invoke bash instead, and pass it the args "-c" "echo 56.8 + 77.7 | bc", or something like that

15:56 duck1123: Ok, It looks like it was happening because I had Midje set as a runtime dependency

15:57 as soon as I moved it to dev-dependencies, it worked

15:59 cemerick: duck1123: That's because midje is configured to not work with Clojure 1.3.0 at all; notice the version number in its project.clj: https://github.com/marick/Midje/blob/master/project.clj

16:00 That's a fixed version range, allowing two versions of Clojure, and only those two versions.

16:01 duck1123: that makes sense. I have a patched version of Midje that works with 1.3 on my home computer. I'll just grab that

16:39 hiredman: dnolen: https://thestrangeloop.com/sessions/the-mapping-dilemma nice

16:41 dnolen: hiredman: yeah should be fun!

16:42 ubii: anybody have an idea how many folks they expect at Clojure/conj this year?

16:42 Raynes: I'm going. That's all that really matters, isn't it?

16:42 ;)

16:44 joly: They're still doing early-bird registration, so there's probably not a good estimate available yet

16:44 ubii: how many did they have last year?

16:44 ibdknox: they haven't even announced speakers yet :-p

16:45 * joly is glad he gets to go this year.

16:45 cemerick: ubii: ~200

16:45 225 incl. speakers and such

16:46 ubii: thx

16:46 got tied up with work last year, so I didn't get to go, but am thinking of going this year

16:48 also considering the possibility of taking the associated training class on Nov 7-9th

16:52 just curious, is this basically the same class offered through The Pragmatic Studio or is the Clojure/core folks doing this on their own?

17:04 Somelauw: I am not sure, but since map takes multiple arguments, wouldn't it make sense to make filter accept multiple arguments as well like filter(= [1 2 3] [4 2 4]) ;=> [false true false]?

17:05 hiredman: Somelauw: if filter took multiple seqs (filter = [1 2 3] [4 2 4]) would return (2)

17:05 lobotomy_: ##(map = [1 2 3] [4 2 4])

17:05 lazybot: ⇒ (false true false)

17:06 nkoza: when you do (= a-map another-map) you are traversing all the elements to find if the maps are equal? I mean, is = O(n) ?

17:08 lobotomy_: ##(map #(when (apply = %&) (first %&)) [1 2 3] [4 2 4])

17:08 lazybot: ⇒ (nil 2 nil)

17:08 lobotomy_: hmm

17:09 hiredman: nkoza: equality is very complex, but yes, in the case of comparing two maps you walk the maps

17:09 well, two clojure maps

17:09 Somelauw: hiredman: You are right.

17:10 cemerick: n is likely to be smaller than you think, due to hashCode caching

17:10 Somelauw: Oh, I think I understand why now.

17:11 nkoza: hiredman: why is complex?

17:15 hiredman: nkoza: http://en.wikipedia.org/wiki/Relational_operator#Equality http://www.nhplace.com/kent/PS/EQUAL.html http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999

17:15 nkoza: hiredman: thanks

18:06 agz: hey what kind of database library would you suggest for personal use in unix enviroment?

18:08 dnolen: agz: sqlite?

18:09 agz: dnolen: yep, but I heard about mongodb so I thought asking about it.. I just want to pick one which has the easiest/no-complication in clojure

18:09 so I though ask the wise gremium here :)

18:09 tufflax: spit and slurp with pr and read-string?

18:10 agz: tufflax: haha :D -> although maybe you are wright, I will have data of 200Mb max

18:11 in sqlite format it was 100Mb .. but it's outdated now so I can't use that

18:11 how much will it be in plain text?

18:11 tufflax: dunno

18:20 amalloy: 0 bytes if you use an optimal serialization format

18:20 (defn unserialize (constantly {:x 1, :y 2, ...}))

18:21 s/defn/def

18:21 lazybot: <amalloy> (def unserialize (constantly {:x 1, :y 2, ...}))

18:36 leeda: Is this the right way to base64 encode a string?

18:36 ,(str (.encode (new Base64) (to-byte-array "abc")))

18:36 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Base64, compiling:(NO_SOURCE_PATH:0)>

18:37 leeda: ok, have to import org.apache.commons.codec.binary.Base64 and clojure.contrib.io first...

18:42 or maybe: (str (.encode (new Base64) (.getBytes "abc"))) ?

18:46 hm, i guess (str x) != (new String x)

19:02 ibdknox: leeda: unrelated, but it's more idiomatic to use the . notation for instantiation: (Base64.) or (String. x)

19:37 icey: ibdknox: I'm checking out Pinot; starting by following the instructions here: https://github.com/ibdknox/noir-cljs ... I'm getting this crazy-ass chain of errors (https://gist.github.com/1169588), and I'm sure I'm doing something obviously wrong... is there something people tend to screw up when setting this up?

19:37 ibdknox: here's all the code (it's not much - https://github.com/pmn/cljstrial )

19:37 ibdknox: icey: yeah, use cljs-watch instead

19:38 icey: ibdknox: ah, will do, thanks :)

19:38 ibdknox: icey: I've done everything in my power to try and make that work, I even started ripping out pieces of the compiler to isolate what it is

19:38 icey: ibdknox: it's something you've seen before?

19:38 ibdknox: icey: yeah

19:38 icey: apparently the cljs compiler doesn't like being in a jar

19:38 icey: ibdknox: that makes me feel a little bit better, lol

19:39 it was pretty nice to get everything packaged up straight out of clojars

19:39 ibdknox: I know. I tried :(

19:39 scottj: ibdknox: are you aware cljs-watch creates a dir bootstrap.js if run before there are .cljs files ?

19:39 ibdknox: I fixed that I think

19:39 scottj: not pushed

19:40 icey: ibdknox: btw, i implemented your suggestions from that page i posted in here the other day; it ended up looking much cleaner afterwards, thanks :)

19:40 ibdknox: scottj: you are correct. One second :)

19:40 icey: I'm glad :)

19:41 scottj: ibdknox: no hurry I don't need it just fyi

19:42 ibdknox: it was my own fault expecting the Java api to be smart enough not to create a directory out of a file name

19:42 *sigh*

19:43 scottj: pushed anyways :)

19:44 I also made the watcher more resilient to parsing exceptions, so it doesn't quit when you save intermediate states of your file

19:45 scottj: nice, it's annoying how the repl bails on those errors

19:45 ibdknox: brepl fixes that too

19:46 of course then you're in the browser, so may not be what you really want, but just heads up

19:48 scottj: brepl should print a file:// url to the index.htlm so you can just click on it

19:49 ibdknox: your terminal hyperlinks links?

19:49 hah

19:49 cool

19:49 scottj: I'll do that

19:50 scottj: also I don't like that you changed the clojure repl prompt format :)

19:50 ibdknox: I did it on purpose, since it's not the clojure repl and it behaves differently than the clojurescript repl likely ever will

19:51 amalloy: ibdknox: your terminal doesn't? what OS?

19:52 ibdknox: amalloy: I just tried it on linux and it did, I'm usually on OSX and it may very well do that... I just never use the mouse such that I would see it haha

19:53 amalloy: heh, i hear you. if i could figure out how to cut/paste from the terminal emacs-style without the mouse...

19:53 ibdknox: yeah that has always bothered me

19:53 tomoj: ibdknox: nice!

19:53 I hadn't seen cljs-watch

19:54 ibdknox: tomoj: as far as I can tell it works for everyone, so I'm happy about that lol

19:54 scottj: with urxvt you can folow the hyperlinks with keystrokes conkeror hinting style

19:54 tomoj: wha?

19:54 I've been using urxvt and never knew

19:55 ibdknox: I really wish I could get noir-cljs to work consistently

19:55 tomoj: everything should work like conkeror

19:55 ibdknox: when I stop being lazy, I'll submit a patch to get cljs-watch into clojurescript itself

19:58 scottj: you can also copy with keys using screen

19:58 icey: ibdknox: switching from noir-cljs to cljs-watch did the trick. everything's rock & roll now. thanks

19:58 ibdknox: icey: good deal, let me know if you run into any issues

19:59 amalloy: scottj: i confess i'm barely competent with screen. opening multiple terminal emulators is just easier

19:59 icey: ibdknox: this is the first i've spent any time with clojurescript, so it may be a day or two before i know enough to have real questions :)

19:59 scottj: amalloy: it's not emacs style though, it's vi

19:59 ibdknox: icey: haha good luck ;)

19:59 icey: nah, pinot should make it relatively painless. Though if you have errors, it can be very difficult to track them down

19:59 amalloy: scottj: the default C-a screen prefix makes me want to rip someone's throat out

20:00 scottj: ibdknox: what's the plan for returning the result in brepl not the browser?

20:00 cljs browser branch style

20:01 amalloy: it sure prevents me from using emacs in screen, but other than emacs it's better imo than the stumpwm C-t default. of course both can be changed

20:01 amalloy: of course. but it prevents me from using the dang shell prompt, because i navigate around that with C-a as well

20:01 scottj: oh yeah I've gotten pretty used to C-a a

20:02 ibdknox: scottj: I expect brepl to eventually no longer be necessary

20:02 amalloy: heh

20:02 on the rare occasions i remember to use screen, i just use C-z

20:02 ibdknox: scottj: I also think it's more valuable to have the result in the browser, since I can then inspect objects and such

20:02 scottj: amalloy: actually do C-a a a pretty often since I run screen's inside of screens

20:03 amalloy: i'm pretty sure that makes you a lunatic

20:04 * ibdknox agrees with amalloy

20:04 ibdknox: haha

20:04 scottj: ibdknox: see if you used emacs you'd change your mind on both the prompt and return values I think

20:04 amalloy: not sure if that means: "It's a thing that lunatics do", or "If you do it, you become a lunatic"

20:04 ibdknox: scottj: I can't inspect a dom object in emacs

20:05 scottj: since it would allow you to use inferior-lisp and C-x C-e expressions from your code

20:05 ibdknox: you return it in both places :)

20:05 keep current return but also send it back to brepl

20:05 ibdknox: yep yep

20:05 I did that originally

20:05 it didn't do well with it

20:05 since the result is often a long javascript function

20:06 that needed to be broken up over multiple websocket frames

20:06 you have to keep in mind brepl was done in a night + a couple hours the next day :)

20:06 I had originally expected to help with the official clojurescript bcrepl

20:09 scottj: require and fault tolerance are the things I really like over bcrepl

20:11 ibdknox: to be honest, I find it easier to not use the repl in this case

20:11 it's easier to just let the watcher recompile the thing and refresh

20:41 agz: hey guys, my agents are lost:

20:41 (def a (agent []))

20:41 (send a conj 1)

20:41 (await a) <-- and no return

20:42 amalloy: maybe someone called shutdown-agents?

20:42 agz: lein swank clojure 1.2.1 contrib 1.2 fetcher 0.5-SNAP clj-time 0.4-SNAP

20:42 uhm googling shutdown-agents

20:43 what I observed, that with a fresh restart of the server it still doesn't work - maybe fetcher did shutdown?

20:43 amalloy: fetcher?

20:43 agz: https://github.com/getwoven/fetcher/blob/master/project.clj

20:43 http grabber

20:44 amalloy: holy...i just saw the (ns) statement in fetcher.core

20:45 ibdknox: wow

20:45 agz: shutdown agent is not called - if I write the above in the fresh interpreter the

20:46 the idleing occur.. :(

20:47 is there an easy way to print the threadpool or sg?

20:51 dohh .. something is really wrong here, if I start a total fresh interpreter with only clojure1.2.2 and contrib1.2.0 swank1.2.1 still not working :O

20:55 reboots

21:00 hey I've lost my agents, a bit desperate here ,D

21:00 (def a (agent [])) (send a conj 1 2 3) (await a) <--- hangs

21:04 cemerick: that ns form is out of control. Something went pear-shaped there.

21:07 agz: if I lein-swank a totally different project with no dependencies other than clojure I still got this misfunction

21:08 I don't know lein - so is it possible installing fetcher made something wrong, which affects interpreter even if I don't include fetcher??? - It would be somehow beyond my comprehense

21:09 ibdknox: agz: did you install it as a plugin?

21:11 agz: ibdknox: no.. I lein install -

21:11 ibdknox: agz: it shouldn't pick it up then

21:11 but the simplest way to prove that

21:11 is to remove ~/.m2/repository

21:12 agz: then check to see what's in ~/.lein

21:16 agz: ibdknox: I cleaned .m2/repository

21:16 with lein deps it downloaded a new clojure

21:16 but still not working .. is it possible that it's problem with the jvm?

21:17 ibdknox: no idea

21:17 agz: ibdknox: anyway thx

21:17 ibdknox: most likely has to be given that you just removed everything specific to clojure right there, assuming you've only used lein

21:18 agz: btw I have lein-1.4.2 and lein-1.6.1 in ~/.lein

21:18 dont is it have any effect

22:41 technomancy: agz: you need swank 1.3.2 which plays well with lein's workaround for Clojure's lack of control over thread pools

22:45 oh, he's gone

22:47 quotemstr: Is the Java 7 dynamic language stuff good for Clojure?

22:53 technomancy: quotemstr: sorta. afaict it can make calls that would otherwise be reflective significantly faster, but not as fast as if they were hinted

22:54 quotemstr: Ah, cool.

22:54 I'll have to read up on the details sometime.

22:55 technomancy: quotemstr: so there's reluctance to drop compatibility with java 6 or add two modes to the compiler since it's not pure awesome

22:56 quotemstr: technomancy: As long as it's source-compatible, I don't see a problem. It's no different from gcc optionally compiling binaries that won't work on older CPUs, yes?

22:57 technomancy: well, if someone were so inclined to add it to the compiler, it's not out of the question that it'd be accepted. I just don't think there's anyone currently working on it or planning to.

22:57 srid: can I define multiple entry points instead of the singular `lein run`?

22:57 it seems that project.clj can only contain one :main entry

22:58 i want to define one entry for running the web app, and another for running the command line interface.

22:59 technomancy: srid: lein run -m my.name.space # ought to do it

23:00 amalloy: thanks, clojure, for immutability-by-default, and atoms/stm for the rest. means i don't have to be too ashamed i never really grasped the difference between barriers and guards, or whatever locking constructs

23:26 icey: ibdknox: cljs-watch is working great, but you may want to add the note from the mailing list regarding copying the goog.jar to the readme on github

23:45 technomancy: bizarre: 3x as many python refugees in haskell vs former rubyists, while they are neck and neck with clojure

23:47 icey: technomancy: because of significant whitespace, maybe?

23:47 technomancy: icey: it could also be that there are just a lot more pythonistas than rubyists and clojure is the odd one for having an even number

23:48 icey: technomancy: also very possible

23:48 technomancy: are there many perl people getting into haskell?

23:49 technomancy: icey: only 6% vs 10% ruby and 28% python

23:50 icey: other than the reputation for being ultra-functional and "mind-bendingly hard" to pick up, what is the major marketing point for haskell? is it just the ultra-functional part?

23:51 technomancy: the type system, I guess?

23:51 it's a lot stricter than ocaml/scala about purity

Logging service provided by n01se.net