#clojure log - Feb 23 2011

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

0:00 Sgeo: Erm, (recur)

0:00 amalloy: Sgeo: yes, given your substitution there :P

0:01 but uhm, wouldn't it be easier to just try it? ##(#(if (zero? %) "done!" (recur (dec %)))) 5)

0:01 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: sandbox6385$eval8665$fn

0:01 amalloy: feh. matching parens in irc is apparently too hard for me

0:02 (#(if (zero? %) "done!" (recur (dec %))) 5)

0:10 Sgeo: How often is partial used with -> ?

0:18 "If a pure function mutates some local data in order to produce an immutable return value, is that ok?

0:18 "

0:18 Sounds ST monadish

0:18 Although maybe this is different

0:29 tibbe: Was there ever a discussion about the pros/cons of providing O(1) size() for maps? i.e. it costs a little bit of performance to do so.

0:32 amalloy: tibbe: i'm not even sure that's the case, since maps have to track their size in order to decide when to repartition the hash bucket

0:32 (for persistent hashes this is probably still true, though quite possibly the details are different)

0:33 * tibbe goes and looks at the code again

0:33 tibbe: I was thinking of PersistentHashMap in particular

0:33 amalloy: tibbe: link me to the source?

0:33 tibbe: amalloy: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java

0:34 amalloy: the PHM stores the count next to the root node

0:34 amalloy: functions that might modify the size return an indicator up the call chain to indicate if they have done so (so the count can be updated)

0:35 amalloy: fair enough

0:36 i wouldn't be surprised if O(1) size was provided to mirror java's Map interface, which is often used with the assumption that size is O(1)

0:36 tibbe: amalloy: right

0:37 amalloy: and it doesn't seem to cost much performance

0:37 i guess i'm just speculating, and it sounds like you've done all the interesting speculation already :)

0:38 tibbe: amalloy: The reason I'm asking is that I tried to add it to my Haskell implementation and it costs about 3% for lookups and 6% for inserts/deletes

0:38 amalloy: and I'm trying to figure out if it's worth it

0:39 also adds a bit of code complexity

0:39 amalloy: tibbe: have you looked at chouser's finger trees? an interesting example of a tree structure that needs to track size in order to be useful

0:40 tibbe: amalloy: no, but we do have finger trees in Haskell that does that

0:40 amalloy: yes, i suppose we did rather steal the idea

0:40 tibbe: amalloy: size balanced trees use it too

0:40 so in those cases you get O(1) size for free

0:41 amalloy: we call it borrowing among friends :)

0:41 amalloy: either way i don't plan to give it back

0:42 tibbe: amalloy: heh

0:44 Sgeo: In order to make a thread, do I have to deal with Java?

0:57 amalloy: &@(future (Thread/sleep 3000) (println "no"))

0:57 sexpbot: ⟹ nil

0:57 amalloy: &@(future (Thread/sleep 2000) "no")

0:57 sexpbot: ⟹ "no"

0:57 Sgeo__: What's the &@?

0:58 amalloy: & gets sexpbot involved

0:58 @ derefs the future object

0:58 Sgeo__: &(#(if (zero? %) "done!" (recur (dec %))) 5)

0:58 sexpbot: ⟹ "done!"

0:58 Sgeo__: What's with that thing at the beginning?

0:58 amalloy: the arrow?

0:59 Sgeo__: It doesn't show up for me :(

1:00 amalloy: use a font with unicode support :P

1:00 or in your unicode-supporting repl, try (char 0x27e9)

1:11 Sgeo__: I suppose there's nothing in Clojure that's quite like .NET's event framework? Does the JVM have an equivalent?

1:14 amalloy: er, there's swing/awt

1:16 Sgeo__: How does one hook into a Swing/AWT event, and can I do a similar thing for custom events in my own application?

1:19 amalloy: i think you *can* do something similar, but (a) it's afaik rare and i haven't done it in a long time, and (b) in a functional language like clojure it's pretty easy to roll your own, or find a clojure library that does this already

1:27 if .net excites you, you can see how clojureclr is coming along

1:33 * Sgeo__ wonders if regular tail-call using code can be mechanically converted to using trampoline

1:35 Sgeo__: Just thinking about it loosely, not too carefully, but I think the trickiest part is automatically wrapping what needs to be wrapped while still allowing it to be TCO'd... I ... hm

1:52 polypus: anybody know how to override a static method with gen-class?

2:00 sattvik: polypus: It's impossible. Static methods belong to a class and cannot be inherited.

2:08 Sgeo__: http://groups.google.com/group/clojure/msg/2ad59d1c4bb165ff are Clojure's agents basically actors?

2:13 polypus: sattvik: ty

2:17 Sgeo__: IIRC, Scala has some weird issue where private static methods can't be called by instances of the class, iirc

2:17 Can I assume Clojure doesn't have that issue? (It wouldn't make sense for it to, I guess)

2:39 All these random tools for Clojure due to it being JVM. Ant and a Java IDE etc. etc.

2:39 It's a lot considering that I just want a language to toy around with

2:53 scottj: you don't have to use any of that if you don't want to

2:58 Sgeo: Aren't null values generally considered nasty in functional languages?

2:59 raek: Sgeo: I don't think you can generate non-public methods from clojure. (after all, gen-class is intended to be used when you need to make clojure callable from java, so it's not something you use very often)

2:59 (there are simpler ways of doing interop too)

3:00 scottj: Sgeo: probably but it's part of java

3:16 stirfoo: Sgeo: there is a video where Hickey (the author of clojure) explains the coping mechinism he employed trying to implement common lisp's t and nil, and scheme's #t and #f and how this mapped to Java.

3:17 It's an interesting discussion, but I can't remember the exact video.

3:54 __name__: good morning

4:07 fliebel: __name__: morning

5:25 Hm, if ClojureCLR would work on Mono, one could run it one MonoTouch, I imagine.

6:18 clgv: fliebel: doesn't it work on Mono? I guess there is a decent probability that it will

6:25 fliebel: clgv: I tried… It has a weird dependency, and doesn;t compile.

6:25 clgv: fliebel: can you AOT compile a clojure project on MS .NET? then you could take the binary and execute it on mono

6:26 that might work even if you dont get the development environment running under Mono

6:26 provided you ship all needed .Net assemblies

6:26 fliebel: clgv: Do you happen to have one laying around? I don;t feel like dusting of some windows box right now.

6:27 clgv: not here. but at home

6:27 but I didnt try ClojureCLR at all, yet

6:28 fliebel: Who maintains ClojureCLR?

6:28 clgv: it's one entry on my list "Nice to try in future" ;)

6:29 fliebel: oh, ther is a binary distribution!

6:29 clgv: that could work ;)

6:30 the question is what language features are used. if it is only .NET 2.0 or 3.0, I guess Mono can handle it

6:30 fliebel: once MacPorts has finished doing its thing, I'll install Mono, and give it a try.

6:31 There's a 4.0 and a 3.5 distribution

6:34 How do I def a dynamic var?

6:34 clgv: in C#?

6:35 fliebel: no, Clojure

6:35 1.3

6:35 clgv: no idea, I am still in the past 1.2 ;)

6:35 Chousuke: wasn't it (def ^:dynamic foo)?

6:35 fliebel: could well be :)

6:36 Chousuke: I guess that should be *foo* :P

6:53 zoldar: what is the way to stop aleph server without restarting the whole repl?

6:54 fliebel: What is a good way to make a bunch of functions that can use another variable function? Should I pass the function around? (verbose) Do some binding trick? (hacky) Something else?

6:54 zoldar: I think Aleph returns a function when you start it, calling that stops it again.

6:54 zoldar: fliebel, thanks!

6:56 fliebel: Hm, binding doesn't even work… Any ideas how to do this in a clean way?

6:57 zoldar: fliebel, what do you mean by a variable function ?

6:57 fliebel: well, it can be a different function sometimes.

6:57 so I have funcion x calling, y, but sometimes i want it to use z instead.

6:59 Chousuke: passing it around would probably be the most "functional" solution but you can use an atom too.

7:00 fliebel: Chousuke: Why an atom? I was hoping that binding a var would work, but it doesn't.

7:00 Chousuke: hm

7:01 binding should work, as long as the var is dynamic.

7:01 you have several options, each having different properties :)

7:01 fliebel: I'm doing (binding [y z] (x)) and it happily goes on to use y.

7:02 Chousuke: is y a dynamic var?

7:02 fliebel: yea

7:02 Chousuke: then I dunno, maybe x needs to be one too :/

7:02 I'm not quite up to date on 1.3

7:05 fliebel: I think it's because x is defined outside of binding.

7:05 raek: have you tried recompiling x after you made y dynamic?

7:06 I think the call is compiled in a different way if the var is dynamic

7:07 fliebel: raek: What do you mean 'recompiling'?

7:07 example: https://gist.github.com/840338

7:07 raek: revaluating the defn form

7:09 fliebel: https://gist.github.com/840340

7:09 fliebel: raek: this is really creapy… https://gist.github.com/840338

7:10 raek: hrm

7:11 yes, a function call seems to compile to different byte code when the var is dynamic

7:13 fliebel: … I don't get it. The definitions of c where the same.

7:13 *x

7:13 Only difference is htat one was defined before the binding call

7:13 raek: fliebel: did you evaluate this exactly in the order of the gist?

7:14 fliebel: I think so, but I'll try again.

7:14 Chousuke: fliebel: can you reproduce that with a clean repl?

7:14 fliebel: it could always be a bug. :)

7:17 fliebel: Can't reproduce...

7:18 raek: I think you did something like (defn y ...) (defn x ...) (defn ^{:dynamic true} y ...)

7:18 fliebel: yea..

7:18 raek: at least that would explain it. otherwise, this is a creepy bug.

7:19 fliebel: No, I did define it non-dynamic first.

7:19 fliebel1: But then dynamic, and *then* did a binding

7:19 Chousuke: yeah, you need to define all functions using y after you've defined y dynamic

7:20 fliebel1: right

7:20 Chousuke: otherwise you'll get weird behaviour

7:20 raek: hrm. maybe this means that (declare *foo*) (defn bar ... (*foo* ...) ...) (defn *foo* ...) won't work either

7:21 fliebel1: this is reproducable: https://gist.github.com/840338

7:22 raek: Can't you make dynamic declarations?

7:22 raek: hrm. maybe (declare ^:dynamic *foo*) would work...

7:24 fliebel1: But still, this is not what I'm doing in my real code, and it exhibits the same behavior.

7:26 Chousuke: fliebel1: that test case is expected behaviour I think

7:26 fliebel1: I do (def ^:dynamic *full-adder-o* (addfn 2)), and then define a few functions using that.

7:27 Cozey: ,({12 :foo} (Short/parseShort "12"))

7:27 clojurebot: nil

7:27 Cozey: Is this expected? I just spent an hour stalking this behaviour

7:27 fliebel1: Cozey: That would work in 1.4, but not 1.2

7:27 1.3

7:27 Cozey: is 1.3 stable?

7:28 fliebel1: no

7:28 Cozey: mhm

7:28 fliebel1: well, not by name. It runs stable for me :)

7:29 Cozey: I wonder if I should just do conversions to Integer, or switch to 1.3, since there might be more surprises like this

7:29 fliebel1: raek, Chousuke: My real code manages to keep using the old value even with #'*full-adder-o*

7:30 raek: fliebel1: and you have reevaluated all defns that use the dynamic var?

7:30 ,({12 :foo} (int (Short/parseShort "12")))

7:30 clojurebot: :foo

7:30 fliebel1: raek: I have never defined them using a static var ;)

7:30 raek: ok, then that's strange

7:31 zoldar: I'm trying to setup a simple websocket echo server using aleph. First "registration" goes fine, but server doesn't broadcast any messages that go after it (checked with wireshark). What am I doing wrong? http://paste.lisp.org/display/119913

7:31 fliebel1: or.. maybe cake kept them around secretly...

7:31 no :(

7:32 Chousuke: how about laziness?

7:32 you're not binding around a map call or anything?

7:33 fliebel1: Chousuke: No… but… let me see :s

7:34 yea, laziness. I hadn't even realized (logo.minikanren/)run was lazy

7:45 tscheibl: hi there

7:46 AWizzArd_: Hallo tscheibl.

7:47 octe: how do those with-transaction or with-connection macros/function work?

7:50 ejackson: acto: they call (.close x) in a finally block

7:50 octe: i mean, how do they keep a connection in some kind of context that all the function calls inside have access to?

7:54 rata_: octe: a binding block?

7:57 octe: hmm

7:57 i guess i should look at the code :)

7:58 ejackson: octe: yeah I always figured it was a dynamic var

7:59 octe: it creates a *db* binding it seems

8:00 which is thread-local, right?

8:00 ejackson: yp

8:02 octe: hmm, i want to transform a list with this structure: [{:name "foo" :value "bar" :group "grp1"} {:name "foo" :value "bar2" :group "grp2"} {:name "baz" :value "boo" :group "grp1"}] into something like -> {:grp1 {:foo "bar" :baz "boo"} :grp2 {:foo "bar2"}}

8:03 any pointers?

8:03 raek: sounds like a job for reduce

8:04 (reduce function-explained-later {} the-list)

8:05 (defn function-explained-later [acc {:keys [name value group]}] (update-in acc [group] (assoc name value)))

8:06 octe: ah, yes

8:06 thanks

8:06 raek: ,(reduce (fn [acc {:keys [name value group]}] (update-in acc [group] assoc name value)) {} [{:name "foo" :value "bar" :group "grp1"} {:name "foo" :value "bar2" :group "grp2"} {:name "baz" :value "boo" :group "grp1"}])

8:06 clojurebot: {"grp2" {"foo" "bar2"}, "grp1" {"baz" "boo", "foo" "bar"}}

8:07 raek: octe: the parens around assoc in my first example should be removed

8:07 you can call (keyword name) on the name too

8:08 tscheibl: ,

8:08 clojurebot: EOF while reading

8:08 tscheibl: ,(doseq [x [[:js :text/javascript] [:css :text/css] [:xhtml :application/xhtml+xml]]] (intern *ns* (symbol (as-str "wrap-" (x 0))) (fn [handler] (wrap-content-type handler (x 1)))))

8:08 clojurebot: DENIED

8:08 tscheibl: is this bad?.. i mean .. it works

8:09 Chousuke: looks like you should use a macro instead.

8:09 tscheibl: it autogenerates the functions wrap-js wrap-css and wrap-xhtml

8:10 Chousuke: yeah. macros are generally better for that

8:10 rata_: tscheibl: yes, a macro seems better suited for that, as all the information you need is available at compile time

8:10 tscheibl: hmm ok.. i will try

8:10 raek: (defmacro defmime [name type] `(defn ~(symbol (str "wrap-" name)) [handler#] (wrap-content-type handler# ~type)))

8:11 tscheibl: ok...

8:11 raek: and then (defmime js :text/javascript) (defmime css :text/css) (defmime xhtml :application/xhtml+xml)

8:12 tscheibl: istead of x, (x 0) and (x 1) in the code, you can write [name type], name and type

8:13 tscheibl: yeah.. looks more concise

8:14 thx

8:17 xkb: hi

8:18 I'm working on a tank game, based on the ants simulation. I'd like to know if there is a way to start an agent from within another agent?

8:18 I'd like to model the bullets the tank fires as an agent

8:20 Chousuke: sounds like you'd end up with lots of agents :/

8:21 xkb: true

8:21 Chousuke: How about a global "bullets" data structure (in a ref) instead and just have the tank agent add to it, then periodically run a function to update the bullet positions.

8:22 xkb: so the tank agent would encapsulate "the grid" + a list of bullets?

8:22 Chousuke: nah, the tank agent can be separate from the bullet ref

8:23 after all, the tank has nothing to do with the bullet after it's been fired

8:23 xkb: ah because the list of bullets is global

8:23 a tank now is (agent [x y])

8:23 and [x y] may contain a tankrecord

8:23 with direction, barrel direction etc

8:23 Cozey: What's a better idea: use keywords or strings for session keys in Compojure?

8:24 Chousuke: of course the bullet may need to know the tank it came from, for scoring

8:24 but that's about it

8:24 xkb: Chousuke: interesting idea

8:24 tscheibl: @raek and what about this, to get rid of the redundant defmimewrapper call?

8:24 xkb: I was trying to spawn an agent with each "fire", but that doesnt work somehow

8:24 tscheibl: ,(doseq [x [['js :text/javascript] ['css :text/css] ['xhtml :application/xhtml+xml]]] (defmimewrapper (x 0) (x 1)))

8:24 clojurebot: java.lang.Exception: Unable to resolve symbol: defmimewrapper in this context

8:24 Chousuke: if you have all the bullets in the same data structure, it'll be a lot easier to update them all in sync

8:25 xkb: indeed

8:25 Chousuke: and to run collision detection

8:25 xkb: that should be quite easy actually: the world is a grid, and each gridcell only has one occupant

8:25 so either wall, tank or bullet

8:26 Chousuke: of course, you *might* get performance issues due to low granularity but you won't know that until you code and test it :P

8:26 xkb: hehe

8:26 Chousuke: and if it turns out to be too slow then you can make it more complicated

8:27 xkb: so if I add the bullet to a central list, how would I dispatch a function to it?

8:27 Chousuke: a function?

8:27 xkb: just thinking out loud

8:27 yes

8:27 Chousuke: you mean (dosync (alter bullet-ref update-bullet-positions) ...)?

8:28 xkb: normally I'd do something like this: (dorun (map #(send % move) bulletlist))

8:28 but the bulletlist changes

8:28 rata_: tscheibl: again, use the [name type] destructuring instead of (x 0) and (x 1)

8:28 xkb: where bulletlist contains bullet agents

8:29 rata_: tscheibl: (doseq [[name type] [['js :text/javascript] ['css :text/css] ['xhtml :application/xhtml+xml]]] (defmimewrapper name type))

8:29 Chousuke: xkb: that's the nice thing about having just one mutable thing. you'll get the entire bullet list as an immutable thing, and calculate a new bullet list from that

8:29 xkb: no need to worry about the head of the list changing before the tail :)

8:29 rata_: tscheibl: so seems cleaner to me

8:29 raek: tscheibl: you'd need to put the doseq in a macro too: (defmacro defmimewrappers [m] (cons 'do (for [[name type] m] `(defmimewrapper name type))))

8:30 xkb: hmm

8:30 Chousuke: raek: missing a couple unquotes.

8:30 raek: eh. very true.

8:30 xkb: I think I'm just gonna try it :)

8:30 usually works best when learning

8:31 raek: (defmacro defmimewrappers [m] (cons 'do (for [[name type] m] `(defmimewrapper ~name ~type))))

8:31 Chousuke: xkb: the rule of thumb is that the fewer mutable things you have in your program, the easier it is for you

8:31 xkb: Chousuke: yeah, that's why I started with just the cell on the grid a tank was on, or was about to move to.

8:33 Thumper_: /wc

8:40 tscheibl: @raek: thx very much... I see I'm just at the beginning of getting a grip on the mechanics of Clojure :)

8:43 clgv: "the mechanics of clojure" sounds like a book title ;)

8:44 Fossi: and like one i'd buy ;)

8:47 tscheibl: and "the inner mechanics of clojure" :) as the logical sequel

9:05 Scriptor: tscheibl: I would get that in a heartbeat

9:39 rata_: what's the function that transforms "regex" into #"regex"?

9:42 cemerick: rata_: re-pattern

9:42 rata_: thanks cemerick =)

9:59 TimMc: ,'#"foo"

9:59 clojurebot: #"foo"

9:59 TimMc: hrm

10:00 Fossi: foo is foo is foo

10:00 TimMc: I was hoping I could get the expansion.

10:00 ,'~foo

10:00 clojurebot: (clojure.core/unquote foo)

10:00 TimMc: like that

10:01 ejackson: foo is foo is foo, but in France we call it LeFoo.

10:01 pdk: does gaston come with it

10:02 clgv: ,#'"foo"

10:02 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol

10:02 clgv: ;)

10:03 what expansion should a string have?

10:07 rata_: clgv: #"foo" is not a string

10:08 clgv: oh right ;)

10:08 ,#"foo"

10:09 clojurebot: #"foo"

10:09 clgv: ,(type #"foo")

10:09 clojurebot: java.util.regex.Pattern

10:10 clgv: I guess clojure simply prints out every pattern like this. so you dont see anything else

10:11 TimMc: How do I collapse truthy and falsey values to true and false?

10:11 $findfn nil false

10:11 sexpbot: [clojure.core/keyword? clojure.core/chunked-seq? clojure.core/sequential? clojure.core/fn? clojure.core/not= clojure.core/string? clojure.core/sorted? clojure.core/false? clojure.core/true? clojure.core/symbol? clojure.core/number? clojure.core/integer? clojure.core/... http://gist.github.com/840520

10:11 TimMc: sexpbot: You're back!

10:12 clgv: he was gone?

10:12 Raynes: He left?

10:12 clgv: $seen sexpbot

10:12 sexpbot: sexpbot was last seen joining on :#jiraph 12 hours and 26 minutes ago.

10:12 Raynes: My logs tell me that amalloy restarted him last night for some reason, but I'm not certain why or how long he was gone.

10:12 clgv: lol thats where he was ;)

10:13 TimMc: ,(boolean nil)

10:13 clojurebot: false

10:13 TimMc: ,(boolean 5)

10:13 clojurebot: true

10:13 TimMc: \o/

10:16 Question: I'm making an undo/redo manager, called History. (I'm abstracting it from my existing program.) It has undo? and redo? accessors, but...

10:16 ...should undo and redo, when called on a fresh History, throw an exception or return the unchanged object?

10:17 clgv: are you working immutable?

10:17 TimMc: It is a defrecord, so yeah.

10:18 clgv: fresh history = empty history?

10:18 TimMc: yeah

10:18 Empty undo and redo buffers.

10:19 clgv: I need an organization chart: the history does contain the state of the whole program?

10:19 TimMc: Each is just a list acting as a stack. There's also the current state.

10:19 It's just the state of the user's data.

10:19 Not the current tool selection, mode, view state, etc.

10:19 clgv: ah kk. if nothing is in there simply return it unchanged

10:20 what use would you have from an exception? except that someone would have to catch it somewhere ;)

10:20 TimMc: Or it would help the client (me!) debug bad event handling and state.

10:21 clgv: but is it bad in this case?

10:22 you could also return nil as a third option ;)

10:22 TimMc: Bleh, nil propagation.

10:22 clgv: but that would only cause a deferred NullPointerException somewhere sooner or later ;)

10:23 TimMc: Yeah, which is evil and bad.

10:23 joly: If you want to do more in this situation than a no-op, you'll need to signal it somehow (exception, nil, etc.). I generally see undo ignored if there's nothing left to undo.

10:25 clgv: yeah I think it is not bad behaviour to just ignore it there. if it's really wrong you'll notice with non-empty history ;)

10:25 TimMc: It *should* be harmless to ignore it.

10:25 I suppose that if the client really cares, they can check using identical?.

10:25 Fossi: emacs at least displays a "nothing to undo in this buffer"

10:25 clgv: are you doing automatic testing?

10:25 Fossi: so somebody might like to do that as well

10:28 TimMc: clgv: Not yet for that feature, but good point.

10:28 I suppose I'll just make sure to document the behavior in that case and make sure it is detectable.

10:41 Dranik: what is the best tool for TDD in clojure?

10:41 nfma: i've been using lazytest and i am very happy with it :)

10:42 semperos: I doubt there's a "the best", but clojure.test, lazytest and midje are worth exploring

10:42 midje has some extra emacs goodness the author includes in the source

10:45 Dranik: nfma, semperos thanks!

10:49 nfma: i'm having some problem type hinting my code, so I've created an empty project with only clojure 1.2 and clojure contrib 1.2 using lein new, i start the repl and set the *warn-on-reflection* var to true, copy paste a bit of code http://pastebin.com/UemhjifF from the clojure.org website where they give examples of type hinting and the still the type hints are not applied... has anyone had this problem before?

10:51 semperos: just tried it myself, not seeing what you're seeing

10:51 dmiles_afk: what is the benefit of ClojureCLR over runing Clojure in IKVM?

10:52 (if it can be ran in IKVM that is)

10:52 clgv: can it?

10:52 dmiles_afk: i am sure it almost can

10:52 since most anyhting runs in IKVM now

10:53 clgv: I'd answer you get immediate direct connection to .NET ;)

10:53 nfma: semperos, are you using lein 1.3.1?

10:54 clgv: nfma: I dont get the warning with clojure 1.2.0

10:55 nfma: i have to figure out what's different...

10:55 clgv: maybe the jars ;)

10:55 nfma: my jars were downloaded automatically with leiningen

10:56 also i have the same problem with clojure 1.3 alpha 4

10:57 clgv: hm ok. I installed my jars manually to my project ;)

10:57 jcromartie: is doto still useful?

10:57 nfma: but did you get them from clojars?

10:58 clgv: nope. from clojure.org

10:58 nfma: i'll try that, thanks

10:59 semperos: nfma: I'm using Leiningen 1.4.1, Java 1.6.0_23 client vm

11:00 clgv: Leiningen 1.4.2 on Java 1.6.0_24 ;)

11:01 joly: jcromartie: I think doto is still useful if you're doing a bunch of operations with side effects on an object. Usually more for Java interop, I'd imagine

11:01 nfma: ya, no luck for me... i'll upgrade leiningen then

11:01 thanks

11:02 semperos: np

11:03 nfma: to make it simple, you might try just using the clojure jar by itself (no leiningen, just download and stick on classpath) and see if you see the same behavior

11:07 nfma: upgrading leiningen did the trick, but ya if it hadn't that's what i would have done. thanks samperos and clgv

11:13 jcromartie: wow StringTemplate is awesome

11:14 not a fan of the clj-stringtemplate that's out there on bitbucket though

11:32 fliebel: dnolen: hi :)

11:45 dnolen: fliebel: how's it going?

11:46 sritchie_: hey all, one quick question about lazy sequences --

11:46 I'm working on a cascalog app, that requires me to serialize float arrays between hadoop jobs

11:47 hadoop supports java.io.serializable objects, so I'm finding that I'm able to store lazy sequences in a hadoop sequencefile,f or later retrieval

11:47 my question is -- is this safe? what does a lazy sequence serialize with it?

12:10 fliebel: dnolen: meh, I quit after I removed the decimal logic.

12:14 dnolen: fliebel: seems like you're starting to have a good understanding of how miniKanren programs work :)

12:15 fliebel: dnolen: meh, I haven't thoroughly read and understood the last chapters, so unification is still kind of magic.

12:16 scottj: is it unidiomatic/confusing/bad to name variables that are the return value of predicates with a "?"? like (let [task? (task-exists? id)]...

12:17 fliebel: dnolen: But as a good (or at least non-moronic) functional programmer, I just threat it as a black box that does the same thing every time.

12:18 AWizzArd_: scottj: that is perfectly fine

12:18 ejackson: scottj: seems fine, or maybe is-task.

12:19 dnolen: fliebel: Unification is not so tricky, that chapter is good and clear. The monadic interleaving goal code is much trickier to understand, I thought.

12:20 fliebel: dnolen: huh, monads? :D I definitely need to learn those as well.

12:22 dnolen: fliebel: the code is monadic but I think learning monads to understand that code is overkill.

12:23 pheep: hi, is there any good example of a _bigger_ swing application?

12:24 I have a hard time managing state through several components, all tutorials on swing that I can find are just for very simple programs where all state can be hold in one map or so easily.

12:30 say, in oop terms I would have one class main window which holds an instance of a user control class and both components can change their own state. Know in clojure I would hold the state of the components in maps and this map in an atom or so, so that the map itself is immutable. But when I add the atom of the user control to the map of the main window it's not really immutable anymore.

12:31 how can I solve this?

12:32 Despite1: Are you concerned about doing nested atoms?

12:33 semperos: using atoms (and other concurrency structures) is about controlling change, not making things immutable; Clojure' data structures are already immutable

12:34 pheep: Despitel, yes, kind of.

12:35 semperos, I know that maps are immutable, however - I would not say they are logically immutable if they contain an atom, so I would prefere (atom {:a 2, :b 3}) over {:a (atom 2), :b (atom 3)} or would you suggest otherwise?

12:36 * dnolen wishes there was a good tutorial introduction on Datalog implementation

12:37 Despite1: I think using atoms as values is fine. *your* copy of the root map won't change, just like any other immutable structure

12:37 I could be completely wrong about that, but that's how I've been thinking of it

12:41 semperos: if holding atoms in a map is just a convenience (so you're not passing as many parameters between functions), having a map of atoms makes some sense

12:41 but consideration should be given to how you're needing to update the state

12:42 Licenser: greetinga

12:44 Despite1: Actually, since these are interconnected UI elements, wouldn't you want updates to them to be synchronized? In which case, you'd need a collection of refs.

12:44 Which is more effort.

12:50 scottj: how would you guys write this differently, use exceptions/state/monads? (if-not (valid1? a) :invalid1 (let [b (foo a)] (if-not (valid2? b) :invalid2 (if-not (valid3? b) :invalid3 ... (do (something with a) :ok)))))

12:53 pheep: for single components that do not nest I actually handled it this way: if some event occurs, for example if a button is clicked, I read the required control-propertys(for example the text of a textbox) and pass them together with the state-map to some function. For example if I have a (let [state (atom {:name ""})] .. I would do then (add-action-listener some-btn (fn [e] (swap! state set-name (.getText name-txt))) where (defn set-name

12:53 Licenser: clj-swing alows cuppeling refs/atoms with ui elements

12:55 amalloy: Despite1: you are in fact completely wrong about using atoms as values :)

12:56 rata_: scottj: at least this is less nested: (if-not (valid1? a) :invalid1 (let [b (foo a)] (cond (not (valid2? b)) :invalid2 (not (valid3? b)) :invalid3 ... :else (do-something-with a))))

12:56 pheep: Licenser, is clj-swing generically usable with arbritary swing components? I never really looked at it but it seemed to me to be just for some specific swing components?

12:56 amalloy: "your" copy of the root map won't change: it will still point to the same atoms, but those atoms will have changing values

12:58 Licenser: pheep: yes and no :) it wrapps special ones but it can interact with every swing component, since clj-swing adds no special wrappers/data structures arond thing

12:58 s

12:59 Despite1: Hmm, I could see how that might be trouble

12:59 pheep: Licenser, are there any examples or introductory documents?

13:00 Licenser: there is an example in the github repo: https://github.com/Licenser/clj-swing/blob/master/src/clj_swing/example.clj

13:01 I know it's not much :(

13:02 Another question to annoy you all :) I was trying to work with Sharepoint and clojure/Java, now I have found an example for java and usually translating code works pretty well - sadly I fail to translate this into any kind of clojure -.-

13:02 pheep: is there also an example of the state thing in it?

13:03 Licenser: grid-bag example has states

13:04 This line: ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);

13:04 is a particular problem since I can't figure out how to do the typecast in clojure and sadly it really is needed

13:04 http://davidsit.wordpress.com/2010/02/10/reading-a-sharepoint-list-with-java-tutorial/ <- entire example

13:05 I kind of hoped that clojures reflections would solve the tyecasting but since port in this example is some kind of odd proxy class it fails horriblie

13:09 amalloy: Licenser: agreed that it shouldn't be necessary, but ##(doc cast)

13:09 sexpbot: ⟹ "([c x]); Throws a ClassCastException if x is not a c, else returns x."

13:09 amalloy: hm. that's not useful

13:09 Licenser: I googled like a crazy man but I did not find any way to force a cast in clojure

13:09 not even by typehinting stuff

13:14 Chousuke: hm, I thought typehinting should work in cases like those?

13:14 Licenser: Didn't for me, it called me out bla.bla.bla$Proxy doe not support function getRequestContext

13:22 I wonder if I've found something clojure has not covered yet -.-

13:23 sy`: Licenser: The nature of god!

13:26 Licenser: The nature of god is to find things not covered yet?

13:27 sy`: Licenser: Yes, for only the language of Lisp can discover it.

13:27 lol

13:27 Licenser: heh

13:28 pheep: what does this cast in java anyway? I can't find the documentation of the library.

13:30 Licenser: Yes it is horribly documented

13:31 pheep: because in my understanding of java it needs to be some down-cast and that should make no problems but maybe I'm wrong about the javapart. However - are you sure that you do get the right object, have you tried this example in java before?

13:31 Licenser: pheep: the service.getListsSoap() call returns some kind of proxy object

13:31 getRequestContext is a function of the BindingProvider interface

13:32 now that proxy class for some reason refuses to allow me to call getRequestContext on it

13:33 it is part of the whole java-ws thing I think

13:33 pheep: how would a proxy object be casted to another object, I thought there were no custom casts in java?

13:33 Licenser: pheep: I don't know

13:34 amalloy: Licenser: http://download.oracle.com/javase/1.3/docs/guide/reflection/proxy.html#methods maybe?

13:35 i've never seen anyone actually expose a proxy class to the public; i get the feeling it's a bad idea

13:36 Licenser: http://download.oracle.com/javase/6/docs/api/javax/xml/ws/Service.html#getPort(javax.xml.namespace.QName,%20java.lang.Class,%20javax.xml.ws.WebServiceFeature...)

13:36 that is the function creating it

13:39 proxies are evil but yes amalloy that is the rough point where to look

13:40 also the methods for the proxy don't seem to let you call a function -.-

13:56 pppaul: hey peoples!

13:58 i want to do side effects on a seq, using sh... i'm doing it with map and dorun (dorun (map (special effects...))) but it gives me back a list, i would rather not get anything back, what should i use inplace of map?

13:59 patrkris: ,(doc doall)

13:59 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is co...

14:00 patrkris: nevermind

14:00 spewn: ,(dorun (map #(* 2 %) (range 10)))

14:00 clojurebot: nil

14:00 spewn: ,(doall (map #(* 2 %) (range 10)))

14:00 clojurebot: (0 2 4 6 8 10 12 14 16 18)

14:00 spewn: pppaul: dorun shouldn't be giving back anything...

14:00 pppaul: um

14:01 it's giving me back (nil nil...)

14:01 i'm mapping something to a map of dorun

14:01 (map ( dorun (map

14:01 amalloy: pppaul: it's not giving you anything back

14:01 it may be printing several nils or something, but it's certainly not returning them

14:02 pppaul: yeah... ok, i guess that's good

14:02 :D

14:02 tscheibl: i had the same thought

14:03 ,(dorun (map #(println "haha" %) (range 10)))

14:03 clojurebot: haha 0

14:03 haha 1

14:03 haha 2

14:03 haha 3

14:03 haha 4

14:03 haha 5

14:03 haha 6

14:03 haha 7

14:03 haha 8

14:03 haha 9

14:03 tscheibl: oops... I'm evil

14:03 Licenser: yes

14:03 amalloy: &(dorun (map #(println "haha" %) (range 3)))

14:03 sexpbot: ⟹ haha 0 haha 1 haha 2 nil

14:03 rmarianski: good thing that was a 10 and not 100 :)

14:03 tscheibl: :)

14:03 amalloy: tscheibl: nah, clojurebot is evil :)

14:03 pppaul: should try 100

14:04 tscheibl: 10000000000000000

14:04 nah.. better 9999999999999999999

14:04 rmarianski: perhaps iterate inc?

14:04 pppaul: ,(dorun (map #(println "haha" %) (iterate inc)))

14:04 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$iterate

14:05 amalloy: you're looking for (range) :P

14:05 pdk: you have to pass an initial value after the fn to iterate

14:05 pppaul: ,(dorun (map #(println "haha" %) (infinity)))

14:05 clojurebot: java.lang.Exception: Unable to resolve symbol: infinity in this context

14:06 pdk: dude

14:06 pppaul: ,(iterate inc 0)

14:06 clojurebot: (0 1 2 3 4 5 6 7 8 9 ...)

14:06 pppaul: woo

14:06 pdk: ,(dorun (map #(println "haha

14:06 clojurebot: EOF while reading string

14:06 pdk: ,(dorun (map #(println "haha" %) (range))

14:06 clojurebot: EOF while reading

14:06 pdk: ,(dorun (map #(println "haha" %) (range)))

14:06 pppaul: ,(range)

14:06 clojurebot: Execution Timed Out

14:07 Execution Timed Out

14:07 pppaul: hmm

14:07 ,(dorun (map #(println "haha" %) (iterate inc 0)))

14:07 clojurebot: Execution Timed Out

14:07 pppaul: guess it wont work

14:08 ,(make pizza)

14:08 clojurebot: java.lang.Exception: Unable to resolve symbol: make in this context

14:09 tscheibl: (loop [] (recur)) ...

14:10 don't try that at home

14:11 don't you people have repls at home? :)

14:12 TimMc: heh

14:12 pppaul: i don't want my repl to be full of the shit i put in this chat

14:13 what if someone saw?

14:13 amalloy: tscheibl: my repl is always too busy computing (->> (range) (filter even?) (filter odd?) (first))

14:13 mefesto: do the bots watch out for loops like that?

14:14 or loops in general not allowed by them?

14:14 pppaul: ,(#(%)#(%))

14:14 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: sandbox$eval2053$fn

14:14 amalloy: mefesto: they timeout

14:14 &(->> (range) (filter even?) (filter odd?) (first))

14:15 sexpbot: Execution Timed Out!

14:15 pppaul: hmmm

14:15 the race is on!

14:15 mefesto: nice

14:15 pppaul: &(->> (range) (filter even?) (filter odd?) (first))

14:15 pdk: it tries to actually generate that infinite sequence before doing anything with it

14:15 pppaul: ,(->> (range) (filter even?) (filter odd?) (first))

14:15 sexpbot: Execution Timed Out!

14:15 clojurebot: Execution Timed Out

14:15 pdk: toss a take in there and you'd be fine

14:15 amalloy: pdk: what?

14:16 pppaul: on your marks, get set, go!

14:16 ,(->> (range) (filter even?) (filter odd?) (first))

14:16 &(->> (range) (filter even?) (filter odd?) (first))

14:16 sexpbot: Execution Timed Out!

14:16 clojurebot: Execution Timed Out

14:16 pppaul: winner!

14:16 tscheibl: botrace?

14:16 pdk: well rather

14:16 the filters just keep on chugging on the seq until it runs out of time

14:17 amalloy: pdk: there's a (first) at the end. that's equivalent to (take 1)

14:17 (for purposes of this discussion)

14:17 pdk: ,(filter even? (range))

14:17 clojurebot: Execution Timed Out

14:18 pdk: the first gets called after it's been run through two filters

14:18 and filters are the rub

14:18 the filters

14:18 amalloy: yes. so? those two filters are intentionally constructed to never return any elements

14:18 that's the joke

14:19 "find me the first even number that is also odd"

14:20 pppaul: actually, it reads find all even numbers, such that all odd numbers from those even numbers, give me the first one

14:20 i didn't know how to end that right

14:26 tscheibl: amalloy: your problem is solvable at infinity

14:26 amalloy: tscheibl: that's why i haven't killed my repl yet. i'm waiting for it to finish

14:27 tscheibl: amalloy: yeah that's science :)

14:28 pppaul: if someone runs that on their machine, will it seg fault or run forever?

14:28 tscheibl: it will segfault forever... lol

14:28 pppaul: is filter holding onto the head?

14:29 or range?

14:29 amalloy, you should try it

14:29 tscheibl: heak

14:29 heap

14:31 amalloy: pppaul: of course not. if filter and range hung onto the heads of their seqs laziness would be impossible like ever

14:33 pppaul: well, who's being lazy? the person who made filter or ranage, or the person who uses them?

14:37 amalloy: hm. i want a function that's not quite like distinct: constrain a list so that each element appears at most N times. i can roll my own with reduce, but that seems like overkill; does one exist?

14:45 if anyone is interested, i just wrote that at https://gist.github.com/ac577998a404164266aa

15:01 tscheibl: nice one

15:02 amalloy: tscheibl: now, go write a lazy version

15:10 markskilbeck: Is there a way to force clojure to output a complete number, not its scientific representation.

15:12 amalloy: markskilbeck: like a floating-point decimal number? don't use floating point if you want perfect accuracy

15:12 tscheibl: amalloy: nah... I'm far too lazy :)

15:12 markskilbeck: ,(* 5.63 (expt 10 7)

15:12 clojurebot: EOF while reading

15:12 markskilbeck: )

15:12 ,(* 5.63 (expt 10 7))

15:12 clojurebot: java.lang.Exception: Unable to resolve symbol: expt in this context

15:13 markskilbeck: Well, I'd like the complete number output. Possible, or not?

15:13 raek: markskilbeck: like this ##(double 1/3)

15:13 sexpbot: ⟹ 0.3333333333333333

15:13 raek: markskilbeck: or like this ##(format "%f" 1e9)

15:13 sexpbot: ⟹ "1000000000.000000"

15:13 markskilbeck: raek: ah. Thanks.

15:14 amalloy: &(format "%f" 1e30)

15:14 sexpbot: ⟹ "1000000000000000000000000000000.000000"

15:14 amalloy: neat

15:14 raek: &1e30

15:14 sexpbot: ⟹ 1.0E30

15:15 amalloy: &(format "%f" (+ 1e30 1e-30))

15:15 sexpbot: ⟹ "1000000000000000000000000000000.000000"

15:15 amalloy: you of course still can't get "complete" output

15:15 pppaul: anyone use lein and uberjar?

15:17 amalloy: wow, i just realized the amazing potential for bad code that comes from stuff like (let [inc (fnil inc 0)] ...)

15:17 pppaul: i'm getting errors when compiling my uberjar

15:18 let inc????

15:18 inc is defined already

15:18 amalloy: pppaul: yep, so?

15:18 raek: pppaul: what kind of errors?

15:18 amalloy: &(let [inc dec] (inc 10))

15:18 sexpbot: ⟹ 9

15:18 pppaul: can't find my main

15:19 in project: :main mkdirs.core)

15:19 and in that file: (defn -main [& args]...)

15:19 i tested it in my repl, and it works... when i build the jar it can't find my main

15:19 amalloy: it just happened i wanted to call inc on several things, and treat nils as if they were zero: (let [inc (fnil inc 0)]) solves my problem quite nicely, but it made me realize how horrible it could be if i redefined built-ins to things that are less clear

15:19 raek: pppaul: you have a namespace like (ns my-proj.main (:gen-class)) (defn -main [...] ...) and :main my-proj.main, :aot [my-proj.main] in the project.clj?

15:20 amalloy: raek: :main implies :aot for the main namespace, doesn't it?

15:20 pppaul: oh crap, i put my main too high in the file

15:21 raek: amalloy: hrm. it probaly does...

15:22 tscheibl: how can I check if a symbol exists without using exceptions?

15:22 amalloy: tscheibl: every symbol exists. you mean var?

15:22 &(resolve 'clojure.core 'test)

15:22 sexpbot: java.lang.SecurityException: You tripped the alarm! resolve is bad!

15:22 amalloy: ,(resolve 'clojure.core 'test)

15:22 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$resolve

15:22 raek: tscheibl: if there exists a var with that name in the curret namespace? 'resolve'

15:22 amalloy: you beat me to it... :)

15:23 ,(resolve 'clojure.core/test)

15:23 clojurebot: #'clojure.core/test

15:23 amalloy: raek: except i'm no good at it, apparently :P

15:23 raek: that returns nil if there is no such var

15:23 ,(resolve 'conj)

15:23 clojurebot: #'clojure.core/conj

15:23 tscheibl: ah coll.. works, thx

15:23 cool

15:23 raek: ,(resolve 'does-not-exist)

15:23 clojurebot: nil

15:32 mattmitchell: anyone know of a library that can parse a query string into a hash-map/vector?

15:33 i'm building a redirect string in a ring app

15:33 amalloy: mattmitchell: ring has a wrap-params middleware or something like that

15:34 mattmitchell: and in my tests.. i don't want to use regular expressions for every param

15:34 amalloy: i saw that but not sure how i could use that for my test

15:35 TimMc: ,(#(%1 %1) #(%1 %1))

15:35 clojurebot: java.lang.StackOverflowError

15:35 TimMc: That was *fast*.

15:35 &(#(%1 %1) #(%1 %1))

15:35 sexpbot: java.lang.StackOverflowError

15:36 TimMc: OK, my new #1 beef with Clojure is this error: "nth not supported on this type: Double"

15:36 ...Double being Point2D$Double. >_<

15:36 amalloy: TimMc: so stop trying to destructure Doubles

15:36 TimMc: :-P

15:36 amalloy: they're not clojure persistent objects

15:37 TimMc: Oh! No, what I mean is, I thought it was referring to j.l.Double

15:37 pppaul: anyone deal with shell-out?

15:37 TimMc: especially given that I can't import Double directly out of Point2D.

15:38 amalloy: TimMc: i believe there's something called import-static in contrib

15:40 pppaul: i'm using clojure.contrib.shell-out, works fine via swank, but when i make an uberjar it doesn't work anymore. only command i'm using is mkdir

15:42 * jweiss wishes for an "idiot mode" in the compiler which warns him when he does stupid things like name his function argument "map" or "meta"

15:43 pppaul: oh

15:43 that would break things bad

15:43 jweiss: well, it certainly breaks when i attempt to call map or meta in said function

15:43 raek: pppaul: sounds strange. also, there's clojure.java.shell since 1.2

15:44 pppaul: i looked at java.shell... i had problems with it.... i'll see about getting it working in my code

15:44 Licenser: anyone dealed with a Proxy yet?

15:48 pppaul: switched to clojure.java.shell... same problem

15:48 i tried doing (println (sh "mkdir" %))... and it prints nothing

15:49 puredanger: given a seq of maps, someone MUST have written a function that can sort the seq by a combination of fields in the maps. (sort-by :field maps) works great for one field and I will write the next step if I must but I will gladly re-use an existing one if I've missed it

15:49 jcromartie: LauJensen: does cql allow operations inside a transaction

15:49 pppaul: no dirs are made :(

15:49 it's like it's not even being called

15:50 amalloy: puredanger: ummmm, depending on what you mean by "sort by a combination of fields", you can (sort-by (juxt :field1 :field2) maps)

15:50 puredanger: amalloy: ah.... I was thinking comp and that it wouldn't work. got my brain on sideways

15:51 amalloy: puredanger: well, juxt won't put them in any meaningful order, i suspect, because (< [:a :b] [4 10]) won't sort well

15:51 but it's a start

15:52 puredanger: amalloy: yeah...

15:52 raek: pppaul: is the % a string?

15:52 pppaul: yes

15:52 my code works 100% in the repl

15:52 just not with lein run, or uberjar

15:53 raek: could it be a problem with laziness?

15:53 pppaul: ... how so?

15:53 it runs in the repl

15:53 raek: ,(do (map println ["one" "two" "three"]) :foo)

15:53 clojurebot: :foo

15:54 raek: the printlns are never evaluated

15:54 pppaul: (->> dir-strs

15:54 (map #(sh "mkdir" %))

15:54 dorun))

15:54 that's my code for making dirs

15:55 raek: and if you replace dorun with pr, what is printed?

15:55 LauJensen: jcromartie: technically it should work with contrib.sql/transaction, but Ive had some issues with it, so hang on until I announce dbsync on twitter

15:55 pppaul: nothing

15:56 raek: it should print something... at least "()"

15:56 jcromartie: LauJensen: I ask because we have many constraints in our existing DB, and it's hard to manage some inserts without transactions

15:56 although it should be possible as long as they are in the right order

15:56 amalloy: pppaul: (apply sh "mkdir" dir-strs) seems like an easier way to do it

15:56 raek: pppaul: I suspect the problem lies at some point outside the ->> form

15:56 LauJensen: jcromartie: I understand. Take a look at contribs transaction, rewrite it for CQL and send me a patch and I'll be happy to merge it as soon as I get the time

15:56 jcromartie: :P

15:57 LauJensen: jcromartie: make sure that you add some tests and run 'cake test --integration=true' before you submit

15:57 pppaul: i just changed my code to use clojure.java.shell... i don't know if that is breaking things

16:01 the java.shell isn't working like contrib.shell-out

16:01 :....(

16:06 got it working in the repl again

16:08 simard: how can I do this, but correctly ? (binding [*out* (System/out)] (prn "test"))

16:08 ie.. java.io.PrintStream cannot be cast to java.io.Writer

16:09 zztr: simard: bind prn instead?

16:09 mefesto: (binding [*out* System/out] ...)

16:09 brehaut: simard: with-out-str, with-out-append-writer, with-out-writer perhaps ?

16:09 mefesto: simard: you are trying to execute System/out as a function

16:10 ugh, also needs to be a writer, not a PrintStream?

16:11 brehaut: perhaps have a look at clojure.java.io ?

16:13 mefesto: (binding [*out* (io/writer System/out)] (prn "test"))

16:13 where io is clojure.java.io

16:13 also, *out* points to System/out by default, doesn't it?

16:14 raek: you might need to wrap the the writer in a PrintWriter: (PrintWriter. (io/writer System/out :encoding "UTF-8"))

16:14 simard: mefesto: thanks, but no, not when "lein swank"

16:14 octe: i'm transforming some ugly nested json to a string and i got this code: http://paste.lisp.org/display/119936

16:14 but it looks pretty ugly

16:14 maybe there's a better way?

16:15 mefesto: simard: when i use that in slime-repl with the binding it prints to console where i launched lein swank

16:15 raek: hrm. (alter-var-root #'*out* (fn [out] (def the-root-out out) out))

16:16 simard: mefesto: yes, it's working now with the binding

16:16 thanks

16:16 mefesto: simard: without the binding it prints within slime-repl

16:17 simard: I have a slime-repl right now

16:18 I M-x slime-connect and all I have is a *slime-events* buffer

16:18 (and I see the result of evaluations in the minibuffer)

16:19 "I have a slime-repl right now" should have been, I don't have a slime repl

16:19 mefesto: hmm, when i slime-connect i get a *slime-repl clojure* buffer

16:19 simard: hmm<

16:20 mefesto: I'm using clojure 1.2 and swank-clojure 1.3.0-SNAPSHOT

16:21 simard: mefesto: me too, maybe it's my slime version

16:21 I'll try to update it first

16:24 pppaul: using java.shell fixed my problem, thanks

16:25 amalloy, i'm using (apply (partial sh "mkdir") dir-strs) thanks for the suggestion

16:25 simard: mefesto: you don't use inferior-lisp-program do you, it's really a slime-connect to lein swank ?

16:27 pppaul: so, when i run my uberjar, the program doesn't finish executing. is there something like (exit) that i need to use?

16:27 simard: mefesto: updating my slime did the trick

16:27 pppaul: i tried ending my main function with 0, but that did nothing

16:28 puredanger: pppaul: no, do a thread-dump and see what's left (ctrl-break on win, ctrl-\ on *nix)

16:28 pppaul: thanks

16:28 puredanger: pppaul: if you're using agents, the thread-pools are non-daemon threads and prevent exit, you'll need a call to (shutdown-agents)

16:29 pppaul: i'm not using agents

16:29 not doing anything fancy in this program

16:30 just some string manip, and calls to shell

16:30 i don't really understand the output of the threaddump

16:32 mefesto: pppaul: if you want to force exit you can use (System/exit retcode)

16:32 pppaul: ok, i'll do that

16:32 thanks

16:33 mefesto: pppaul: maybe that shell lib leaves a thread or process running?

16:34 pppaul: hmmm

16:34 maybe

16:34 system/exit isn't working

16:34 mefesto: (System/exit 0) hangs?

16:34 pppaul: yup

16:35 unless lein isn't running my new code that i saved

16:35 oops

16:36 forgot to remake the jar

16:36 works! :D

16:36 thanks a lot

16:36 mefesto: sweet :)

16:36 pppaul: what shell lib are you using?

16:37 pppaul: clojure.java.shell

16:37 mefesto: c.c.shell ?

16:37 oh ok

16:37 pppaul: it's more sophisticated than clojure.contrib.shell-out... but i don't use it's features

16:59 mattmitchell: hello?

19:27 kcl: exit

19:50 Derander: my fingers are cold

19:51 amalloy: Derander: write some php. all the typing should warm you up

19:51 TimMc: amalloy: Pssh, PHP? Java is the ticket.

19:51 Just don't use autocompletion.

19:52 amalloy: java is verbose, but it's not full of completely unnecessary $ and -> tokens

19:53 Derander: JustLotsOfGoofyTypeNamesThatAreReallyLongAbstractFactoriesConstructorMachines

19:56 brehaut: Derander: i've never seen java code that looks like that. Its always <OvrlySpfcNs:ApproximationOfALongClassname withSomeVerbose="attributes"><pojo:Param name="blah blah"><…

19:56 Derander: oh right, of course.

19:56 heh. microsoft hungarian is fun too

20:26 tscheibl: (cljs (on-ready

20:26 (-> (js* ($ "body"))

20:26 (#(js* (.append (clj %) (.text ($ "<div>") "HUHU") )))

20:26 (#(js* (.append (clj %) (.text ($ "<div>") "HAHA") ))))))))

20:27 hmm... that's not really more readable than pure javascript+jQuery...

20:27 it's scriptjure. btw

20:30 I'll go to bed now... it's 2:30 AM, bye

22:22 Sgeo_: I asked yesterday, but I don't think I got a response. How's Clojure-on-Clojure going?

22:27 Clojure has no continuations? That's no fun

22:28 spewn: Sgeo_: I haven't taken the time to read this yet, but http://dosync.posterous.com/continuation-passing-style-in-clojure

22:28 Sgeo_: What happened to Try Clojure?

22:43 Is it reasonable to like Clojure for everything except the Javaness, and despite that part?

22:43 And certain ... consequences of that

22:44 pdk: entirely

22:44 you're trying to have a full fledged lisp coexist with a language that well

22:44 yknow

22:44 brought us primitive boxing

22:45 Sgeo_: I once asked in #scala if learning Scala was reasonable given lack of interest in JVM compatibility. They said no, due to the compromises that Scala had to make

22:45 Or well, one person said no

22:46 pdk: scala's type system is probably more advanced than java's at any rate

22:47 Sgeo_: A criticism I've seen of Scala is that it's like a modern C++... just a lot of bolted on features

22:47 They made the same criticism of Falcon, I think, except stronger

22:47 They pretty much actively made fun of Falcon

22:48 pdk: falcon doesnt ring a bell

22:48 Sgeo_: http://falconpl.org/

22:48 I am not responsible for any brain-damage

22:55 tomoj: it's hard to take the language seriously with a website like that

22:58 Scriptor: the language isn't *too* bad

22:58 er

22:58 the *website

22:59 for one thing, it actually provides example code ;)

22:59 tomoj: reading some of the examples is enough to make me want to keep reading even though the website is terrible

23:01 right, it's not too bad

23:02 the curve of actual design quality vs. take-serious-ability is steep

23:04 Scriptor: best to go with minimalism, for langs

23:04 tomoj: I can't even come close to pulling off minimalism :(

23:04 Scriptor: just follow io's site :)

23:05 Sgeo_: I'm kind of excited about Seph

23:06 tomoj: even they have a FOUC

23:07 though.. github is currently totally unstyled and unusable in my browser

23:10 * Sgeo_ quickly checks something about map and filter

23:10 Sgeo_: :(:(

23:11 (-> somecol (partial filter sometest) (partial map sometransform))

23:12 Those partials are somewhat ugly

23:12 amalloy: Sgeo_: and also not doing what you want

23:12 Sgeo_: And yeah, sure, it could be written (map sometransform (filter sometest somecol))

23:12 amalloy, hmm?

23:12 amalloy: try it

23:13 &(macroexpand-all '(-> somecol (partial filter sometest) (partial map sometransform)))

23:13 sexpbot: ⟹ (partial (partial somecol filter sometest) map sometransform)

23:14 amalloy: you *could* do it with -> and partial if you wanted, but that's crazy. instead you want ##(macroexpand-all '(->> somecol (filter sometest) (map sometransform)))

23:14 sexpbot: ⟹ (map sometransform (filter sometest somecol))

23:15 amalloy: c'est bon?

23:16 bartj: If I have a (def blah ["x" "y"])

23:17 and I refer blah through out the code

23:17 now, I require blah to be called as a function

23:17 is this possible to do in Clojure ?

23:18 amalloy: bartj: huh? you just write (blah 0), which results in "x"

23:20 Sgeo_: amalloy, I'm confused

23:21 Oh, "second item" vs "last item"

23:21 amalloy: indeed. and you probably want to understand why your partial-based solution doesn't work

23:22 Sgeo_: Because it makes (map somecol sometransform) and (filter thatmap sometest) instead of what I want?

23:23 amalloy: no, that's what would happen if you used -> without any partials

23:23 bartj: amalloy, wrong question

23:24 amalloy: (-> foo (partial bar baz)) turns into (partial foo bar baz), *not* an invocation of (partial bar baz) with argument foo

23:24 Sgeo_: Oh, I don't need (or want) partial at all????

23:24 So forms, not functions

23:24 amalloy: indeed

23:24 Sgeo_: That's rather convenient

23:25 amalloy: that's the idea :)

23:25 Sgeo_: And if I wanted to use a named function, nothing wrong with () around it I guess

23:25 amalloy: Sgeo_: you don't have to at all

23:25 &(-> 1 inc inc inc)

23:25 sexpbot: ⟹ 4

23:26 Sgeo_: What if I want to include forms some of which should have their second position filled in, some of which their last?

23:27 amalloy: &(macroexpand-all '(-> foo (bar 1) (->> (baz 10))))

23:27 sexpbot: ⟹ (baz 10 (bar foo 1))

23:27 Sgeo_: I missed anyhing after Sgeo_> Or what if I want to fill in the third position?

23:28 amalloy, hah

23:28 What about the inverse? Or again, what about third position

23:28 amalloy: um, i don't understand what you mean by inverse, and you really don't want to put things into the third position :P

23:29 use (let) for your temporary bindings to make that kind of stuff more explicit

23:29 Sgeo_: Most of the things needing stuff inserted last, but something in the middle needing it inserted second

23:29 I see how ->> inside -> works, but the other way around shouldn't

23:29 afaict

23:30 amalloy: it won't

23:31 you can either use one -> and a lot of ->>s, or use let, or if you don't mind some pain, (->> foo (map baz) (filter bar) (#(swap! % inc)))

23:32 Sgeo_: Ok, I think I'll stay away from the painful alternative

23:33 Given that I don't understand it

23:33 (fn [x] swap! x inc)

23:33 OH

23:33 I get it

23:33 Since that () form contains the function, and it's.. I get it

23:34 Although maybe some function other than swap! would have been nice >.>

23:52 sritchie: does anyone have experience with crane, or pallet, for managing hadoop clusters/

23:52 ?

23:54 hugod_: sritchie: pallet doesn't have a working crate for hadoop yet - I would be willing to help get one going though - it's been on the todo list for a long time

23:55 sritchie: hugod_: that's definitely something I'd be interested in helping with

23:56 hugod_: I've got a cascading app that I need to get running on EC2 this week -- I'll start looking around pallet

23:57 hugod_: sritchie: the crate I started is here https://github.com/pallet/pallet-apache-crates

23:57 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.Exception: 503>

23:58 bartj: .quit

23:58 sritchie: hugod_: great, forked

23:58 hugod_: hope I can be helpful, here!

Logging service provided by n01se.net