#clojure log - Aug 17 2010

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

0:00 dnolen: seangrove: you don't have to use my plugin, but if your native libs are in the right place, lein will pick them up for you.

0:02 seangrove: Is that url your plugin?

0:03 dnolen: seangrove: yes

0:03 seangrove: Very cool

0:03 Is there a way to start clojure in 32bit?

0:04 technomancy: seangrove: depends on the platform. try starting java with the -client flag

0:04 seangrove: I'm on snow leopard

0:04 technomancy: hmm; I think you have to compile your own Java for that unfortunately. =\

0:04 seangrove: Seems that the jni is only supposed to run on 32bit :P

0:04 Haha

0:04 Goodness

0:05 dnolen: seangrove: that why I didn't bother with OpenCV, Xuggle is 64bit.

0:05 seangrove: in yr Utilities directory there is the Java utility, launch and pick the 32bit one

0:07 seangrove: Looking for that...

0:10 dnolen: http://stackoverflow.com/questions/3363637/opencv-2-1-mac-os-x-webcam-issues-32-and-64-bit

0:11 seangrove: Got it I think

0:12 Alright, imported :)

0:12 Thanks guys!

0:12 That was the biggest issue so far

0:13 I'd like to get this working in lein in a bit, but this is the first big step

0:43 Cool, got it all working, thanks!

0:48 bmh: good evening, channel

0:50 technomancy: release candidate for Leiningen 1.3.0: http://github.com/technomancy/leiningen/blob/master/NEWS

0:51 bmh: I'm interested in converting a bitfield into a IEEE float. Clojure's bit ops seem to only work on integer types. Any advice?

1:27 slyrus: ,(flatten {3 4 5 6})

1:27 clojurebot: ()

1:30 tomoj: ,{{}}

1:30 clojurebot: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1

1:30 tomoj: ,(identity {{}})

1:30 clojurebot: 1

1:30 tomoj: wat

1:30 I get {}

1:30 $(identity {{}})

1:30 sexpbot: This command is old. Use -> now. It's a hook, so it can evaluate anything, even stuff that doesn't start with parentheses.

1:30 tomoj: ->(identity {{}})

1:30 sexpbot: java.lang.ArrayIndexOutOfBoundsException: 1

1:30 tomoj: hmm

1:31 ,(read-string "(identity {{}})")

1:31 clojurebot: 1

1:31 tomoj: ,(read-string "(identity {})")

1:31 clojurebot: (identity {})

1:31 tomoj: what the heck?

1:33 -> (sequential? (first {3 4 5 6}))

1:33 sexpbot: => true

1:33 tomoj: slyrus: ^

1:33 slyrus: hmm...

1:34 tomoj: err

1:34 -> (sequential? {3 4 5 6})

1:34 sexpbot: => false

2:16 alpheus: How do I make an InputStream from a string?

2:19 cgrand: alpheus: (-> "hello world" (.getBytes "UTF-8") java.io.ByteArrayInputStream.)

2:20 alpheus: thanks!

2:21 raek: alpheus: you can also create a Reader (the Character counterpart for InputStream, which reads Bytes) with:

2:21 (java.io.StringReader. "HelloWorld")

2:23 alpheus: Would either one be a suitable argument to net.cgrand.enlive-html/html-resource ?

2:23 raek: but that depends on whether you need a stream of bytes or characters (the latter is more likely in the case of a web server)

2:27 I did a quick glance through the code, and it looks like both should work

2:28 I'm inclined to recommend the Reader approach, since it does not do the extra encode to byte and decode into character step

2:29 but maybe cgrand himself can answer the question more accurately...

2:33 cgrand: alpheus: yeah, use a Reader, but you can also trade your html-resource for a html-snippet. (html-snippet "<html>....</html>")

2:38 adityo: good morning

2:40 how can i flatten a map i.e {a 1, b 2, c {"foo" "bar"}} into {a 1, b 2, "foo" "bar"}

2:41 contrib's flatten might not work on this

2:48 raek: ,(let [m {:a 1, :b 2, :c {"foo" "bar"}}] (into (empty m) (apply concat (for [[k v] m] (if (map? v) v [[k v]])))))

2:48 clojurebot: {:a 1, :b 2, "foo" "bar"}

2:49 raek: ,(let [m {:a 1, :b 2, :c {"foo" "bar"}}] (apply merge (for [[k v] m] (if (map? v) v {k v}))))

2:49 clojurebot: {"foo" "bar", :b 2, :a 1}

2:50 adityo: thanks raek, ;)

3:50 LauJensen: technomancy: You're the man!

3:50 Good morning all :)

7:19 raek: haven't seen this approach for exceptions before: http://github.com/richard-lyman/amotoen/blob/master/src/com/lithinos/amotoen/errors.clj

7:19 it avoids the subclassing issue in a pretty interesting way

7:44 hanDerPeder: with my current intuition, reduce and apply can be used pretty much interchangeably.. am sure this can't be correct. does anyone have a good example where one could be used but not the other?

7:46 Raynes: ->(apply + 1 2 3 4 [5 6 7 8 9]) ; I don't think you can do stuff like this with reduce.

7:46 sexpbot: => 45

7:47 Raynes: Plus, what they do is completely different.

7:48 fogus_: ,(apply hash-map [2 3 4 5])

7:48 clojurebot: {2 3, 4 5}

7:48 fogus_: ,(reduce hash-map [2 3 4 5])

7:48 clojurebot: {{{2 3} 4} 5}

7:48 Raynes: Apply simply applies the function to the sequence of arguments as if they were individual arguments. It "unrolls" a sequence.

7:49 Reduce applies a function to the first two elements of a sequence (or the first element and the initial value you optionally provide) and then applies the function to the result of that and the next element and so on until the sequence is depleted.

7:49 They only appear to do same thing in certain situations, such as with the arithmetic functions.

7:49 raek: for variadic functions like +, they happen to have the same result

7:52 hanDerPeder: ahh, ok

7:52 thanks!

7:52 fogus_: raek: hash-map is variadic

7:53 Raynes: raek: Just be quiet and bask in the glory of my explanation. ;P

7:54 hanDerPeder: so when using the max or an arithmetic function, is one considered better style than the other?

7:55 ie, (apply max '(1 2 3)) vs (reduce max '(1 2 3))

7:56 Raynes: I always use apply when I picture the final result as being the application of a function to a set of arguments that happen to be in a sequence, such as in the case of my + example above.

7:57 fogus_: raek: Maybe you mean "associative" :-)

7:57 Raynes: hanDerPeder: I'd use the former, because it makes more sense in my head.

7:58 hanDerPeder: Raynes: seems like a fair heuristic, thanks!

7:59 Raynes: rhickey: Morning.

8:00 rhickey: hi

8:01 metagov: This morning I was surprised this expression worked at all: (def a [a])

8:02 It appears to be an array whose first element is an earlier version of the array.

8:02 (ie an empty arrary)

8:03 fogus_: metagov: Why is that surprising?

8:04 metagov: fogus_: I thought the reader would complain

8:04 fogus_: It will complain if a had not been previously defined, but otherwise no problem

8:06 metagov: But I thought the symbol 'a', while created, wouldn't have been bound until after the overall (def ...) expression finished.

8:07 fogus_: `a` must have been bound previously no?

8:08 metagov: oh! right! I forgot I'm in a repl.

8:08 fogus_: :)

8:09 Raynes: Dun dun dun.

8:09 metagov: I keep thinking I can't rebind symbols like they're read only or something.

8:11 So, quitting the repl and trying it anew, I get the error I was expecting. Thanks :-)

8:12 fogus_: Public poll: If *you* were creating a unification library what would you do on a clash? 1) Throw an Exception 2) Throw a ClashException 3) Return a kw ::clash 4) other

8:14 Raynes: fogus_: Is scream and run in circles an option?

8:15 fogus_: That's contained in #4 :p

8:16 * metagov votes for #4 (the Raynes version)

8:19 fogus_: Reading: http://stephen.wolfram.usesthis.com/

8:20 hoeck: fogus_: are there any other exceptions a unification can throw? If not, I would use a plain Exception.

8:21 fogus_: hoeck: Yes. It can also throw on a cycle. I'm currently going the ::cycle/::clash route, but am not completely satisfied

8:24 hoeck: fogus_: is this lib available somewhere?

8:24 fogus_: hoeck: not yet

8:33 LauJensen: fogus_: the clashexception sounds good to me

8:34 nickik: can somebody help me with some namespace problems?

8:34 I have a namespace (main.players) with some records in it. Called nice and asshole (they are bots for a game).

8:34 In the main.core I include it. (ns main.core (:use [main.players]))

8:35 So far so goot but know I want to test it.

8:35 fogus_: LauJensen: I would like to avoid AOT if at all possible, but will if that makes the most sense.

8:35 nickik: This is in the testfile:

8:36 LauJensen: Ok

8:36 nickik: (ns titfortat.test.core (:use [titfortat.core] :reload-all) (:use [clojure.test]) (:import [titfortat.players nice]) (:import [titfortat.players asshole]))

8:36 fogus_: Another option of course is to throw Exception on one and Error on the other

8:36 nickik: but in the testfile i cant get a new player like this (nice. [])

8:37 LauJensen: fogus_: To me the biggest concerns are always quality through predictability. I'm afraid passing keywords around etc can lead to misundertandings. An exception seems like the right response to something like that. But its a matter of taste I guess

8:38 fogus_: LauJensen: I think I agree

8:41 hoeck: nickik: and whats the exception?

8:43 nickik: @hoeck No matching ctor found for class titfortat.players.nice

8:43 hoeck: nickik: that means the (nice. []) call is wrong

8:44 has the wrong number of arguments

8:44 for each field there must be an argument in the ctor-call

8:44 (defrecord nice [a b c]) -> (nice. 1 2 3)

8:45 * fogus_ When in doubt, always remember: WWJBD

8:45 LauJensen: fogus_: Jich Bickey ?

8:45 hoeck: if the class has not been imported, it would have been a "unable to resolve classname: nice" Exception

8:46 fogus_: Josh Bloch ;-)

8:47 LauJensen: :)

8:47 I knew it was a long shot going in :)

8:48 nickik: @hoeck thx, I'm an idiot. The error that caused the problem I resolve myself and than I had a other one and didn't notice it.

8:54 LauJensen: fogus_: Out of curiosity, what would he do in this case?

8:59 fogus_: He'd pick an existing Exception that corresponds to the type of problem. For example, a cycle could be likened to an IllegalStateException.

8:59 LauJensen: Ok, makes sense

9:29 cemerick: technomancy: I'm really surprised that you're recommending that people push personal copies of jars into clojars (looking at the lein readme)...

9:46 bmh: I'm interested in converting a bitfield into an IEEE float, but clojure bitops only work on integer types. Should I just be looking at doing this with the java interop?

9:47 puredanger: If anyone's interested, I just published a short interview with Chris Houser http://thestrangeloop.com/blog/10/08/17/strange-loop-speaker-interview-chris-houser

9:54 nickik: should I write unit-test for macros?

9:56 esj: you should test everything :)

9:58 bmh: nickik: Just implement static type checking in the macro system. Take a look at Soft Typing by Cartwright and Fagan ;-)

10:03 apgwoz: what's the best way to traverse a hiccup produced tree? i, for instance, want to pull out specific elements and get the text from them. it doesn't fit the xml produced by clojure.xml

10:07 bmh: ok, java interop it is

10:11 jfields: is there a better way to do this? -

10:11 (deftest add-values

10:11 (is (=

10:11 {:a {:b 4 :c 7}}

10:11 (merge-with (partial merge-with +) {:a {:b 2 :c 3}} {:a {:b 2 :c 4}}))))

10:20 pdk: (doc reduce)

10:20 clojurebot: "; "

10:20 pdk: ok who maintains clojurebot again

10:20 hiredman right

10:21 (doc is)

10:21 clojurebot: "clojure.contrib.test-is/is;[[form] [form msg]]; Generic assertion macro. 'form' is any predicate test. 'msg' is an optional message to attach to the assertion. Example: (is (= 4 (+ 2 2)) \"Two plus two should be 4\") Special forms: (is (thrown? c body)) checks that an instance of c is thrown from body, fails if not; then returns the thing thrown. (is (thrown-with-msg? c re body)) checks that an instance of c is thrown AND

10:42 no_mind: with Oracle showing aggressiveness over Java patents, can clojure be dragged into Java patent minefield ?

10:43 cemerick: no_mind: Oracle has patents related to VMs, not languages. Clojure and other JVM languages aren't within spitting distance of that sideshow.

10:46 Chousuke: and why would oracle harass languages that can be used to write more software for their platform :P

10:46 My guess is they target Dalvik because it's not compatible with the java platform

10:46 apgwoz: i think they target Dalvik because they already have a dying mobile platform

10:50 Luyt: I think they target Dalvik to squeeze out some $$$ from Google

10:51 But it leaves a nasty taste in my mouth, and I frown when I see my system use BerkeleyDB or MySQL.

10:51 Raynes: I think they target Dalvik because they were bored and didn't feel like being creative.

10:55 nickik: if i have namespaces A, B and C. A uses B, B uses C. In C is a macro and i want to use that macro form a what do I have to do? Do I have to include (use) C in A?

10:55 apgwoz: so, are zippers the way to go to traverse arbitrary trees even if you're not modifying them?

10:56 no_mind: for whatever reason they are suing dalvik, they are still suing an entity which is making developer build more and more programs on there platform

10:56 arohner: Oracle is suing because they're not getting JavaME licenses from dalvik

10:57 which used to be a decent source of money for Sun

10:58 Raynes: nickik: Yes.

10:58 arohner: apgwoz: they can be. I've used zippers for scraping HTML

10:58 apgwoz: arohner: so, it'd be a great way to scrape stuff from hiccup?

10:59 are there any selector sort of interfaces on top of something like hiccup? i know enlive will do this against the xml structures

11:00 nickik: as far as I understand it the VM stuff the have patents on is common in many VMs (smalltalk ...) and the want to hit google. If the win google pay.

11:00 *they

11:01 arohner: zf-xml works just fine against the HTML that hiccup produces

11:01 fogus_: arohner: Why would they get JavaME licenses from Davlik? Davlik is not JavaME right?

11:01 apgwoz: zf-xml?

11:01 ahh

11:01 zip-filter.xml

11:01 cool

11:01 i'll check it out

11:02 arohner: fogus_: right, but dalvik is a substitute for javaME, taking money away from Oracle

11:04 fogus_: arohner: Competition hurts

11:04 Luyt: However, Google has always made sure there wouldn't be any licensing troubles with Dalvik. This is the test if that worked.

11:12 cemerick: fogus_: I'd be very surprised if Google ends up being the white knight in all this. As it is, they've successfully pushed a Java-but-not-Java VM into the world that, in practical terms, serves their interests and not Sun/Oracle's, and probably not mine.

11:14 fogus_: cemerick: Maybe you could have asked them... I'm sure they would have thrown some cemerick love into the mix

11:15 nickik: maybe they did it because the offical one sucks

11:15 cemerick: fogus_: Unlikely. Every now and then, instead of search results, I just get a white page that says "Suck it, cemerick" in bold type. :-(

11:16 nickik: That's just a little silly. Dalvik only recently got a JIT.

11:16 fogus_: Wow... my type is blinking. Is that better or worse?

11:16 cemerick: fogus_: BLINKING? That HTML is coming from inside the building! Get out!

11:18 nickik: @cemerick is the offical one fast? on most phones I had it seamd very slow

11:19 cemerick: nickik: I've never messed with mobile stuff much, couldn't say.

11:21 nickik: @cemerick don't no either but the had some reason

11:21 slyrus: any other fnparse users around? I've been having fun with it.

11:21 cemerick: Lots of reasons, I'm sure. We'll see if they turned out to be legal.

11:21 slyrus: and morning folks

11:29 fogus_: Jeez, not only is chouser a Vi user, but he also got his start in the TI-99/4A! What's next?

11:29 slyrus: hunt the wumpus!

11:40 arkh: q: "What makes JoC unique?" a: "Fogus wrote it - what more do you need?"

11:49 edbond: does enlive have some specific function to get attr (:href) from node?

11:49 or it's ok to treat node as map and use get-in :attrs :href?

11:50 dnolen: edbond: that's the right approach, the node is just a map.

11:52 edbond: dnolen: thanks

12:05 nickik: how to write a function that gets a nummer as input "n" and returns true in n% of the time

12:05 is there something like that in a lib

12:09 qbg: (< (rand-int 100) n)

12:11 ,(reduce + (map #(if % 1 0) (repeatedly 100 #(< (rand-int 100) 33))))

12:11 clojurebot: 29

12:11 qbg: ,(reduce + (map #(if % 1 0) (repeatedly 1000 #(< (rand-int 100) 33))))

12:11 clojurebot: 351

12:14 technomancy: cemerick: it's true though; java on mobile devices is widely regarded as terrible

12:14 before android, anyway

12:14 cemerick: absolutely agreed

12:15 Of course, that's neither here nor there in court.

12:16 technomancy: headius makes a pretty good case on his blog that the patents are absurd.

12:16 of course ... they're software patents, so they're already absurd by definition. but they don't seem to hold a bit of water.

12:17 nickik: (< (rand-int 100) n) works nicely

12:17 cemerick: I'm of two minds about it. People always say "oh, that's obvious", when the people that filed the patent may have been the ones that made it obvious.

12:17 qbg: If you want n to be real, you can use rand instead of rand-int

12:19 arkh: anyone one ever see an exception for cake like this? "Exception in thread "main" java.io.FileNotFoundException: .cake/project.log (Permission denied) (NO_SOURCE_FILE:0)"

12:19 cemerick: In any case, I don't think Google deserves any pity, etc. They went into this with their eyes open, and they're big boys with a lot of money. Let 'em fight it out.

12:20 arkh: I'd rather see the fight avoided and patent reform take place instead

12:21 cemerick: That ship sailed a looong time ago. :-)

12:21 * metagov keeps hoping another ship will be built

12:22 arkh: Viva La Revolución

12:23 * cemerick has yet to see a realistic patent reform proposal. "No more patents!!11!11" doesn't seem like a well-thought-out policy.

12:23 arkh: agreed

12:24 technomancy: eh; "no more _software_ patents" seems to be working well for other countries

12:24 arkh: our democracy would work if people really used it :)

12:24 ... but they don't :(

12:26 cemerick: technomancy: I dislike policy that downgrades my profession to time-and-materials labor. If I come up with something that's truly novel, and I want exclusivity in the market, I don't see why I shouldn't have the same opportunities as the guy who designs a better screw.

12:26 The details are a complete mess, but that's where I'm grounded.

12:28 technomancy: then we can agree to disagree. you and I, we are good at that. =)

12:28 cemerick: yes, yes we are :-)

12:29 technomancy: can I surmise then that you'd prefer a purely FOSS world where support is your primary stream of income?

12:30 * cemerick is an expert at straw men

12:31 technomancy: cemerick: and a pony, if you're asking.

12:32 Joreji: Given (let [x 0] (let [x 1] ...)) - is there any way to access the outer binding of x (i.e. x==0) within ... ?

12:34 cemerick: Joreji: nope. Lexical scope is what it is.

12:34 i.e. no fancy tricks like OuterClass.this.field as in Java

12:36 Joreji: cemerick: Hmm, alright. Guess I'll just rename the var.

12:36 Thanks!

12:36 no_mind: Is there a templating engine in clojure which can use HTML files as input ?

12:38 metagov: no_mind: http://wiki.github.com/cgrand/enlive/getting-started

12:42 no_mind: metagov, the doc says enlive is not a templating system but a html transformation library

12:43 I need a templating system where code can be embedded into the template and templates can include other templates

12:44 phobbs: What is the difference between next() and more() for ISeqs?

12:47 metagov: no_mind: I'm thinking of using enlive as a templating system by combining html files + clojure files. The templating code, including embedding, appears in .clj files and the templates are just .html files.

12:48 So, you get equivalent functionality but in two files instead of one.

12:48 no_mind: hmm, how will you achieve thing like, filling a select box options ?

12:49 two files is okay with me

12:50 metagov: no_mind: I don't know about select box options specifically.

12:51 I'm, unfortunately, not that experienced with enlive :-/

12:52 no_mind: ok

12:55 metagov: no_mind: I do know that enlive uses 'selectors' which give CSS-like access to the html: http://enlive.cgrand.net/syntax.html

12:56 phobbs: more() returns PersistantList.EMPTY when empty and next() returns null.

13:00 cgrand: no_mind: (deftemplate my-page "html/page.html" [opts] [:select#id :option] (clone-for [opt opts] (content opt))) ; with your <select> having a dummy <option> in your file

13:01 phobbs: more is lazy, it doesn't force evaluation of the "rest", next evaluates it and always returns nil when empty

13:14 pdk: (doc more)

13:14 clojurebot: Pardon?

13:17 phobbs: (doc next)

13:17 clojurebot: "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."

13:42 nickik: (defrecord test-record [a b c])

13:43 how to get from (test-record. 1 2 3) to "test-record"

13:43 raek: nickik: it is probably a good idea to make a constructor function

13:44 that fn could take as many or as few args as you, independently of how many fields the record has

13:45 pdk: (doc lazy-cons)

13:45 clojurebot: I don't understand.

13:45 raek: as Stuart Halloway pointed out in one of the currently active google group thread, protocols are only used in clojure as an implementation detail

13:46 the user doesn't need to know that protocols are involded

13:46 nickik: how does that help me with the name? I want something better than (defrecord test-record. a b c name) (:name (test-record. 1 2 3 "test-record") to get to the name of a record

13:48 raek: you want the name of the record type as a string?

13:48 I thought you were asking about how to get away the dot from the constructor... :)

13:48 sorry

13:49 pdk: lazy-cons has been replaced by lazy-seq + cons (but you don't have to use cons, of course...)

13:56 pdk: does it affect anything if you drop the cons raek

13:57 at first glance i assumed lazy-cons would have been shorthand for (lazy-seq (cons ...

13:57 (doc lazy-seq)

13:57 clojurebot: "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls."

13:59 raek: pdk: lazy-seq only delays the evaluation of some sequence

13:59 so you always need to put something in it

14:00 pdk: hmm

14:00 raek: maybe an example would help

14:00 pdk: yeah so you need to have a sequence in the body of lazy-seq

14:00 which would be e.g. cons

14:00 raek: exactly

14:01 (defn my-repeat [n x] (cons x (my-repeat (dec n) x)))

14:01 eager version, don't do this ^^

14:02 oh sorry, I'm really tired today, forgot the condition...

14:02 pdk: its the fun way

14:02 since it's eager it gets me excited to run this function

14:03 raek: http://gist.github.com/531174

14:03 there

14:04 you should always be able to get an eager version if you simply remove the surrounding lazy-seq

14:05 lazy-seq simply returns something that evals and returns the body when you call seq on it

14:05 subsequent seq calls will be caches

14:06 this is also thread safe, of course

14:07 http://gist.github.com/480608 <-- this can be useful to experiment with when the lazy seq are actually realized

14:58 alpheus: What's a good way to store configuration for a clojure program? Presumably I can just write clojure code and call load on the config file. But what's recommended?

15:02 LauJensen: alpheus: usually depends a little on who's reading it

15:34 jfields: is there any fn that reloads all of the current namespaces?

15:34 (user defined namespaces)

15:35 technomancy: jfields: there's not really anything special about user-defined namespaces; they're all first-class

15:35 except clojure.core; that's zeroth-class

15:35 but yeah, no such function

15:35 jfields: k, thx

15:36 technomancy: jfields: it'd look like this though: (doseq [n (all-ns)] (require [(.getName n) :reload]))

15:41 jfields: technomancy, will that reload all ns's?

15:45 chouser_: you might want :reload-all instead of just :reload, or macros might not get updated in the right order

15:46 chouser: you might want :reload-all instead of just :reload, or macros might not get updated in the right order

15:52 AlmostObsolete: Hi all, I want to install Clojure with SLIME on Ubuntu. I'm an experienced Emacs user. What's the best method/setup these days?

15:55 raek: it's recommended to start the swank server outside emacs (or more accurately, without swank-clojure.el, which is deprecated)

15:56 the swank server can be started with a project management tool, such as leiningen, cljr or cake

15:56 AlmostObsolete: Thanks raek, any suggestions on which of those to look at first?

15:56 Would this be a reasonable up to date setup? http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

15:57 raek: AlmostObsolete: I recommend to read the official swank-server docs first of all: http://github.com/technomancy/swank-clojure

15:57 I use leiningen for my projects

15:58 cljr can be neat if you don't want to create a project everytime you want to do something in clojure

15:59 if you add :dev-dependencies [[swank-clojure "1.2.1"]] to you project.clj with leiningen, starting up a swank server is just a matter of running lein swank

15:59 (after having ran lein deps)

15:59 http://github.com/technomancy/leiningen <-- leiningen docs

16:00 last time i installed slime, I did it through ELPA

16:01 (slime, slime-repl and clojure-mode are the packets you'd want)

16:01 AlmostObsolete: that guide compiles clojure from source, wich is rarely necessary

16:02 AlmostObsolete: thanks

16:02 I guess I'd better start reading then

16:03 raek: http://www.assembla.com/wiki/show/clojure/Getting_Started <-- this has gotten pretty good

16:03 anyway, use slime-connect to connect to the swank server from emacs

16:07 AlmostObsolete: thanks, I'll take a look at that!

16:32 smokecfh: raek: i recently found out that there is 'clojure box' which is a great way to get started; but it is not mentioned on the assembla site

16:44 technomancy: smokecfh: IIRC it's not cross-platform

16:44 but then again, leiningen is only vaguely cross-platform

16:46 smokecfh: correct, 'clojure box' is for windows only. am i right in assuming that most clojure development is done on linux?

16:46 technomancy: smokecfh: hard to say, but going by bug reports and patch submissions, I'd estimate windows users as less than 10% for the projects I work on.

16:46 kotarak: smokecfh: there are some windows guys, and also a lot of Macs

16:47 technomancy: that metric is probably a bit biased against Windows since there's a history of having a hard time with git on that platform though

16:48 kotarak: technomancy: there is was svn history before git. I don't think that is really a problem.

16:48 LauJensen: fogus_: Thinking about what we were discussing earlier, whats the definitive advange of using prexisting exceptions?

16:49 technomancy: kotarak: well I was looking for a more gentle way to say "Windows users don't contribute as much on average" =)

16:50 * LauJensen whistles something about productivity on linux

17:07 caljunior: Messing around with Obba (http://www.obba.info/) trying to use OpenOffice as a GUI for my clojure app.

17:09 hiredman: clojurebot: restfn?

17:09 clojurebot: ant clean and rebuild contrib

17:09 caljunior: Is there any prior art in the clojure community on using obba?

17:11 Or any thoughts on whether it would be at all viable to call clojure functions via java via obba/openoffice?

17:24 holoway: hi

17:24 clearly a lame question, but i'm trying to call a function for every item in a vector

17:25 and it looks like for is the answer, but I'm clearly getting something wrong

17:26 chouser: map should do too

17:26 ,(map inc [1 2 3 4])

17:26 clojurebot: (2 3 4 5)

17:30 holoway: chouser: thanks!

17:47 ecyrb: What's the proper / ideomatic way to do something like (zipmap (map first xs) (map second xs)) ?

17:48 hiredman: apply hash-map

17:48 chouser: probably (into {} xs)

17:49 hiredman: as long as you are calling first and second on two element vectors there

17:49 ecyrb: yes

17:51 thanks guys. I don't know why I couldn't see that.

17:51 though, hash-map is a confusing name.

17:52 I mean, I know it's in the core, but I keep thinking it returns a HashMap for some dumb reason.

17:52 raek: it reaturns a PeristentHashMap

17:53 ,(class (hash-map :a 1 :b 2))

17:53 clojurebot: clojure.lang.PersistentHashMap

17:53 raek: (modulo spelling)

17:57 arkh: if a transaction is retried multiple times with following: "(dosync (ref-set reference (Object.)))" is a java object generated with each try?

17:59 raek: yes

18:00 only ref access and agent sends are affected by transactions, afaik

18:00 arkh: fair enough ... back to the drawing board

18:00 raek: you can do something like (let [o (Object.)] (dosync (ref-set reference o))) i guess...

18:01 arkh: oh yeah

18:01 :)

18:01 I must be staring at the screen for too long o.0

18:02 ecyrb: Oh wow, I didn't realize they were true hash-maps. Karl Krukow's blog is really good.

18:03 Joreji: Hey guys, I'm destructuring a map using {:keys #{k1 k2} :or {k1 0 k2 1}} - is there some way to have clojure raise an error when a key not in #{k1 k2} has been specified?

18:05 nickik: are the slides for this http://vimeo.com/9090935 somewhere?

18:05 chouser: should be :keys [k1 k2]

18:06 MayDaniel: A set can be used too.

18:07 chouser: hm, really? I wonder if that can be relied upon.

18:07 Joreji: chouser: I've always used sets. Worked so far.

18:08 chouser: interesting

18:11 raek: ecyrb: this is how they are implemented http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/

18:12 vectors: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/

18:13 oh sorry

18:13 that *is* Karl Krukow's blog

18:14 didn't see his name at first

18:14 please disregard the previous lines... :)

18:17 ecyrb: np :)

18:28 rhudson: yow, {:keys (a b)} works too. But a vector's the documented form

18:47 raek: hrm, it seems like clojure.contrib.apply-macro/apply-macro is broken

18:47 java.lang.StackOverflowError for the example in the doc

18:48 ...not that I need to use it

19:26 hiredman: ping?

19:26 clojurebot: PONG!

19:57 bobbytek: what's the point of the do form if its not needed in function definitions?

19:58 mefesto: bobbytek: it can be handy for an if/else and you need to perform side effects in one or the other

19:59 bobbytek: just a grouping mechanism?

19:59 mefesto: yeah

21:27 bobbytek: Anyone here use scala?

21:32 seancorfield: bobbytek: yeah, i use scala

21:32 bobbytek: what sort of things do you use it for vs. clojure?

21:34 seancorfield: i'm using it for XML manipulation - i needed high performance statically typed stuff for that piece of my application

21:34 also i've only learned clojure recently and haven't had much opportunity to use it in a production app

21:35 bobbytek: cool

21:35 I'm just learning clojure

21:35 seancorfield: mostly i'm building web applications with cfml (running on railo, the jboss community project) and integrating java-based stuff where some other language makes my life easier

21:36 bobbytek: neat

21:36 I use groovy a lot for that type of thing

21:36 seancorfield: java is too verbose, i like groovy but it's dynamic and doesn't buy me much performance wise compared to cfml (on railo, at least)

21:36 hence my choice of scala

21:37 but i'll probably use clojure for some stuff i have coming up in the next year (lots of dynamic data structures and probably a DSL for processing them)

21:38 bobbytek: ya, definitely using groovy for performance is a step in the wrong direction

21:38 great for xml, db access, html, scripting, etc.

21:39 I'm interested in clojure right now, but I'm going to checkout scala later I'm sure

21:54 bmh: hey channel

22:12 I'm implementing my own random number generators (long story), and they all supply a method to output a pseudorandom bit. Is this a job for a multimethod? (I suppose that the haskell analog would be constructing a typeclass)

22:20 phobbs: hello

22:20 I am having a problem with nested maps

22:20 hash-maps, that is

22:21 if I try: (:a {:a {:b 'aoeu}})

22:21 I get: clojure/core$print_map$fn__4867

22:21 [Thrown class java.lang.NoClassDefFoundError]

22:21 and if I set a variable to be a hash-map and try to use it in a similar expression, I get the same result

22:21 hiredman: no you don't

22:21 phobbs: heh

22:22 bmh: Yeah, that code is cromulent.

22:22 phobbs: you're right

22:22 ok, then slime or swank is messing something up

22:22 that's what I get in emacs

22:22 it works on the command line

22:23 It gives me the same thing when I try to slime-compile-and-load-file

22:23 =/

22:24 hiredman: why are you so quick to blame slime?

22:24 phobbs: I have little imagination for what else it could be

22:24 what do you think it is?

22:25 hiredman: you're doing it wrong

22:25 phobbs: thanks

22:25 hiredman: well, given the choice between you doing it wrong, or slime doing it wrong, slime's not perfect but it sees a lot of use

22:26 phobbs: so if I copy and paste it into the repl, and it gives me that same error...

22:26 am I doing it wrong?

22:27 hiredman: dunno what you are copy and pasting

22:27 phobbs: what I just typed: (:a {:a {:b 'aoeu}})

22:27 hiredman: what did you type before that? is it a fresh slime?

22:28 phobbs: let me try it on a new one

22:28 I didn't realize it was possible to mess a repl up that much

22:29 hiredman: *shrug*

22:29 gigo

22:32 phobbs: thanks

22:32 that worked

22:32 =]

22:35 wwmorgan: phobbs: the NoClassDefFoundError is often indicative of something wrong with your environment, as opposed to the ClassNotFoundException which is often a typo or classpath problems

22:43 bobbytek: poo tastes bad

22:45 phobbs: wwmorgan: thanks for that tip

22:45 hiredman: I also was doubting my slime or swank setup

22:45 I've messed that up pretty badly before

22:45 I also have a lot of existing emacs customizations which used to conflict with my clojure setup

22:46 in fact, setting clojure up was so frustrating at first that I'm only now coming back to the language

22:46 for some reason it's much easier now =]

22:47 bobbytek: eclipse works fine for me :)

22:58 what's with the name clojure? Is it spanish or something?

22:58 kwertii: bobbytek: it's a pun on "closure"

22:59 a block of code that closes (captures) the lexical bindings of the context in which it was created

22:59 bobbytek: how is that a pun?

22:59 kwertii: the pronunciation is similar

22:59 perhaps conflated with "conjure"

22:59 bobbytek: that's a stretch as far as a play on words is concerned

22:59 kwertii: yeah, well...

22:59 bobbytek: it's about as witty as groovy

23:00 wwmorgan: the "j" is for "java"

23:00 bobbytek: ah

23:00 kwertii: wwmorgan: that makes sense

23:00 bobbytek: indeed it does

23:00 I like it better now :)

23:00 perhaps even better if it stood for jvm :)

23:02 is a keyword just and abstraction to a constant unique integer?

23:37 alpheus: a unique identity

Logging service provided by n01se.net