2010-08-17
| 00: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. |
| 00:02 | seangrove | Is that url your plugin? |
| 00:03 | dnolen | seangrove: yes |
| 00:03 | seangrove | Very cool |
| 00:03 | seangrove | Is there a way to start clojure in 32bit? |
| 00:04 | technomancy | seangrove: depends on the platform. try starting java with the -client flag |
| 00:04 | seangrove | I'm on snow leopard |
| 00:04 | technomancy | hmm; I think you have to compile your own Java for that unfortunately. =\ |
| 00:04 | seangrove | Seems that the jni is only supposed to run on 32bit :P |
| 00:04 | seangrove | Haha |
| 00:04 | seangrove | Goodness |
| 00:05 | dnolen | seangrove: that why I didn't bother with OpenCV, Xuggle is 64bit. |
| 00:05 | dnolen | seangrove: in yr Utilities directory there is the Java utility, launch and pick the 32bit one |
| 00:07 | seangrove | Looking for that... |
| 00:10 | dnolen | http://stackoverflow.com/questions/3363637/opencv-2-1-mac-os-x-webcam-issues-32-and-64-bit |
| 00:11 | seangrove | Got it I think |
| 00:12 | seangrove | Alright, imported :) |
| 00:12 | seangrove | Thanks guys! |
| 00:12 | seangrove | That was the biggest issue so far |
| 00:13 | seangrove | I'd like to get this working in lein in a bit, but this is the first big step |
| 00:43 | seangrove | Cool, got it all working, thanks! |
| 00:48 | bmh | good evening, channel |
| 00:50 | technomancy | release candidate for Leiningen 1.3.0: http://github.com/technomancy/leiningen/blob/master/NEWS |
| 00: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? |
| 01:27 | slyrus | ,(flatten {3 4 5 6}) |
| 01:27 | clojurebot | () |
| 01:30 | tomoj | ,{{}} |
| 01:30 | clojurebot | java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1 |
| 01:30 | tomoj | ,(identity {{}}) |
| 01:30 | clojurebot | 1 |
| 01:30 | tomoj | wat |
| 01:30 | tomoj | I get {} |
| 01:30 | tomoj | $(identity {{}}) |
| 01: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. |
| 01:30 | tomoj | ->(identity {{}}) |
| 01:30 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 1 |
| 01:30 | tomoj | hmm |
| 01:31 | tomoj | ,(read-string "(identity {{}})") |
| 01:31 | clojurebot | 1 |
| 01:31 | tomoj | ,(read-string "(identity {})") |
| 01:31 | clojurebot | (identity {}) |
| 01:31 | tomoj | what the heck? |
| 01:33 | tomoj | -> (sequential? (first {3 4 5 6})) |
| 01:33 | sexpbot | => true |
| 01:33 | tomoj | slyrus: ^ |
| 01:33 | slyrus | hmm... |
| 01:34 | tomoj | err |
| 01:34 | tomoj | -> (sequential? {3 4 5 6}) |
| 01:34 | sexpbot | => false |
| 02:16 | alpheus | How do I make an InputStream from a string? |
| 02:19 | cgrand | alpheus: (-> "hello world" (.getBytes "UTF-8") java.io.ByteArrayInputStream.) |
| 02:20 | alpheus | thanks! |
| 02:21 | raek | alpheus: you can also create a Reader (the Character counterpart for InputStream, which reads Bytes) with: |
| 02:21 | raek | (java.io.StringReader. "HelloWorld") |
| 02:23 | alpheus | Would either one be a suitable argument to net.cgrand.enlive-html/html-resource ? |
| 02: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) |
| 02:27 | raek | I did a quick glance through the code, and it looks like both should work |
| 02:28 | raek | I'm inclined to recommend the Reader approach, since it does not do the extra encode to byte and decode into character step |
| 02:29 | raek | but maybe cgrand himself can answer the question more accurately... |
| 02:33 | cgrand | alpheus: yeah, use a Reader, but you can also trade your html-resource for a html-snippet. (html-snippet "<html>....</html>") |
| 02:38 | adityo | good morning |
| 02:40 | adityo | how can i flatten a map i.e {a 1, b 2, c {"foo" "bar"}} into {a 1, b 2, "foo" "bar"} |
| 02:41 | adityo | contrib's flatten might not work on this |
| 02: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]]))))) |
| 02:48 | clojurebot | {:a 1, :b 2, "foo" "bar"} |
| 02:49 | raek | ,(let [m {:a 1, :b 2, :c {"foo" "bar"}}] (apply merge (for [[k v] m] (if (map? v) v {k v})))) |
| 02:49 | clojurebot | {"foo" "bar", :b 2, :a 1} |
| 02:50 | adityo | thanks raek, ;) |
| 03:50 | LauJensen | technomancy: You're the man! |
| 03:50 | LauJensen | Good morning all :) |
| 07:19 | raek | haven't seen this approach for exceptions before: http://github.com/richard-lyman/amotoen/blob/master/src/com/lithinos/amotoen/errors.clj |
| 07:19 | raek | it avoids the subclassing issue in a pretty interesting way |
| 07: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? |
| 07:46 | Raynes | ->(apply + 1 2 3 4 [5 6 7 8 9]) ; I don't think you can do stuff like this with reduce. |
| 07:46 | sexpbot | => 45 |
| 07:47 | Raynes | Plus, what they do is completely different. |
| 07:48 | fogus_ | ,(apply hash-map [2 3 4 5]) |
| 07:48 | clojurebot | {2 3, 4 5} |
| 07:48 | fogus_ | ,(reduce hash-map [2 3 4 5]) |
| 07:48 | clojurebot | {{{2 3} 4} 5} |
| 07:48 | Raynes | Apply simply applies the function to the sequence of arguments as if they were individual arguments. It "unrolls" a sequence. |
| 07:49 | Raynes | 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. |
| 07:49 | Raynes | They only appear to do same thing in certain situations, such as with the arithmetic functions. |
| 07:49 | raek | for variadic functions like +, they happen to have the same result |
| 07:52 | hanDerPeder | ahh, ok |
| 07:52 | hanDerPeder | thanks! |
| 07:52 | fogus_ | raek: hash-map is variadic |
| 07:53 | Raynes | raek: Just be quiet and bask in the glory of my explanation. ;P |
| 07:54 | hanDerPeder | so when using the max or an arithmetic function, is one considered better style than the other? |
| 07:55 | hanDerPeder | ie, (apply max '(1 2 3)) vs (reduce max '(1 2 3)) |
| 07: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. |
| 07:57 | fogus_ | raek: Maybe you mean "associative" :-) |
| 07:57 | Raynes | hanDerPeder: I'd use the former, because it makes more sense in my head. |
| 07:58 | hanDerPeder | Raynes: seems like a fair heuristic, thanks! |
| 07:59 | Raynes | rhickey: Morning. |
| 08:00 | rhickey | hi |
| 08:01 | metagov | This morning I was surprised this expression worked at all: (def a [a]) |
| 08:02 | metagov | It appears to be an array whose first element is an earlier version of the array. |
| 08:02 | metagov | (ie an empty arrary) |
| 08:03 | fogus_ | metagov: Why is that surprising? |
| 08:04 | metagov | fogus_: I thought the reader would complain |
| 08:04 | fogus_ | It will complain if a had not been previously defined, but otherwise no problem |
| 08:06 | metagov | But I thought the symbol 'a', while created, wouldn't have been bound until after the overall (def ...) expression finished. |
| 08:07 | fogus_ | `a` must have been bound previously no? |
| 08:08 | metagov | oh! right! I forgot I'm in a repl. |
| 08:08 | fogus_ | :) |
| 08:09 | Raynes | Dun dun dun. |
| 08:09 | metagov | I keep thinking I can't rebind symbols like they're read only or something. |
| 08:11 | metagov | So, quitting the repl and trying it anew, I get the error I was expecting. Thanks :-) |
| 08: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 |
| 08:14 | Raynes | fogus_: Is scream and run in circles an option? |
| 08:15 | fogus_ | That's contained in #4 :p |
| 08:19 | fogus_ | Reading: http://stephen.wolfram.usesthis.com/ |
| 08:20 | hoeck | fogus_: are there any other exceptions a unification can throw? If not, I would use a plain Exception. |
| 08:21 | fogus_ | hoeck: Yes. It can also throw on a cycle. I'm currently going the ::cycle/::clash route, but am not completely satisfied |
| 08:24 | hoeck | fogus_: is this lib available somewhere? |
| 08:24 | fogus_ | hoeck: not yet |
| 08:33 | LauJensen | fogus_: the clashexception sounds good to me |
| 08:34 | nickik | can somebody help me with some namespace problems? |
| 08:34 | nickik | I have a namespace (main.players) with some records in it. Called nice and asshole (they are bots for a game). |
| 08:34 | nickik | In the main.core I include it. (ns main.core (:use [main.players])) |
| 08:35 | nickik | So far so goot but know I want to test it. |
| 08:35 | fogus_ | LauJensen: I would like to avoid AOT if at all possible, but will if that makes the most sense. |
| 08:35 | nickik | This is in the testfile: |
| 08:36 | LauJensen | Ok |
| 08:36 | nickik | (ns titfortat.test.core (:use [titfortat.core] :reload-all) (:use [clojure.test]) (:import [titfortat.players nice]) (:import [titfortat.players asshole])) |
| 08:36 | fogus_ | Another option of course is to throw Exception on one and Error on the other |
| 08:36 | nickik | but in the testfile i cant get a new player like this (nice. []) |
| 08: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 |
| 08:38 | fogus_ | LauJensen: I think I agree |
| 08:41 | hoeck | nickik: and whats the exception? |
| 08:43 | nickik | @hoeck No matching ctor found for class titfortat.players.nice |
| 08:43 | hoeck | nickik: that means the (nice. []) call is wrong |
| 08:44 | hoeck | has the wrong number of arguments |
| 08:44 | hoeck | for each field there must be an argument in the ctor-call |
| 08:44 | hoeck | (defrecord nice [a b c]) -> (nice. 1 2 3) |
| 08:45 | LauJensen | fogus_: Jich Bickey ? |
| 08:45 | hoeck | if the class has not been imported, it would have been a "unable to resolve classname: nice" Exception |
| 08:46 | fogus_ | Josh Bloch ;-) |
| 08:47 | LauJensen | :) |
| 08:47 | LauJensen | I knew it was a long shot going in :) |
| 08: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. |
| 08:54 | LauJensen | fogus_: Out of curiosity, what would he do in this case? |
| 08: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. |
| 08:59 | LauJensen | Ok, makes sense |
| 09: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)... |
| 09: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? |
| 09: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 |
| 09:54 | nickik | should I write unit-test for macros? |
| 09:56 | esj | you should test everything :) |
| 09: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 | jfields | (deftest add-values |
| 10:11 | jfields | (is (= |
| 10:11 | jfields | {:a {:b 4 :c 7}} |
| 10:11 | jfields | (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 | pdk | hiredman right |
| 10:21 | pdk | (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 | Chousuke | 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 | Luyt | 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 | arohner | 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 | apgwoz | 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 | nickik | *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 | apgwoz | ahh |
| 11:01 | apgwoz | zip-filter.xml |
| 11:01 | apgwoz | cool |
| 11:01 | apgwoz | 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 | cemerick | 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 | edbond | 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 | nickik | is there something like that in a lib |
| 12:09 | qbg | (< (rand-int 100) n) |
| 12:11 | qbg | ,(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 | technomancy | before android, anyway |
| 12:14 | cemerick | absolutely agreed |
| 12:15 | cemerick | 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 | technomancy | 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:22 | arkh | Viva La Revolución |
| 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 | arkh | ... 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 | cemerick | 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 | cemerick | technomancy: can I surmise then that you'd prefer a purely FOSS world where support is your primary stream of income? |
| 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 | cemerick | 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 | Joreji | 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 | no_mind | 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 | metagov | 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 | no_mind | two files is okay with me |
| 12:50 | metagov | no_mind: I don't know about select box options specifically. |
| 12:51 | metagov | 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 | cgrand | 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 | nickik | 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 | raek | 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 | raek | 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 | raek | I thought you were asking about how to get away the dot from the constructor... :) |
| 13:48 | raek | sorry |
| 13:49 | raek | 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 | pdk | at first glance i assumed lazy-cons would have been shorthand for (lazy-seq (cons ... |
| 13:57 | pdk | (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 | raek | 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 | pdk | which would be e.g. cons |
| 14:00 | raek | exactly |
| 14:01 | raek | (defn my-repeat [n x] (cons x (my-repeat (dec n) x))) |
| 14:01 | raek | eager version, don't do this ^^ |
| 14:02 | raek | oh sorry, I'm really tired today, forgot the condition... |
| 14:02 | pdk | its the fun way |
| 14:02 | pdk | since it's eager it gets me excited to run this function |
| 14:03 | raek | http://gist.github.com/531174 |
| 14:03 | raek | there |
| 14:04 | raek | you should always be able to get an eager version if you simply remove the surrounding lazy-seq |
| 14:05 | raek | lazy-seq simply returns something that evals and returns the body when you call seq on it |
| 14:05 | raek | subsequent seq calls will be caches |
| 14:06 | raek | this is also thread safe, of course |
| 14:07 | raek | 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 | jfields | (user defined namespaces) |
| 15:35 | technomancy | jfields: there's not really anything special about user-defined namespaces; they're all first-class |
| 15:35 | technomancy | except clojure.core; that's zeroth-class |
| 15:35 | technomancy | 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 | raek | 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 | AlmostObsolete | 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 | raek | I use leiningen for my projects |
| 15:58 | raek | cljr can be neat if you don't want to create a project everytime you want to do something in clojure |
| 15:59 | raek | 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 | raek | (after having ran lein deps) |
| 15:59 | raek | http://github.com/technomancy/leiningen <-- leiningen docs |
| 16:00 | raek | last time i installed slime, I did it through ELPA |
| 16:01 | raek | (slime, slime-repl and clojure-mode are the packets you'd want) |
| 16:01 | raek | AlmostObsolete: that guide compiles clojure from source, wich is rarely necessary |
| 16:02 | AlmostObsolete | thanks |
| 16:02 | AlmostObsolete | 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 | raek | 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 | technomancy | 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" =) |
| 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 | caljunior | 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 | holoway | clearly a lame question, but i'm trying to call a function for every item in a vector |
| 17:25 | holoway | and it looks like for is the answer, but I'm clearly getting something wrong |
| 17:26 | chouser | map should do too |
| 17:26 | chouser | ,(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 | ecyrb | thanks guys. I don't know why I couldn't see that. |
| 17:51 | ecyrb | though, hash-map is a confusing name. |
| 17:52 | ecyrb | 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 | raek | ,(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 | raek | 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 | arkh | :) |
| 18:01 | arkh | 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 | raek | vectors: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/ |
| 18:13 | raek | oh sorry |
| 18:13 | raek | that *is* Karl Krukow's blog |
| 18:14 | raek | didn't see his name at first |
| 18:14 | raek | 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 | raek | java.lang.StackOverflowError for the example in the doc |
| 18:48 | raek | ...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 | seancorfield | 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 | bobbytek | 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 | bobbytek | 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 | seancorfield | hence my choice of scala |
| 21:37 | seancorfield | 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 | bobbytek | great for xml, db access, html, scripting, etc. |
| 21:39 | bobbytek | 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 | bmh | 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 | phobbs | I am having a problem with nested maps |
| 22:20 | phobbs | hash-maps, that is |
| 22:21 | phobbs | if I try: (:a {:a {:b 'aoeu}}) |
| 22:21 | phobbs | I get: clojure/core$print_map$fn__4867 |
| 22:21 | phobbs | [Thrown class java.lang.NoClassDefFoundError] |
| 22:21 | phobbs | 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 | phobbs | ok, then slime or swank is messing something up |
| 22:22 | phobbs | that's what I get in emacs |
| 22:22 | phobbs | it works on the command line |
| 22:23 | phobbs | It gives me the same thing when I try to slime-compile-and-load-file |
| 22:23 | phobbs | =/ |
| 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 | phobbs | 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 | phobbs | 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 | phobbs | I didn't realize it was possible to mess a repl up that much |
| 22:29 | hiredman | *shrug* |
| 22:29 | hiredman | gigo |
| 22:32 | phobbs | thanks |
| 22:32 | phobbs | that worked |
| 22:32 | phobbs | =] |
| 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 | phobbs | hiredman: I also was doubting my slime or swank setup |
| 22:45 | phobbs | I've messed that up pretty badly before |
| 22:45 | phobbs | I also have a lot of existing emacs customizations which used to conflict with my clojure setup |
| 22:46 | phobbs | in fact, setting clojure up was so frustrating at first that I'm only now coming back to the language |
| 22:46 | phobbs | for some reason it's much easier now =] |
| 22:47 | bobbytek | eclipse works fine for me :) |
| 22:58 | bobbytek | what's with the name clojure? Is it spanish or something? |
| 22:58 | kwertii | bobbytek: it's a pun on "closure" |
| 22:59 | kwertii | 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 | kwertii | 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 | bobbytek | I like it better now :) |
| 23:00 | bobbytek | perhaps even better if it stood for jvm :) |
| 23:02 | bobbytek | is a keyword just and abstraction to a constant unique integer? |
| 23:37 | alpheus | a unique identity |