#clojure log - Jun 24 2010

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

0:16 alexyk: what's the status of 1.2?

0:17 technomancy: alexyk: probably not right around the corner given that the prim stuff is targeted for it.

0:17 alexyk: prime?

0:17 clojurebot: primetime is <lowlycoder> i'm not convined clojure is ready for primetime until i see facebook apps in clojure

0:18 technomancy: alexyk: improved primitive support

0:18 alexyk: ahh

0:18 that would kick haskell's ass

0:19 technomancy: what about contrib compatibility with 1.1? was it solved?

0:19 technomancy: alexyk: I think it's pretty much solved. it's much, much better than it was right after the contrib changes first landed.

0:21 Raynes: I noticed that a couple of days ago. All library writers: stop targeting specific versions unless the specific version is 1.2 and uses 1.2-only features. Don't think I wont hunt you down and kill you.

0:21 :D

0:24 technomancy: I wonder if Clojure is going to keep a reputation of "it's not as mature for web work as ruby" just because its web frameworks are so simple, and thus people don't have a lot of incentive to create a million different web-centric libraries, etc.

0:25 Blackfoot: Where did you see that?

0:27 technomancy: Blackfoot: it's just that you can get a lot done with simple request/response functions plus middleware implemented as function composition. there's not a lot of room for superfluous "oh, I'm going to implement actions as methods on classes vs a DSL", etc.

0:27 in Clojure, the right answer to "How should I represent X?" is almost always "as a function."

0:28 Blackfoot: oh, I can see that. and I like the simple sinatra model. I'm more curious where you heard the sentiment that it is not as mature

0:28 alexyk: what about node.js? it scared rubyfolk into fits of optimization of their whole stack

0:29 http://nodejs.org/

0:29 technomancy: well right now it's obviously not as mature since Rails has been around since 2005-ish and I don't think anyone's had anything deployed with Compojure for much over a year.

0:29 alexyk: looks like clojure in disguise to me

0:29 since javascript is

0:30 duck1123: clojure on the web is not as mature. (not the same as not as capable)

0:30 Blackfoot: nodejs is also a cool model. They almost did the same thing for IO as clojure did for state management

0:30 technomancy: yeah, I'm not making a judgement call--just saying that's how it's perceived.

0:31 alexyk: they monitor directories apparently and see if they change using OS. I wonder how JVM jives with that.

0:31 cemerick: I'm not sure there's much of a comparison to be made -- so much of the rails world's attention has always been on deployment and ops issues that the jvm web stuffs have had down pat for 10 years.

0:31 alexyk: cemerick: but, nothing as good-sounding as Capistrano! :)

0:31 makes you want to travel

0:32 technomancy: alexyk: not so sure about that... nothing beats Vlad the Deployer.

0:32 * alexyk knows not much about it but likes the sound of it

0:32 cemerick: mm, they're certainly good at marketing :-)

0:32 lancepantz: technomancy: i was just about to say the same

0:32 alexyk: DHH went to business school and it shows

0:33 he gave an excellent talk at AMZN about it around the hight of the hype

0:33 of course nothing in AMZN can be run on it

0:33 ...as it runs on perl! :)

0:35 so why is clojure so fast? it's right there with haskell and ocaml in speed. something smells fishy!

0:35 * cemerick points at the JVM

0:36 cemerick: ...and the stellar data structures

0:36 * alexyk notices that big hulky robot in the dark corner

2:34 alexyk: how do I translate this into Clojure: Map<String,Object> userData = mapper.readValue(new File("user.json"), Map.class);

2:34 (from http://wiki.fasterxml.com/JacksonInFiveMinutes)

2:36 lancepantz: is mapper part of the jackson api?

2:42 alexyk: lancepantz: it's described by the jackson's author :)

2:43 and has always been; I think about this: let's use it to slurp a Java map very quickly out of json, then convert that to clojure

2:43 's map

2:43 better yet, teach it to extract the clojure's map directly, if possible

3:16 scottj: alexyk: I might be missing something here..what about that code is hard to translate to java?

3:18 alexyk: scottj: me too -- it's late and is not obvious to me now :)

3:19 scottj: does this work? (.readValue mapper (File. "user.json") Map)

3:20 alexyk: scottj: it assumes you give types to Map, from which Jackson extracts the schema... is Map a stand-in for Map.class?

3:22 scottj: alexyk: not sure, (class String) says java.lang.Class so I figured Map in clojure was same as Map.class in java

3:26 alexyk: what's the language mechanism that lets the thing being assigned look at the type it's being assigned to?

3:26 alexyk: scottj: reflection?

3:29 TheBusby: What's the best way to determine the most frequently occuring element in a list?

3:29 ,(first (reverse (sort-by val (frequencies [1 2 2 3 3 3 9]))))

3:29 clojurebot: [3 3]

3:29 TheBusby: that works, but because you need to use "reverse" it has to run back across the entire list...

3:30 scottj: alexyk: hmm, I didn't know reflection could do that.

3:30 alexyk: scottj: I'm not sure what you mean then. Jackson has ways to match but you have to pass the type in, per link.

3:35 hiredman: ,(first (sort-by (comp - val) (frequencies [1 2 2 3 3 3 9])))

3:35 clojurebot: [3 3]

3:36 serp_: ,#{1 1}

3:36 clojurebot: Duplicate key: 1

3:36 serp_: how so?

3:36 I would expect => #{1}

3:37 hiredman: #{1 1} is considered a bug, since sets can't have duplicate keys, so most likely the programmer made a mistake

3:39 serp_: I guess practically that makes sense

3:40 scottj: there are some other weird behavior with hash/set literals that don't apply to the non-literal versions and also have that answer: don't do it

3:41 TheBusby: hiredman: thank you!

3:42 hiredman: work has been done to try and address the oddness with literals, the exception you get from that set is a result of some of that work

3:43 serp_: it would not be odd if the set just dropped duplicate members... that's what should be expected

3:47 Blackfoot: http://groups.google.com/group/clojure/browse_thread/thread/9c394897f6c0498e/d06f21c0eb49016b?lnk=gst&q=hash+literal+oddity#d06f21c0eb49016b

3:47 serp_: ,(clojure.set/union #{1} #{1})

3:47 clojurebot: #{1}

3:47 serp_: ^ here duplicates are silently dropped

3:48 Blackfoot: it's probably a similar issue

3:49 hiredman: the argument is a #{1 1} literal set is plainly a bug/typo since sets cannot claim duplicates, so why would you do that unless it was a mistake?

3:50 serp_: that's almost like saying that typos in string literals should be forbidden. why make typos if it's not a mistake?

3:52 sets come from mathematics, where the usual convention is that duplicates make no difference

3:52 hiredman: serp_: that argument is ridiculous

3:52 serp_: it's a bit extreme, but I think it illustrates my point

3:52 hiredman: no

3:53 scottj: Blackfoot: I was thinking of hickey's response in the thread linked at the bottom of the one you pasted, about it being inefficient to check literals for duplicates. but isn't that happening here?

3:53 hiredman: it's not extreme, it's completely wrong headed

3:55 Chousuke: scottj: why would you accept silly input when you can just throw an error and get the programmer to check it out?

3:55 Blackfoot: scottj: i'm not sure of the details, but you might be right

3:55 Chousuke: scottj: I mean, in 100% of the cases the programmer didn't intend to type two equivalent items :P

3:56 Blackfoot: it may not spend the time condensing the keys, it just puts it into the data structure which throws the error

3:57 i think the logic is: if you specify a literal set, a valid set does not have duplicate keys

3:57 just like if you specify a literal string with an non-existant escape sequence

3:58 serp_: hiredman: I think the language itself shouldn't forbid something that is not necessarily wrong. you could use a lint tool for that

3:58 Chousuke: but it is wrong

3:58 gregh: sounds like a compile warning might be appropriate

3:58 hiredman: ,(let [x′ 1] #{x′ 1})

3:58 clojurebot: java.lang.IllegalArgumentException: Duplicate key: 1

3:58 hiredman: serp_: I care less and less what you think

3:59 Chousuke: a literal set with two equivalent items makes no sense at all.

3:59 you can write some math that has one, but people will think you're weird :P

4:00 (or they will be puzzled and think maybe you meant something else)

4:00 scottj: Chousuke: I'm not saying you shouldn't check literals, just that rhickey said once he didn't want to check them because it would slow things down so I'm wondering if that check is happening at a different level here

4:00 Chousuke: it only slows down the compiler as far as I know.

4:01 and not by any noticeable amount.

4:01 scottj: btw, what other languages have literal syntax for sets?

4:01 gregh: pascal :)

4:01 Chousuke: you can still conj duplicates to sets, remember

4:02 ,(conj 1 #{1}); I hope I got the arg order right :P

4:02 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection

4:02 Chousuke: damn

4:02 I always get that wrong.

4:02 ,(conj #{1} 1)

4:02 clojurebot: #{1}

4:02 hiredman: Chousuke: :( how do you get that wrong

4:02 it's conj man

4:02 Chousuke: hiredman: I dunno, somehow.

4:03 hiredman: I keep thinking of cons :P

4:04 hiredman: cons works on seqs and has the same argment order as if you where constructing the seq from just cons calls (cons 1 (cons 2 nil)) and conj works on everything and has the opposite order

4:05 Chousuke: yeah, I know, but it still manages to confuse me :P

4:05 scottj: one way to think about it is conj has the order it would if it were a method. an add method would be on the collection, not the item

4:12 AWizzArd: Is there a way to get a specific function object of a class which extends a Protocoll? Let's say we have the fn 'foo' and extend String and FileInputStream with it. Now is there a way to get the one foo for Strings?

4:13 (get-protocoll-fn 'foo String) ==> callable fn

4:18 Licenser: $(doc cons)

4:18 sexpbot: => ------------------------- clojure.core/cons ([x seq]) Returns a new seq where x is the first element and seq is the rest. nil

4:20 Chousuke: AWizzArd: there probably is, but I doubt it's a public API

4:21 AWizzArd: you might want to check out the implementation of extend etc.

7:39 LauJensen: Hi guys - Contrib has been broken for 8 days, whats going on ? The console output looks a little funny

7:55 Licenser: out of curiosity, on the euqal branch, how is the state of compairoson operators, are they working on primitives too? aka being faste when i compare 2 longs?

8:07 kib2: Hi

8:09 Licenser: hi kib2

8:10 kib2: Licenser: are you the one how wrote a syntax highlighter ? (sorry, I went here once only).

8:10 Licenser: Yap, I am the one :)

8:11 kib2: Licenser: cool :) Can you give mine a try ? It's a very little script (the first one I've made with Clojure)

8:12 Licenser: sure I'll gladly look over it

8:12 kib2: http://kib2.free.fr/Clojure/prism_v.01.zip

8:12 Thanks, just unzip, and launch 'prism.clj'

8:12 the result will be 'prism.html'

8:14 Licenser: first hint def is for global variables if you need local ones use let

8:15 kib2: Licenser: witch one ?

8:15 Licenser: prism clj line 88

8:16 kib2: Licenser: oh yes, I forgot this one; thanks

8:16 Licenser: :)

8:16 it looks very procedural ^^

8:17 kib2: it's certainly not idiomatic Clojure code

8:17 indeed :)

8:17 I only used recur once...shame on me !

8:17 Licenser: :P

8:18 but you use a definition very close to what I use, you might want to have a look at clj-highlight for some ides how to do things less procedural

8:18 kib2: yes, I saw you were using the same sort of rules.

8:20 but there's a problem : suppose you want to highlight "defn" keyword, then ie "my-defn" will also be highlighted

8:20 Licenser: also use [] instead of '()

8:20 kib2: ie a vector ?

8:20 Licenser: no since I use a set for keywrds not a regexp

8:20 yap

8:20 kib2: you don't use regexps at all ?

8:21 or a mix of the two ?

8:21 Licenser: well I take a multi step aproach

8:22 kib2: good...can you tell me more about it ?

8:22 Licenser: regexps to tokenize and then something I call 'manglers' that go over the tokens and alter them in some way i.e. by making some idents to keywords depending weather they are part of a keyword list or not

8:22 this allows you to do funky stuff with your highlighter by applying multiple mangers and things like that

8:23 kib2: cool :)

8:23 Licenser: you can toss all kinds of things on them and it does not get much slower thanks to everything being a lazy seq

8:23 also I don#t use regexp directly but matcher functions

8:24 that way you can also match against other things, for example for clojure nubmers (since they can be quite complex) I use a sepcial function that generates the regexp on the fly if they are needed

8:24 kib2: I'm using matchers too because I needed start and ends pos of the tokens

8:25 Licenser: yea I found javas regexp library horrible :(

8:26 AWizzArd: Why that?

8:26 Licenser: because it is very hard to tokenzie with it AWizzArd it has no good suport for that

8:26 at least none I found

8:26 AWizzArd: I mean, it would be nice of course if there were a Clojure fn to report that kind of data.

8:26 But the java API offers that kind of information.

8:26 Licenser: AWizzArd: but you can only search for 'the next match' not 'what of this matches first'

8:27 kib2: A nice PEG library should be nicer

8:27 but I don't know if there's already one for Clojure

8:27 Licenser: so you can't use the fast regexp functions since if you go with an index you can't use ^ since ^ matches not the start from the index but the start of the string. and if you don't have ^ it matches any match with the string not only if ti starts

8:28 there is no function to say 'does the string at position X matches regexp R'

8:28 and the fast libraries don't have support for certain cases like the one I'd love ot use since it is claimed to be the fastes does not support ^ at all :(

8:30 kib2: If I was clever enough; i would write REBOL's "parse" function...but I'm not.

8:31 Licenser: kib2: I wrote a pretty fast function for it but it's not perfect

8:31 it abuses the fact that java treats substrings w/o copying

8:32 kib2: Licenser: where is it ?

8:33 Licenser: in clj-highlight

8:33 it rests at github feel free to take a look, fork or do wahtever you feel like :)

8:33 kib2: thanks, nicce to you

8:39 Licenser: also if you've a question or an idea for it jet give me a ping about it

8:44 kib2: no problem, I just have to study what you've done ;, it will certainly take me some time to understand how things work internally.

8:44 Licenser: no worries

9:14 kib2: I have to go; see you guys.

9:16 Licenser: someone around who likes optimisation?

9:27 hmm getting closer :P

10:37 So I have tried to write a really really fast benchmark for clojure, but I fail, http://github.com/Licenser/clj-shootout/blob/master/fannkuchen/src/profile/fannkuchen.clj is what I got and I don#t see much more way to optimize sadly :(

10:39 http://grab.by/57el is what the profiler says eevar2 yes I sayed profiler

10:43 eevar2: awesome

10:46 cemerick: danlucraft1: ping

10:46 danlucraft: cemerick: hey

10:46 cemerick: thanks for the moz info -- I'm waiting for my vm to boot so I can try it in windows. But: where do you actually use the moz view?

10:47 danlucraft: cemerick: inside any Swt layout

10:47 ?

10:48 cemerick: is that what you meant?

10:48 cemerick: danlucraft: oh, all the editors are web views?

10:48 danlucraft: cemerick: oh, you mean in Redcar?

10:48 cemerick: yeah

10:48 danlucraft: right

10:48 in that case, there are a few places its used

10:48 I'm trying to use the web view instead of dialogs

10:49 * cemerick was looking for the web preview option :-)

10:49 danlucraft: cemerick: heh, not written that yet

10:49 try Plugins/Plugin Manager

10:49 or open a directory, select multiple files and right click and choose "Bulk Rename"

10:50 cemerick: danlucraft: I get errors for both of those: NameError: uninitialized constant Redcar::ApplicationSWT::HtmlTab::LocationListener::URI

10:51 danlucraft: hmm

10:51 that's weird. have you installed from the gem?

10:51 cemerick: yup

10:52 OS X 10.5.8-ish, ruby 1.8.6

10:52 oh, it's jruby, nevermind :-)

11:00 Licenser: rhickey: you're around and have a minute?

11:31 AWizzArd: What is the difference between a definline and a macro?

11:31 Are not both expanded during macroexpansion time?

11:33 chouser: they are expanded at roughly the same time, but things defined by definline can be used as a function

11:34 hoeck: AWizzArd: definline is experimental, defmacro not :P

11:37 chouser: oh. wow.

11:38 I refuse to think about how long it took me to find that typo in my map keywords

11:40 arohner: is anyone using sonatype nexus to proxy clojars?

11:40 it's correctly proxying some jars, but not others and I can't figure out why

11:42 cemerick: arohner: yes

11:42 which jars isn't it picking up?

11:43 arohner: ring-core, ring-devel, ring-jetty-adapter, org.clojars.arohner/hiccup, sandbar

11:43 cemerick: have you tried reindexing from scratch?

11:43 arohner: no

11:44 cemerick: is that right click and select ReIndex?

11:44 cemerick: arohner: yeah, and expire cache too, just for kicks

11:46 arohner: cemerick: still no luck. I have clojars set up as a proxy, snapshot repository, with a url http://clojars.org/repo/

11:47 cemerick: arohner: it can't be done that quick -- dropping indexes takes a bit, look at the scheduled tasks panel

11:49 arohner: cemerick: I did another expire and reindex, and there are no scheduled tasks listed

11:49 hrm...

11:49 cemerick: arohner: which versions of those artifacts are you trying to use?

11:49 if you're trying to use release versions, nexus won't expose those through a snapshot proxy repo

11:50 arohner: cemerick: so do I add clojars twice at the same url?

11:50 cemerick: (clojars hosting snapshots and releases out of the same repo is fairly broken)

11:50 arohner: yes, one snapshot proxy repo, one release proxy repo

11:50 arohner: and you can set up a group to merge the two for internal use if you want

11:51 we have one group repo that merges ~20 upstream repos that we proxy

11:51 makes pom configuration very pleasant :-)

11:51 arohner: cemerick: what is the difference between snapshot and release? I've heard there's a difference, but can't find any detail on what it means

11:53 cemerick: arohner: Google is your friend ;-)

11:53 http://docs.codehaus.org/display/MAVENUSER/Maven+Concepts+Repositories

11:53 http://mojo.codehaus.org/versions-maven-plugin/version-rules.html

11:54 chouser: I love (def ^:private foo ...)

11:54 AWizzArd: I always do (d/defvar- foo ... "docstring), where d is clojure.contrib.def :as d

11:55 arohner: cemerick: that first article I'd seen, and it just says release repos hold releases, and snapshot repos hold snapshots. I'm wondering why there's a technical restriction for something that seems like it should be policy / convention

11:56 cemerick: adding a second clojars repo worked, thank you

11:56 cemerick: bah, I didn't meant to paste that second link -- informative, but irrelevant here

11:56 * cemerick gets back to the page he wanted

11:58 cemerick: arohner: I don't know the implementation details, but the point of snapshots is that they're meant to reflect a state of flux, and that the associated artifacts are transient -- i.e. it's typical for snapshot repos to get flushed periodically.

11:58 If everyone had their own policy/convention around handling artifacts from builds of HEAD, then we'd be in some degree of trouble.

12:00 stuff like this is why e.g. using shas as version numbers and intermixing snapshot and release versions is unfortunate

12:01 hiredman: ,(doc alter-var-root)

12:01 clojurebot: DENIED

12:01 hiredman: clojurebot: you suck

12:01 clojurebot: No entiendo

12:01 cemerick: arohner: http://www.maestrodev.com/node/133

12:02 The 'better builds with maven' book is excellent, BTW.

12:02 arohner: cemerick: I'll look into that, thanks

12:23 ivenkys_: the clojurebot is so polite .. :-)

12:32 Lajla: ivenkys, I wish to consume your vital life essence.

13:25 triyo: RWH introduces Applicative parsing examples. Does newer parsec versions have built-in support for applicative parsing or do I have to use the ApplicativeParsec.hs from RWH?

13:25 ahh crap wrong channel :)

13:25 mmarczyk: triyo: you might want to ask on #haskell ;-)

13:25 :-)

13:25 I'd look into attoparsec though

13:26 and similar new Parsec-like packages

13:26 triyo: mmarczyk: thanks

13:26 mmarczyk: np

13:47 Blackfoot: has anyone use clj-native with compiled classes?

13:48 edbond: is it possible to run swank using ~/clojure-contrib/launchers/bash/clj-env-dir ?

13:48 Blackfoot: i'm getting an error "No matching method found: defineClass for class sun.misc.Launcher$AppClassLoader" when compiled, but none when I just use it in pure clojure

13:50 edbond: paredit question: how to remove ) ? I know comment trick but there should be right way to do this.

13:51 arohner: edbond: I just highlight the ) and kill it

13:53 edbond: arohner: no, paredit doesn't remove parentesis

13:54 I can comment it and remove, this is the only way.

13:54 arohner: what keys do you use?

13:54 Raynes: C-u backspace

13:54 arohner: edbond: I highlight the paren and M-w

13:55 Raynes: You don't even have to do the highlight stuff.

13:55 Just put the cursor in front of the paren you want to remove, and C-u backspace

13:55 edbond: Raynes: thanks!

13:55 Raynes: But highlighting works too.

13:56 For me, anyway.

13:57 edbond: arohner: thanks, this works too. but I had to press Ctrl-w

14:01 candera: I've knocked out a quick definition of something that computes the Cartesian cross product of multiple sequences. But as always when I write Clojure, I have to assume someone else can do it in less code. Anyone care to take a look? http://gist.github.com/451734

14:06 AWizzArd: candera: did you look at clojure.contrib.combinatorics?

14:07 candera: Obviously not. :)

14:07 AWizzArd: k

14:07 candera: But say I wanted to do it without contrib.

14:07 (I'll look at c.c.combinatorics now.)

14:09 mcav: i'm new to clojure too; is there a reason to use apply instead of recur in that context?

14:09 chouser: candera: yours looks pretty tight!

14:11 apply would unpack its last arg (more) into the next call's b & more

14:11 candera: chouser: thanks. The one in c.c.combinatorics is far more verbose. Not sure I understand why. Might be they're dealing with some corner case I'm ignoring (empty seqs, perhaps?)

14:11 mcav: ah, i see

14:15 chouser: except ... I thought recur with varargs wanted the vararg passed as a seq

14:16 ah, it does. so recur would in fact be better there -- faster, and no thread to the heap.

14:16 (defn cartes4 [a b & more] (let [so-far (for [x a y b] [x y])] (if more (recur so-far (first more) (next more)) (map flatten so-far))))

14:19 candera: chouser: Any comments on this, then? http://gist.github.com/451734 (I just added destructuring)

14:20 chouser: candera: that's what I just wrote!

14:21 candera: chouser: I just destructured more a little bit. Sorry if I was unclear - was asking if by doing so I was screwing anything up over explicit (first more) and (next more)

14:21 chouser: no, I mean I forked your gist, fixed it up with recur and destructuring -- and then you pasted the same thing

14:22 candera: Oh, I didn't see the fork. Was just looking at what you pasted into this channel.

14:22 chouser: here's what I had written but not yet posted: http://gist.github.com/451752

14:23 candera: chouser: OK, got it now. Sorry for the confusion. I just moved house yesterday, so that's my current excuse for being so slow. Tomorrow I'll have to think of a different excuse. :)

14:24 Anyway, thanks again for the eyeball.

14:28 bobo_: ,(contains? ["1" "2"] "1")

14:29 clojurebot: false

14:29 bobo_: why is that?

14:29 ,(contains? [1 2] 1)

14:29 clojurebot: true

14:30 noidi: ,(contains? [5 6] 1)

14:30 clojurebot: true

14:30 noidi: ,(doc contains?)

14:30 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."

14:31 noidi: bobo_, the vector does not contain an element at the index "1", but does at the index 1

14:31 bobo_: ah

14:31 ,(contains? [4 5] 1)

14:31 clojurebot: true

14:31 bobo_: ,(contains? [4 5] 4)

14:31 clojurebot: false

14:31 bobo_: i see!

14:31 thnx

14:31 lpetit: bobo_: this is a search "by key". Keys of a vector are its indices

14:32 chouser: if you want a collection of things keyed on their value, try a set

14:33 ,(contains? #{"1" "2"} "2")

14:33 clojurebot: true

14:33 qbg: contains? returns true when get can succeed.

14:33 bobo_: yes that did indeed work alot nicer

14:33 lpetit: bobo_: if contains? were to try to match vector values, the algorithm would be o(n), looking each value after the other (which a set does not, 'cause it indexes its values, as chouser demonstrated)

14:34 bobo_: indeed

14:34 http://en.wikibooks.org/wiki/Clojure_Programming/FAQ#Why_doesn.27t_contains.3F_do_what_I_expect_on_vectors_and_lists that explained it nicely

14:35 pinebaron: am I completely off base with this? I'm pretty new to lisp/clojure. http://paste.ideaslabs.com/show/fK7WyBka84

14:36 noidi: btw. which is better if you're starting with a seq, converting to a seq and using contains?, or searching linearly with some ?

14:36 I'd guess the latter, since the conversion to set probably has to walk the whole seq?

14:36 or are sets lazy too_

14:38 chouser: if you really want it to be a seq and are going to leave it as a seq (not convert it to a set and keep using it as a set), then yes just search the seq linearly

14:38 which you can do a couple of ways:

14:38 ,(some #{"1"} (list "1" "2"))

14:38 clojurebot: "1"

14:38 chouser: (.contains (list "1" "2") "1")

14:38 ,(.contains (list "1" "2") "1")

14:38 clojurebot: true

14:44 lpetit: pinebaron: sorry to say probably yes

14:46 pinebaron: a function with no argument= bad smell, a def inside a function body = bad smell.

14:48 noidi: maybe you want something like this? (defn draw [angle] (really-draw-things) (recur (+ angle (/ PI 25))))

14:49 lpetit: pinebaron: I guess what you want must be based on cycle

14:49 noidi: and of course you need an exit condition

14:49 lpetit: ,(doc cycle)

14:49 clojurebot: "([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."

14:49 lpetit: ,(cycle (range PI (/ PI 25)))

14:49 clojurebot: java.lang.Exception: Unable to resolve symbol: PI in this context

14:49 lpetit: ,(cycle (range Math/PI (/ Math/PI 25)))

14:49 clojurebot: ()

14:50 lpetit: ,Math/PI

14:50 clojurebot: 3.141592653589793

14:51 lpetit: ,(cycle (range 0 Math/PI (/ Math/PI 25)))

14:51 clojurebot: Execution Timed Out

14:51 lpetit: ,(take 15 (cycle (range 0 Math/PI (/ Math/PI 25))))

14:51 clojurebot: (0 0.12566370614359174 0.25132741228718347 0.3769911184307752 0.5026548245743669 0.6283185307179586 0.7539822368615503 0.879645943005142 1.0053096491487337 1.1309733552923253 1.256637061435917 1.3823007675795087 1.5079644737231004 1.633628179866692 1.7592918860102837)

14:55 marcolz: guys, I'm trying to use contrib.sql/insert-values, but I get an Exception that is a java.io.NotSerializableException. How can I debug it? Is there any way for printing the actual generated SQL?

15:01 briancarper: marcolz: The generated SQL is just "INSERT INTO table (col1,col2,col3) VALUES (?,?,?)". I think the serializing is done in Java.

15:04 marcolz: briancarper: Thanks Brian. I was just wondering if perhaps the SQL had some values badly quoted or anything. It would be nice to be able to debug it... the backtrace I'm getting is really useless.

15:05 briancarper: Yeah, I don't think quoting is an issue. But if your data types don't match your DB column types, Java will try to convert them itself, and it becomes confused easily.

15:47 arohner: technomancy: does lein support username / passwords on maven repos?

15:47 technomancy: I tried adding to ~/.m2/repository/settings.xml and it doesn't appear to work

15:51 cschreiner: looking for a good css-library to use with compojure

15:53 chouser: huh. jvisualvm just completely fell over trying to profile some code using the prim branch. yourkit worked fine.

15:54 DeusExPikachu: hi

15:55 bobo_: cschreiner: http://github.com/programble/csslj i havent used it but still. its a css-library =)

15:55 programble: :O

15:55 someone heard of me

15:56 cschreiner: bobo_: not quite what I had in mind :)

15:56 programble: well wtf is "css-libarary" mean?

15:56 DeusExPikachu: question, if reify is used in a function, and that function is called repeatedly, is a new anonymous class generated each time or is there some sort of caching or compiling going on?

15:56 bobo_: programble: :-)

15:57 programble: cschreiner: what does css-library mean?

15:57 cschreiner: programble: good question

15:57 programble: cschreiner: ... so answer it

15:57 arohner: DeusExPikachu: reify creates a new class each time it's evaluated, I believe

15:58 bobo_: its easier to know what you dont want, then what you want

16:00 cschreiner: bobo_: indeed

16:00 programble: but

16:00 what do you want

16:00 bobo_: :-)

16:01 programble: wtf is "css-library"

16:01 the interbutts doesn't even know what that means

16:01 cschreiner: programble: by all means, I like your solution, but please, keep your tone light

16:01 programble: well, why can't you just answer?

16:02 i mean, you want us to find you one of these "css-libraries", but won't actually tell us what you want

16:02 cschreiner: programble: because I have to think through what I want

16:02 programble: csslj is in the same style as hiccup, and will be integrated with hiccup sometime in the future

16:02 cschreiner: ok

16:03 programble: whenever weavejester gets around to it i guess...

16:03 chouser: DeusExPikachu: no. Just like 'fn', 'reify' creates a class when the form is compiled. multiple calls at runtime create instances of that class.

16:06 Licenser: hmm is rhickey around?

16:06 djpowell: should i create a issues for that laundry list of clojure.java.sh patches I posted a while back? nobody objected to them.

16:07 chouser: djpowell: did you implement any of them already?

16:08 djpowell: yeah, i posted patches for them all as attachments to my mail

16:08 chouser: ok, I thought so.

16:08 man, I wish I had time to do all the things I want to.

16:08 bhenry: chouser: don't we all.

16:08 chouser: I ought to read through your code

16:09 * dnolen ponders the fact that jQuery+Underscore.js code requires more parens then his Clojure code

16:10 djpowell: http://groups.google.com/group/clojure-dev/browse_thread/thread/b4a4d6eca3fd9b9d/1ebd2916345b88d9

16:10 chouser: djpowell: I think Halloway has proposed changes for it too.

16:10 djpowell: ok

16:10 i've been using sh a bit for calling graphviz. graphviz rocks.

16:10 chouser: graphviz does rock. except... it's about 80% of what I want. That last 20% is a pain.

16:10 djpowell: yeah

16:11 chouser: heh, it's entirely possible I wrote sh originally to call graphviz.

16:11 djpowell: the html stuff isn't very flexible I found today

16:11 and i can never get clusters to work properly (and sometimes they seem to crash graphviz)

16:12 I might try using the csv output, and rendering it myself using javascript divs or something

16:12 chouser: heh, yep. very possible. http://github.com/Chouser/clojure-classes/blob/master/src/net/n01se/clojure_classes.clj uses shell-out

16:15 djpowell: actually, it sounds like clojure.core/slurp should probably use clojure.java.io too

16:16 byte at a time copying is bad

16:16 DeusExPikachu: chouser: sweet thanks, that's what I expected, so using reify can be very efficient

16:17 chouser: yes

16:18 djpowell: it is similar to anoymous inner classes in java

16:24 DeusExPikachu: is there any good articles on clojure double dispatch using protocols (not multimethods) via the visitor pattern or whatever? I feel like that after single dispatch on type, double dispatch on type is the next common use case for multimethods. I somewhat recall rich talking about in on the internet somewhere (including discussing adding/not-adding language support) but I can't seem to find it.

16:47 alexyk: lancepantz: what do I supplu for jiraph :load function if I want to get raw bytes to use later?

16:50 lancepantz: I guess identity?

17:00 I need to define two vars in repl from a pair returned by a function; here's what I do now: (let [[a b] (load-graph "tokyo/dreps.clb" "tokyo/dments.clb")] (def dreps a) (def dments b)) -- is there a better way?

17:04 chouser: alexyk: not that I can think of

17:04 alexyk: :)

17:20 programble: cschreiner: ever figure it out?

17:21 cschreiner: programble: yeah, I went for the include-css

17:21 trad. style

17:22 programble: that... is not a css-library

17:22 cschreiner: you don't say

17:36 patrkris: does anybody know why I get a ClassNotFoundException on invoking `lein nailgun`? I'm brandonw's lein-nailgun plugin

17:36 the class not found is clojure/main

17:38 mmarczyk: Licenser: nice effort to research numerics in Clojure, thanks for posting that

17:38 patrkris: have you changed the Clojure jar recently?

17:39 patrkris: mmarczyk: Nope. I'm just using the jar leiningen downloads for me

17:39 perhaps I should wipe the clojure.jar from my maven repository and have lein download it again

17:39 mmarczyk: well, have you recently run lein deps or sth?

17:39 zakwilson: I am having a problem with Google Groups where it seems to get stuck in some sort of redirect loop on Chrome. Anyone else?

17:40 mmarczyk: I think nailgun needs to be compiled with the clojure.jar you're using... not quite sure though -- just a hunch

17:40 dakrone: zakwilson: yea, having the same problem with firefox

17:40 mmarczyk: zakwilson: yup, delete groups.google.com & googlegroups.com cookies

17:41 zakwilson: it should solve it for a while... no guarantee that it won't come back though :-/

17:42 idrop: hi, I'm new to clojure and FP, & trying to Find the sum of all the even-valued terms in a Fibonacci sequence which do not exceed four million. I have a fn for lazy seq of fibo, but trying to apply following filter to this seq:

17:42 (defn myfilter[] (filter (comp #(< % 4000000) even?) (fibo)))

17:42 zakwilson: mmarczyk: clearing the cookie fixed it. Thanks.

17:43 mmarczyk: good, though as I said, the problem seems to recur occasionally for whatever reason

17:44 idrop: you could also take every third term

17:44 idrop: and i think the even? predicate is returning a list of boolean, which can't be evaluated by the next-left predicate.. guess i has thought comp was the intersection of predicates

17:44 mmarczyk: comp is function composition

17:45 eevar: idrop: you're applying your filter to every element in the infinite list?

17:45 mmarczyk: you could use, say, #(and (< % 4000000) even?)

17:45 or (filter even? (take-while #(< % 4000000) (fibo)))

17:46 idrop: ooooh, 'and' .. that makes sense

17:46 mmarczyk: :-)

17:51 tomoj: need to add a point there

17:51 (even? %) I mean

17:52 mmarczyk: hm? where?

17:53 there's no point to wrapping even? in #(even? %), if that's what you mean

17:54 tomoj: #(and (< % 4000000) (even? %)) I mean

17:54 mmarczyk: ah, um, ouch :-P

17:54 tomoj: #(and (< % 4000000) even?) is the same as #(< % 4000000)

17:54 eevar: testing for size in the filter is kindof awkward, tho. when do you stop?

17:55 mmarczyk: yup, silly me, thanks

17:55 tomoj: yeah, won't work anyway :)

17:56 mmarczyk: true. one problem here was "how to compose predicates", the other was "why take-while should be used" ;-)

17:56 tomsw: hello

17:57 tomoj: so clojure in uncle bob's keynote I hear :D. wonder how many will come because of that

17:57 mmarczyk: yeah, I tried scanning the video to find the mention, but somehow couldn't

17:58 tomsw: is there a way to create an anonymous class that implements an arbitrary set of methods?

17:58 i thought of (proxy [Object] [] (method1 [args] ...)) but I can't call method1 on the result

17:59 mmarczyk: tomsw: nope, if you need arbitrary methods -- possibly specific to your class -- you'll need gen-class

17:59 proxy can only implement methods of the superclass + interfaces

18:00 idrop: got it now, thanks for your help

18:00 mmarczyk: what I really loved about that keynote -- Uncle Bob's -- though, was how he insisted that everybody needs to flush their reading queues and read SICP as their very next book :-D

18:01 tomoj: nice

18:01 tomsw: mmarczyk: how do I get from creating a namespace that creates a class to an instance of that class?

18:01 mmarczyk: idrop: happy Eulering (I guess?) :-)

18:01 cemerick: yeah, who'd have ever thought Uncle Bob would be the highest-profile clojure proponent

18:01 tomoj: I can hear all the rubyists grumbling about parentheses

18:01 mmarczyk: cemerick: that's a lol-inspiring way of putting it :-)

18:02 tomoj: through the constructor ;-)

18:02 idrop: mmarczyk: indeed :)

18:02 mmarczyk: ouch, I mean, tomsw

18:03 tomsw: mmarczyk: ouch indeed

18:04 Licenser: mmarczyk: you#re welcome :)

18:04 and thak you for noticing

18:04 mmarczyk: Licenser: how could I not :-)

18:08 Licenser: well it was spammy? :P

18:08 tomsw: mmarczyk: ok but it's not dynamic in the sense that it will only generate classfiles that can be loaded by another java instance - I can't just inject a new class into the current environment

18:09 mmarczyk: Licenser: not my meaning at all ;-)

18:09 tomsw: true

18:10 tomsw: why would you want to inject an entirely new class -- as opposed to a subclass of a preexisting class overriding some methods or perhaps a class implementing some interfaces?

18:12 tomsw: mmarczyk: in this case it's because I'm trying to do as much as possible on the repl without compiling anything :)

18:12 mmarczyk: well, that won't be possible at this time

18:12 note that if you use :gen-class, you can replace methods dynamically

18:13 tomsw: ok. time to stop pretending this is javascript

18:13 mmarczyk: only addition / removal of methods needs to happen ahead-of-time

18:13 :-)

18:14 Licenser: mmarczyk: but it seems we still have a long way to go :)

18:15 mmarczyk: heh, reading "Let Over Lambda" now... funny how a good part of the introduction is devoted to the magnificence of Paul Graham's "On Lisp" :-)

18:15 tomoj: oh god the intro...

18:15 cemerick: it's an easy thing to do

18:15 tomoj: best part is that it ends with "your humble author" :D

18:15 mmarczyk: Licenser: and it is a *long* way indeed, with some downcasting maybe ;-)

18:16 tomoj: really? bwahahaha :-D

18:18 tomsw: I liked the auto-quoting macros and the pandoric macros, but "humble" is just wrong

18:21 cemerick: technomancy: 322 looks like it's in the bag from here :-)

18:40 arohner: technomancy: it looks like lein plugins can't effectively hook deps, because the first time you run lein deps, your plugin isn't installed

18:43 alexyk: oh, the hookery of it

19:46 Blackfoot: for clj-native, i'm trying to get the root DynamicClassLoader. But when compiling with SWT, the whole chain from baseLoader does not contain an instance of that class

20:29 bortreb: Good evening everyone

20:29 I've been using clojure.contrib.shell-out to write some simple scripts, but it always waits for the command to finish before printing the results. Is there some way to make it print to the terminal as the shell command generates text? (I'm using it to automate calls to rsync that take ~15 mins and want to see the progress)

20:30 maybe using binding to *out* or somethign?

20:31 chouser: bortreb: not yet. you can mimic its implementation in your own code.

20:33 bortreb: so I'd have to rsync each file independently and print those results as they complete instead of issuing one command?

20:33 for example?

20:36 chouser: bortreb: I just mean you could write your own sh fn that prints stdout as it goes or something.

23:12 alexyk: lancepantz: pingy

23:18 rsh: i have a deeply nested object that consists of a map with a key that is a vector of maps, which in turn have a key that are a vector of maps. I want to remove a map from the inner vector.. would a zipper help me here? will anything?

23:21 tomoj: you have descended into hell

23:21 only satan can help you now

23:22 I would be interested to hear what this map represents :)

23:27 mmarczyk: rsh: a zipper would do fine, though you might need to supply your own branch? & children functions to clojure.zip/zipper

23:28 rsh: thanks

23:28 mmarczyk: depending on what you want to do, you might also have use for clojure.walk

23:29 tomoj: how would you zip it?

23:29 only descend into keys?

23:29 mmarczyk: I mean, do you want to pop each of the inner vectors or something more complex than that?

23:30 rsh: I need to pop if a key on the map equals something

23:31 the only examples of zippers I have seen use nesting of the same kind of data structure

23:32 mmarczyk: tomoj: ah, depends... the general zipper concept would do just fine, but it involves a one-off implementation; clojure.zip might need to be coerced to do the job

23:32 Huet's paper describes zippers on heterogeneous trees

23:32 I mean, tree-like structures where nodes might have different types

23:32 and that's in a statically typed language

23:33 you could treat map keys as accessors for fields in ADTs and reuse some concepts

23:34 um, one question though

23:34 is the outermost map involved in determining what to remove from the innermost vectors?

23:34 rsh: nope

23:35 found the paper, I will have a look at it

23:35 mmarczyk: ok, so maybe just write a function to look at an inner map

23:35 check if the vector inside it needs to be popped

23:35 if so, return a version of the map with the vector popped

23:36 call this function foo; then apply this to the outer map:

23:36 (partial update-in [...] (partial map foo))

23:36 hm, overengineered this one :-P

23:37 (update-in outer-map [...] (partial map foo))

23:37 argh

23:37 (update-in outer-map [...] (partial foo

23:37 ... <- here goes the outer vector key

23:38 sorry for the confusion, I suddenly realise that this is probably my bedtime... but this should probably do fine with no zipping

23:38 rsh: yes, I like the path you were suggesting at the end

23:41 mmarczyk: hope it works out fine -- going off to bed now :-)

23:41 rsh: good night

Logging service provided by n01se.net