# #clojure log - Jul 28 2010

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

0:00 daaku: wwmorgan: aww.. i kept searching for clojurerc -- that's probably what i want

0:00 seancron: Does anyone have any suggestions on using agents to look up hosts repeatedly?

0:42 slyrus: one of the things that I often misabuse ASDF for is the location of project-relative files (data files, etc...). How can I locate a file relative to some directory that's on the CLASSPATH?

0:45 tomoj: (.getResource (clojure.lang.RT/baseLoader) "<CLASSPATH-relative filename>")

0:46 or (.getResourceAsStream ...)

0:46 slyrus: thanks tomoj

0:49 ah, that and a lein resources directory and I'm good to go. great!

1:27 gstamp: hrmm. hash-combine doesn't have a doc string. I assume it creates a new hash from two existing hashes?

1:55 dublindan: http://clojure-games.org (a very very early work in progress)

2:35 slyrus: ok, name me two actors/actresses

2:36 ttmrichter: slyrus: Aishwarya Rai, Steve Buscemi.

2:36 (I would pay loads of money to see those together in a movie.)

2:37 slyrus: ("Steve Buscemi" "Things to Do in Denver When You're Dead" "Andy García" "The Pink Panther 2" "Aishwarya Rai")

2:38 not in a movie together, but close...

2:39 ttmrichter: So why did you want two actors/actresses?

2:39 slyrus: (map :name (graph/find-node *actor-film-graph* (get-actor-node "Aishwarya Rai") (get-actor-node "Steve Buscemi")))

2:39 my kevin-bacon-solver

2:39 ttmrichter: A six degrees of Kevin Bacon with movie stars?

2:39 slyrus: yeah

2:39 ttmrichter: Dammit!

2:39 slyrus: freebase

2:40 100k movies, 75k actors, or so.

2:40 ttmrichter: OK, let's see if I can't break it.

2:40 Peter Falk and Bipasha Bipu

2:41 Doris Day and Faye Wong

2:42 slyrus: ("Faye Wong" "2046" "Takuya Kimura" "Howl's Moving Castle" "Lauren Bacall" "Young Man with a Horn" "Doris Day")

2:42 ttmrichter: Damn!

2:42 slyrus: unfortunately, the Peter Falk search turned up empty...

2:42 ttmrichter: Hah!

2:42 NOBODY stars with Peter Falk!

2:42 Except through Columbo!

2:42 Where everybody stars with Peter Falk! :D

2:42 absalom: Mikhail Gorbachev did...

2:43 slyrus: well, that's not true, it's just that Bipasha Bipu isn't in there.

2:43 is the spelling right?

2:43 ttmrichter: Oh.

2:43 I... think so?

2:43 Let me check.

2:43 slyrus: ("Peter Falk" "The Thing About My Folks" "Olympia Dukakis" "The Great New Wonderful" "Naseeruddin Shah" "Dus Kahaniyaan" "Bipasha Basu")

2:43 basu?

2:43 Basu.

2:44 slyrus: the ya go

2:44 s/the/there/

2:44 sexpbot: there ya go

2:44 ttmrichter: Gong Li and Charlie Chaplin.

2:45 slyrus: ("Charlie Chaplin" "A King in New York" "Phil Brown" "Johnny Kapahala: Back on Board" "Cary-Hiroyuki Tagawa" "Memoirs of a Geisha" "Gong Li")

2:46 ttmrichter: Man, that's shorter than I expected.

2:46 I guess that goes to show how inbred the movie industry is, right?

2:47 Chousuke: what happens if it can't find a connection?

2:47 slyrus: yeah, don't ask me to run the graph-distance-matrix to compute all pairwise distances though :)

2:47 Chousuke: the universal no connection answer, the empty list :)

2:47 Chousuke: heh

3:05 LauJensen: Good morning all

3:07 unfo-: morning LauJensen

3:16 slyrus: if anyone wants to try out cinematograph, it's here: http://github.com/slyrus/cinematograph

3:28 or you can just keep throwing pairs of actors/movies at me and I'll tell you how they're connected :)

3:28 ragnard: (doc declare)

3:28 clojurebot: "([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

3:29 ragnard: sorry, missed the repl

4:41 raek: does anyone know what seqs are chunked?

5:45 cais2002: hi, is there a quick guide on how to create my own task for leiningen?

5:49 this is what I know of

5:51 raph_amiard: Hi there

5:51 i want to know, if i want simple syntax highlighting for clojure in vim

5:51 i don't want slimv nor vimclojure/gorilla

5:51 in my opinion they are complicated and way too big and buggy for my tastes

5:52 what are my options ?

5:54 cais2002: raph_amiard: I am using vimclojure and mainly just for syntax highlighting and Ctrl+N for autocompletion. you can ignore those adv features

5:55 raph_amiard: yeah well you're probably right

5:56 but i find installation to be seriously horrible but i guess i can just grab the vimclojure's syntax file ?

6:01 bonega: Hi - Can anybody share some good thoughts regarding -> and ->>

6:01 I understand the usage - but have a hard time deciding when it's appropriate

6:02 I am using Forth in my job - so I am a bit damaged...

6:02 raek: (f1 a (f2 c (f3 e (f4 x) f d) b) <--- not very readable

6:03 bonega: Try working in forth ;)

6:03 Nah - more if there exists some consensus at what complexitivity level it becomes appropriate

6:03 raek: bonega: if you know forth then I don't have to explain why the -> syntax is no neat...

6:04 if the code looks simpler and more readable, go for it

6:05 bonega: yes ty - I am only worried for the ones that have to work with my code...

6:05 raek: imo, you should expect clojure programmers to understand ->

6:06 it might be overkill to use it for just 2 forms, but for 3 or more I don't see why it should be bad

6:08 bonega: I hate having to base my decisions on what feels right :(

6:09 raph_amiard: You should really use a editor that is parens aware and have REPL integration

6:09 I am a vim user myself, but couldn't seem to get vim setup right for Clojure

6:09 So for the moment I am using Eclipse and Counterclockwise

6:10 bartj: bonega, having tried vim to get working with Clojure for nearly 6 months, and using it - I know it is highly frustrating

6:10 bOR__: stupid simple question. If I want a global var to return a new random number (def myvar (rand)), how should I write it?

6:10 cais2002: raph_amiard: I just followed the instructions and ignored the ng server related stuff

6:10 bartj: bonega, my best suggestion to you is to use emacs - paredit, etc just rocks

6:11 bonega: I have no time learning another OS ;)

6:11 bOR__: (def myrand (first (take 1 (repeatedly #(rand))))) doesn't seem to work :).

6:12 raph_amiard: bonega: I used emacs for 1 year for clojure

6:12 bonega: still hate it in the end though

6:13 bonega: but the lisp integration is wonderfull

6:13 i guess i'm gonna try emacs with vimpulse

6:13 maybe it'll be enough

6:14 bOR__: I'll just go for (defn myvar [] (rand))

6:14 bonega: That's an abomination

6:14 bOR__: would have liked a dev solution.

6:14 def.

6:15 Nikelandjelo: bOR__: (def myvar (fn [] (rand) ) )

6:15 raek: bOR__: your first example always gives the same value

6:16 it evalueates (first ...) and binds that value to the var

6:16 bOR__: raek - that I noticed.

6:16 bonega: please don't call it something like myvar - it's still a rand function

6:16 bOR__: bonega - it is just a simple example of something else.

6:16 bonega: roger

6:17 raek: bOR__: how do you want to use it?

6:17 Lajla: ,

6:17 clojurebot: Lajla: Excuse me?

6:17 bOR__: was using iterate to generate a stream of a certain process, noticed that the x in the iterate function would stay the same if I did a (def myvar (iterate (partial + 2) (rand-int 10)))

6:18 raek: rand-int is only called once

6:19 bOR__: raek - yes, but how can I get it to be called each time I look up the def?

6:19 Lajla: raek, I long to consume your mortal soul.

6:19 bOR__: (count (take-while (partial some #(= (:rat %) :healthy)) burrow-stream)) is what I'm using it for.

6:20 counting the time till a whole gerbil burrow is infected with the plague ;).

6:20 raek: bOR__: you wrap everything in a defn insead

6:20 bOR__: *nod*, that was my solution.

6:20 raek: functions run code, values are fixed

6:20 bOR__: was wondering if there was a way to def it.

6:20 good point.

6:21 raek: this could be of use maybe: (defn make-rand-int-seq [] (repeatedly rand-int))

6:22 (let [a-rand-seq (repeatedly rand-int)] [(take 4 a-rand-seq) (take 7 a-rand-seq)])

6:22 ,(let [a-rand-seq (repeatedly rand-int)] [(take 4 a-rand-seq) (take 7 a-rand-seq)])

6:22 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$rand-int 6:22 raek: ,(let [a-rand-seq (repeatedly #(rand-int 10))] [(take 4 a-rand-seq) (take 7 a-rand-seq)]) 6:22 clojurebot: [(4 5 4 4) (4 5 4 4 2 3 8)] 6:22 raek: then multiple processes can share the same sequence of random numbers 6:22 bOR__: thanks raek, but iterate is the one I wanted. put an infected flea in a burrow with rats, process a timestep, process another timestep on the result of the first process, etc. 6:23 serp_: ,(take 5 (repeatedly (partial rand-int 10))) 6:23 clojurebot: (0 9 9 3 2) 6:23 bOR__: ah, raek - yep. 6:25 Lajla: serp_, my beloved, I've crossed oceans of time to be with you. 6:28 zmila: ,(bit-not 65535) 6:28 clojurebot: -65536 6:51 raph_amiard: Re here 6:51 i'm trying to make slime work with liebke's cljr swank command 6:51 but i'm hitting a wall :/ 6:51 "make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005" 6:52 when i launch "cljr swank 4005", it's just hanging in there so i imagine it's working 6:55 raek: i haven't used cljr, but when you start swank in other ways (from the repl, or with lein swank, etc) it usually prints a line that says that it is listening on a port 6:55 raph_amiard: okay 6:55 i have got no such line, nothing at all. 6:56 that means few debug information too .. 6:56 raek: try connecting to the port with telnet or something to check if there is something listening 6:56 raph_amiard: good idea 6:56 i'm also maybe gonna try starting a swank server with leiningen 6:56 to see if it works there 6:57 raek: what is cljr, btw? a packet manager? 6:57 raph_amiard: well it is a very cool project from liebke, the guy who does incanter 6:58 raek: ah, read on the project page 6:58 raph_amiard: http://github.com/liebke/cljr 6:58 basically it's a clojure environnement for things that don't fit in the leiningen project model 6:58 raek: to make starting a repl for things that are not projects easy, right? 6:58 raph_amiard: yeah exactly 6:58 raek: neat 6:59 raph_amiard: yeah also the ability to install libs system wide is very cool 7:00 raek: well, now clojure has the best of both worlds, then... 7:00 raph_amiard: so much of my activity with clojure is fast scripting, testing out ideas 7:00 yeah i hope 7:00 i don't know leiningen so well though 7:00 but it seems really good 7:02 yeah well i think cljr swank server is not working 7:08 raek: :( 7:43 gfrlog: can I access a public instance variable of a java object in clojure? Or does there have to be a method to call? 7:45 raek: (. instance field) 7:45 gfrlog: works perfectly, thanks 7:45 rhudson: I think (.field instance) works too 7:46 gfrlog: oh geez it does 7:46 I thought I had tried that 7:46 but I actually hadn't 7:47 raek: yeah, the (.field instance) is probably preferred 7:48 all of this is documented here: http://clojure.org/java_interop 7:48 gfrlog: thanks; I'm mostly familiar with the interop. Just don't deal with public variables often 7:49 raek: ok. yeah, setters and getters are more common 7:49 if it has getters, consider using bean 7:49 gfrlog: right 7:50 I found a bug in bean actually; at least in older versions (I think 1.1?) 7:50 raek: oh 7:50 what does it do? have you created a ticket? 7:51 gfrlog: should I check it on the master branch before creating a ticket? 7:51 bean returns a map 7:51 and if you try to access a nonexisting key it throws an NPE 7:51 I assume that's a bug 7:51 chouser: it's on master, but I'm not sure if it's a bug. 7:51 gfrlog: there's certainly no warning about it in 7:52 (doc bean) 7:52 clojurebot: "([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties." 7:52 chouser: you can give a "notfound" value to return... 7:52 hm 7:52 gfrlog: you can? 7:52 (bean 128 99) 7:52 ,(bean 128 88) 7:52 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$bean

7:52 chouser: , (:foo (bean Object) :bar)

7:52 clojurebot: :bar

7:53 gfrlog: yes but

7:53 ,(:foo {})

7:53 clojurebot: nil

7:53 gfrlog: why would we want different behavior?

7:54 ,((bean "jokes") :foo :bar)

7:54 clojurebot: :bar

7:54 chouser: ,(:foo (assoc (bean Object) :a :b))

7:54 clojurebot: java.lang.reflect.InvocationTargetException

7:54 gfrlog: that's fine because the docs say it's read-only

7:54 chouser: huh. that returns nil for me

7:54 ,(:a (assoc (bean Object) :a :b))

7:54 clojurebot: java.lang.reflect.InvocationTargetException

7:55 chouser: and that returns :b

7:55 gfrlog: what version are you using?

7:55 chouser: gfrlog: you're probably right that it's a bug. best to start by mentioning it on the google group.

7:55 gfrlog: some recent master.

7:56 gfrlog: does your recent master throw the NPE as well?

7:56 chouser: yes

7:56 gfrlog: okay

7:56 I'll try the google group, but last time I tried posting it never got there

7:56 is there some extra registration process I'm unaware of?

7:57 chouser: hm, no -- your first few posts should be held in a queue until manually approved (to reduce spam) but no other registration.

7:58 gfrlog: hmm

7:58 okay

7:58 I guess my post wasn't clever enough

7:58 chouser: heh

7:58 gfrlog: ,(bean Object)

7:58 clojurebot: java.lang.reflect.InvocationTargetException

7:59 gfrlog: ,(bean (Object.))

7:59 clojurebot: {:class java.lang.Object}

7:59 chouser: ah

7:59 ,(:foo (assoc (bean "") :a :b))

7:59 clojurebot: nil

7:59 chouser: ,(:a (assoc (bean "") :a :b))

7:59 clojurebot: :b

7:59 gfrlog: your clojure lets you call bean on a class?

7:59 chouser: yup

7:59 gfrlog: ,(assoc (bean "") :a :b)

7:59 clojurebot: {:a :b, :bytes #<byte[] [B@1f1df3f>, :class java.lang.String, :empty true}

7:59 gfrlog: I wonder what "read-only" means

8:00 chouser: you can't call setters of the bean object

8:00 gfrlog: okay, so it doesn't mean anything important in clojure, just if you were thinking of doing fruity java things with it?

8:00 chouser: I think so, at least that's how I read it.

8:01 and since the thing bean returns allows assoc, I don't see how someone could justify the NPE at all.

8:01 gfrlog: yeah

8:02 ,(:haha (assoc (bean "") :a :B))

8:02 clojurebot: nil

8:02 rhudson: ,(class (assoc (bean "") :a :b))

8:02 clojurebot: clojure.lang.PersistentArrayMap

8:03 gfrlog: ,(class (bean ""))

8:03 clojurebot: clojure.core.proxy$clojure.lang.APersistentMap$0

8:09 rhudson: Hmm. The implementation's creating a map of accessor functions 'pmap , then just indexing on 'k as ((pmap k)). No entry for k => NPE

8:15 gfrlog: I don't suppose you can compile java code from within clojure can you?

8:16 bortreb: grflog: sure, use something like lancet

8:16 gfrlog: okay, I'll look into it, thanks

8:17 bortreb: examples are a little thin right now so if you want a working example i can send you one

8:17 gfrlog: I can't object to that

8:17 raek: I guess you could also run a leiningen plugin from clojure

8:17 gfrlog: I've never dynamically compiled java code from java even, so I'd have similar questions there

8:25 bortreb: ok, I packed up a project I'm working on at www.rlmcintyre.com/probes.tar.bz2 for you

8:25 gfrlog: cool, thanks!

8:26 bortreb: it also shows how to use clojure as a command line script

8:26 just unpack it and change the shebang line on the quake file at the base, then run "quake -c"

8:27 question: I want to sign the contributor agreement, but how do I fill out the form

8:30 like, do I put under project name, github? or clojure-contrib? help pls...

8:30 gfrlog: you also have to change quake-conf too, sorry

8:36 raek: bortreb: project name should be "clojure", "clojure-contrib" or both

8:37 lozh: Anyone know if emacs/slime/paredit has something to comment out the top level form your point is in?

8:37 raek: some of the things listed on the page didn't have their own fields, so I wrote them on a blank space on the paper

8:37 bortreb: but it also says to include your assembla and github usernames, so how would he know which is which?

8:38 oh ok

8:38 gfrlog: botreb: I think your server has stopped responding

8:38 raek: I wrote something like "github username: raek" "assebla username: raek"

8:38 bortreb: oh noes maybe wget -c ? let me look for a sec

8:38 raek: this form will not be read by a machine

8:39 gfrlog: I also tried loading it in a browser initially, and that didn't work either

8:39 raek: so, anything a human can understand will do, I suppose

8:39 bortreb: yeah, I'm being silly

8:41 raek: well, the form does not contain all fields...

8:42 bortreb: maybe a pdf on the website showing one acceptably filled out would allievate confusion

8:43 wow my server actually did crash

8:45 gfrlog: and just now wget retried so many times that it just spit out "Giving up." and stopped

8:46 bortreb: server's back

8:46 gfrlog: also for some reason after each try it said "probes.tar.bz2 has sprung into existence." -- I'm not sure what that means

8:46 and it's done

8:46 thanks

8:47 bortreb: see ya

9:35 brandonw: hmm

9:35 oh i think i have been unbanned :)

9:36 i tried an auto-away message script that monitors your screen session. apparently that creates some kind of spam and i was temp-banned from this channel

9:40 raek: welcome back

10:05 brandonw: unless technomancy worked his magic and somehow got me unbanned :)

10:23 eckroth: I don't want "patterns" in my code, but I find myself doing this alot (for records): (assoc this :xs (conj (:xs this) x)) ; is there a shortened version of this, and do others do this often as well?

10:24 ztellman: (update-in hash [:xs] #(conj % x))

10:26 eckroth: ztellman: ah perfect, thanks

10:26 ztellman: eckroth: no problem, I always thought that was really awkward until I discovered update-in

10:26 eckroth: ztellman: exactly

10:28 chouser: ,(update-in {:a [1]} [:a] conj 2)

10:28 clojurebot: {:a [1 2]}

10:28 mefesto: does it also work w/out the annonomus func?

10:28 chouser: you don't need the anon fn

10:28 ztellman: chouser's right

10:28 I always use anonymous functions, but that's a bad habit

10:36 rbe: hi

10:37 can someone point me to a documentation for &v (without space) please?

10:37 lozh: slighly unfortunate that #(fn x %) is shorter than (partial fn x)

10:40 rbe: ,(binding [a 111] (let [[&a b] [1 2]] (list a b)))

10:40 clojurebot: java.lang.Exception: Unable to resolve var: a in this context

10:40 rbe: this works in clojure 1.2

10:40 (111 2)

10:41 eckroth: chouser: thanks; right after I replaced the pattern with update-in, your comment let me delete a lot of #(... % ...) :)

10:41 chouser: :-)

10:41 raek: ,(binding [a 111] (let [[& a b] [1 2]] (list a b)))

10:41 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form, only :as can follow & parameter

10:42 raek: nevermind

11:00 Bahman: Hi all!

11:00 Lajla: Ahh, Bahman, my one true love, let me worship Your Shadow.

11:03 * ttmrichter eyes Lajla and Bahman.

11:03 Lajla: ttmrichter, ahh, my one true love, never did I love one such as I do you.

11:03 ttmrichter: Keep it down! My wife's like two feet away from me!

11:06 Lajla: ttmrichter, ah, your wife, my one true love, never had I loved one such as I love her.

11:25 tashafa: hello all

11:25 wakko10warner: does anyone here know how to get bobot++ to run with free node.

11:26 I think that bobot++ allows lispy scripting and I want to use it.

11:26 cemerick: tashafa: my gawd, he's got voice! ;-)

11:27 wakko10warner: ,(println "help wakko with bobotpp")

11:27 clojurebot: help wakko with bobotpp

11:29 tashafa: cemerick: finally figured it out

11:32 dnolen: lancepantz: ping

11:32 cemerick: heh

11:35 tashafa: entirely tangentially: "[Emacs crashed opening the large file.] The file opened quickly on Windows, even my 32-bit XP box, using Notepad++." http://www.johndcook.com/blog/2010/07/28/miscellaneous-emacs-adventures/

12:01 tashafa: cemerick: ha

12:39 jfields: ,(do (defn x [{y :k} {z y}] z) (println (x {:k :v} {:v :s})))

12:39 clojurebot: DENIED

12:41 raek: ,(let [x (fn [{y :k} {z y}] z)] (println (x {:k :v} {:v :s})))

12:41 clojurebot: :s

12:44 bortreb: So I've been trying to get clojure to work as a command line scripting language for some time

12:44 and finally came up with this pun that gets it to work

12:45 Raynes: -> (def x (fn [{y :k} {z y}] z))

12:45 Raynes: -> (println (x {:k :v} {:v :s})))

12:45 sexpbot: => :s nil

12:45 bortreb: ":";exec java -cp '.:./lib/*' clojure.main $0$*;

12:45 what do you guys think?

12:45 just replace the #! with ":"; and everything works

12:46 I got the idea from http://www.emacswiki.org/emacs/EmacsScripts

12:46 I dunno what works best

12:46 jfields: raek, you got the idea for what I was trying to do

12:47 I'm destructuring once and using the result to destructure again, is that insane or expected?

12:47 I'm deciding if I want to do that in my prod code.

12:47 raek: but I guess this has ben thunk upon before

12:49 btw, that example is a bit outdated... clojure.lang.Script is not used anymore

12:49 bortreb: using a #!/usr/bin/env clj directly is lame because you have to have your own clj executable

12:50 and using #!/usr/bin/env java args just doesn't work at all under ubuntu since you can only put one argument on the shebang line

12:51 their rediculous three line thing works but is equivalent to my ":";

12:51 jstirrell: test

12:54 bortreb: should I add it to the wiki or is it bad ?

13:01 jstirrell: Hi guys, I'm new and have a question: I have a sequence of hash maps. each hash has a :type. the first hash in the sequence has a type :date. after that there are any number of :time and :text types (a :text type will always be paired with a :time type but the occurence of :date is unpredictable). I need to process all these so I end up with a collection of structs which each contain a :date :time and :text. Any hint

13:01 s on how I might go about doing this? I initially tried using a loop but that no longer seems like the way to go

13:04 bortreb: can you give an example?

13:04 nickik: I don't get what you want to do with this data

13:04 yeah plz

13:06 jstirrell: shure

13:07 I'm parsing an html page which has a number of messages on the page

13:07 I end up with a bunch of hashes, each with a type corresponding to a div on that page

13:08 pdk: hm can you try pastebinning the code with some sample data to run it on that doesn't reveal anything secret about the project

13:08 jstirrell: sure (nothing's really secret, just trying to make it as easy as possible to explain :)

13:17 ok so that is just the printed seq i'm working with

13:17 the first represents the date (and time but i don't need the time here)

13:19 after that the seqs alternate between messege-sender and message-text until the next day is reached

13:19 I would like to end up with a sequnce of hashes that look like {:date "blah" :time "blah

13:20 " :text "blah" :sender "blah"}

13:21 This is my first miserable attempt: http://pastebin.com/HPFUZCc7

13:24 pdk: do you have the input you fed to that code to produce the result you got in the 2nd pastebin jstirrell

13:25 bortreb: I'm still confused :( it looks like it always goes (time, from, text) or is that not the case?

13:26 jstirrell: pdk, the first pastebin is what the result of the first binding in the loop looks like

13:27 pdk: hm do you mean it's output or is that what you fed to it in a sequence

13:27 jstirrell: bortreb, it goes (date, time, from, text, time, from, text, time, from, text ... ,date, time, from, text,

13:28 that's just the output of another function i used to print the relevent results of the parsed html

13:29 so yeah that would be what i'm feeding the function I'm trying to create here

13:30 bortreb: can you have two dates in a row?

13:30 jstirrell: no

13:30 the dates only show up if there are messages for that date

13:30 and the messages for a date will be "under" that date

13:31 bortreb: ok

13:31 then how about starting off with (partition-by date? your-sequence)

13:32 jstirrell: yeah actually that makes a lot of sense :)

13:32 bortreb: then you get a sequence of (date not-dates)

13:32 jstirrell: cool yeah then it should be easy to assoc the rest with that date

13:33 bortreb: oh it doesn't actually do what I thought

13:33 pdk: hmm

13:33 bortreb: ,(partition-by even? [2 1 1 1 2 1 1])

13:33 clojurebot: ((2) (1 1 1) (2) (1 1))

13:34 bortreb: but still very close

13:34 pdk: is it considered bad form to use let within a doseq if the let binding values are based on the iterator of doseq

13:35 bortreb: ,(partition 2 (partition-by even? [2 1 1 1 2 1 1]))

13:35 clojurebot: (((2) (1 1 1)) ((2) (1 1)))

13:35 bortreb: even better

13:35 jstirrell: sweet yeah i THINK i should be able to figure out something from that, thanks for the help

13:36 bortreb: no problem :)

13:39 raek: jstirrell: this is an idea I had: http://gist.github.com/495481

13:40 warning: not tested, but compiles

13:40 a more "manual" solution, perhaps

13:41 this keeps "state" in form of parameters

13:57 candera: Can anyone tell me why my catch block in this http://gist.github.com/495545 isn't working?

13:57 I would expect the fn to return nil, but it throws.

13:59 mefesto: i'm not sure _why_ but the NumberFormatException is wrapped in a RuntimeException

13:59 raek: ah, this makes sense...

13:59 mefesto: and the try/catch isn't catching RuntimeException

13:59 raek: *map* is lazy

14:00 candera: I saw the RuntimeException, but sort of ignored it figuring it to be REPL noise.

14:00 raek: the exception gets thrown after the nfe-test call is done

14:00 rsh: what is the name of that function that takes a seq and a value, and inserts that value between each element of the seq?

14:00 raek: ...when the repl forces the lazy-seq to realize

14:00 rsh: interpose

14:00 rsh: thanks

14:00 candera: raek: No, in this case I would think the call to every? would force the seq.

14:00 bortreb: beat me to it

14:01 candera: I get the same results with a doall in there.

14:01 raek: hrm

14:01 the lazy-seq catches the exception anyway

14:02 it doesn't know that it is evaluated in the try-catch

14:02 mefesto: i think fn's need to wrap checked exceptions

14:02 candera: That said, catching RuntimeException *does* work properly, so good call on that.

14:02 mefesto: including anon fns

14:02 because fn's need to be able to be used a Runnables which do not throw checked exceptions

14:02 candera: mefesto: Ah, okay, that sort of makes sense.

14:02 mefesto: ... that's my guess anyway

14:02 raek: exceptions plus lazy sequences really don't work well together...

14:04 candera: Thanks!

14:06 jweiss: I'm a little confused about *ns*. at my repl, if i run (in-ns 'foo) and then at the next repl prompt, type *ns* to get the current ns, it fails. but if i do *ns* when the repl first starts, it prints "#<Namespace user>"

14:07 mefesto: jweiss: clojure.core/*ns*

14:07 jweiss: ahh

14:07 mefesto: when you switched ns it didn't include clojure.core

14:08 jweiss: also, in my code, how do i refer to the namespace that the code is part of?

14:08 raek: jweiss: if you use ns instead of in-ns, it will create the namespace if it doesn't exist

14:08 jweiss: i could refer to it by name, but if i rename the namespace i have to edit in more than 1 place

14:08 raek: i think in-ns creates it

14:09 raek: hrm...

14:09 but ns does the refer-clojure part?

14:09 * raek takes a look in the docs

14:10 mefesto: raek is right, it'll implicitly refer 'clojure unless otherwise specified

14:11 technomancy: what's the regex character class for "all letters, unicode-aware"?

14:13 Nikelandjelo: Can somebody explain, why does candera's example http://gist.github.com/495545 throw RuntimeException instead of NumberFormatException?

14:14 As I understande it wraps NumberFormatException in RuntimeException. But why?

14:15 raek: technomancy: I think it is \p{L}

14:15 L is the unicode class for letters, anyway

14:15 technomancy: raek: thanks!

14:15 bummer that \w doesn't just DTRT

14:16 Kaali: Is there a way to load a clojure library dynamically to a swank session? I guess I should modify the classpath somehow?

14:17 raek: a library that was not on the classpath before?

14:18 Kaali: Yes

14:19 Nor do I want to restart my swank session.

14:19 raek: I know that it is possible to do some ClassLoader magic, but I have never done it

14:19 you have the source?

14:19 Kaali: I noticed that add-classpath is deprecated

14:20 raek: then one possible solution is to eval all the files by hand...

14:20 not very fun to do, though

14:20 Kaali: Yeah, it will be more convenient to restart my session than that ;)

14:20 technomancy: Kaali: the only hack that really works is to put a dir on your classpath and unzip your jars there. but it's annoying; most people just restart.

14:21 raek: yes, what about putting it in your src/ dir temporarily?

14:21 Kaali: raek: That sounds like a workable solution

14:21 raek: then require it and then delete it

14:23 Kaali: Nice and "clean" solution.

14:24 raek: why was add-classpath deprecated anyway?

14:25 it can obviously be useful when doing dynamic development and a new lib has to be added to the classpath

14:25 qbg: It doesn't add it to the system classpath

14:26 That can cause a few issues IIRC

14:29 rsh: is there a built in case statement in 1.2 that doesn't throw an error when nothing matches?

14:29 nickik: how do i atach a docstring to a (fn ....)

14:30 Nikelandjelo: If any exception is thrown in map function it always throws RuntimeException. Is it specially designed?

14:30 qbg: rsh: case takes a default expression argument

14:31 slyrus: raek: I was bitter when add-classpath was deprecated, but I've learned to live without it. lein swank, for better or worse, seems to do the job well enough for me.

14:33 qbg: nickik: Why do you want a docstring on an anonymous function?

14:33 raek: nickik: docstring usually go on the metadata of the var

14:33 ,(meta #'inc)

14:33 clojurebot: {:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 766, :arglists ([x]), :added "1.0", :inline #<core$inc__inliner clojure.core$inc__inliner@d408f0>, :doc "Returns a number one greater than num."}

14:34 raek: ,(meta inc)

14:34 clojurebot: {:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 766, :arglists ([x]), :added "1.0", :inline #<core$inc__inliner clojure.core$inc__inliner@d408f0>, :doc "Returns a number one greater than num."}

14:34 the vars are generally where one would look for it

14:36 nickik: I have a macro that does something like (def NAME (A-FUNCTION (fn .....) other stuff)) and i want a docstring on that

14:36 mefesto: Nikelandjelo: LazySeq wraps any exception in a RuntimeException

14:36 qbg: nickik: Then you put the docstring on the metadata of NAME

14:37 Nikelandjelo: mefesto: I see

14:38 jweiss: what's the diff between (defn ^{:foo :bar} [] :baz) and (defn #^{:foo :bar} [] :baz)

14:38 Nikelandjelo: mefesto: But if I want to catch special exception, I have to write some ugly stuff with retrieveing real exception from RuntimeException and throwing it further?

14:38 jweiss: looks like the reader macro is different in the docs than when i wrote this metadata

14:38 raek: those are examples of how this has been done before

14:38 qbg: jweiss: The second is deprecated in 1.2

14:38 mefesto: Nikelandjelo: only if it throws a checked exception, i think subclasses of runtime exception will just pass through

14:38 seancron: Can anyone tell me why my agents are not working in http://gist.github.com/495738 ?

14:39 jweiss: qbg: ok so just the ^ is the 'correct' way?

14:39 qbg: ^ is the idiomatic way now

14:39 jweiss: k thx

14:39 qbg: It looks nicer too

14:40 nickik: like this (fn ^"BLABLA" ....)

14:40 Nikelandjelo: mefesto: It doesn't work in both case: NullPointerException (unchecked) and IOException (checked)

14:40 mefesto: if I want to catch them

14:41 mefesto: Nikelandjelo: I guess all exceptions then :(

14:51 Nikelandjelo: Is handling exception in java way is idiomatic in clojure. Or it exists only for some kind of compatibility?

14:53 Kaali: There is often a need for me to either transform keys of a map or the values. Am I missing a function here, or is there some kind of an idiomatic way to do it?

14:55 nickik: My macro produces this as a output. How can I add a docstring here? (def cdoubler (with-constraints (fn ([n] (* 2 n))) positiv))

15:01 technomancy: Nikelandjelo: it's idiomatic to use Exceptions, but creating your own Exception subclasses is usually inadvisable.

15:01 see clojure.contrib.condition and error-kit for better ways to handle that problem

15:03 Nikelandjelo: technomancy: I'm asking because map is one of the popular functions (imho) and handling exception with map seems to be ugly

15:04 Chousuke: nickik: you'll need to attach the :doc metadata to the cdoubler symbol in your macro

15:04 nickik: using with-meta

15:05 nickik: but that looks a lot like a precondition, are you aware of that feature?

15:05 nickik: im working on the lib to make pre and post conditions usful

15:05 :)

15:05 trammel

15:05 Chousuke: I see.

15:06 seancron: Can anyone see why my agent send-off is not working in http://gist.github.com/495738 ?

15:06 nickik: i hoped to avoid the (with-meta )

15:07 cmihai: Hi. I'm having some issues setting up Clojure / SLIME / swank-clojure and it's passing the wrong number of arguments when running running compile-and-load-file. I've understood this problem can be solved with swank-clojure-1.2.1.jar, and connecting manually but I can't find the thing anywhere. All I have is 1.1.0. Any tips?

15:07 Nikelandjelo: seancron: Does it trow exception?

15:07 cmihai: Actually, is there some authoritative documentation on the subject? All I've managed to find so far was umh.. let's just say confusing.

15:07 seancron: Nikelandjelo: Nope. It doesn't change the state at all

15:08 Chousuke: seancron: did you test lookup-dns outside an agent?

15:08 seancron: ie. does it actually work :)

15:08 seancron: Chousuke: Yeah. It worked before with just one host. I'm trying to make it support multiple host lookups

15:08 Nikelandjelo: seancron: Why don't you pass host into send-off?

15:09 Chousuke: Nikelandjelo: the host is the agent's value

15:09 raek: cmihai: the official docs for swank-clojure http://github.com/technomancy/swank-clojure

15:09 swank-clojure.el

15:09 Previous versions of Swank Clojure bundled an Elisp library called swank-clojure.el that provided ways to launch your swank server from within your Emacs process. While swank-clojure is still distributed with the project, it's a much more error-prone way of doing things than the method outlined above.

15:09 Chousuke: seancron: why are you using agents for something like that though? seems a bit overkill to me.

15:10 Nikelandjelo: Chousuke: Oh, sorry :)

15:10 Chousuke: seancron: I mean, the code pattern looks a bit suspicious to me

15:10 seancron: oh, hm, are you sure there is no race in the cache clearing that might be giving you errors?

15:11 seancron: Chousuke: Yeah, I'm new to Clojure and functional programming so it's probably not ideal at all. I'm doing this as a side project to try out Clojure

15:11 Chousuke: I've tried it with just one host and it doesn't work either

15:13 Chousuke: If you can think of any other ways to lookup the hosts concurrently I'd be glad to hear them

15:14 Chousuke: well it seems like you could just use futures

15:15 that way you can just look up a host like normal and the user can just deref the future when the result is actually needed

15:16 raek: cmihai: my tip to get slime and swank working is to start swank outside emacs as described in the link

15:16 and the use slime-connect from emacs to connect to it

15:17 beware that there are a lof of outdated tutorials 'round the net

15:17 the getting started guide on clojure's wiki should be up to date too

15:18 seancron: Chousuke: My ultimate goal is to do these lookups every 10 seconds and log the results in a CSV file

15:19 cmihai: raek: I've noticed. I still failed to find swank-clojure-1.2.1.jar, but I'm building the toolkit to build it (hopefully..).

15:19 raek: cmihai: how do you indend to start swank? manually?

15:20 cmihai: Manually, elpa, git builds, some script from the internets.. tried it all :-)

15:20 raek: do you use leiningen or cljr?

15:20 cmihai: Just finished setting up cljr now.

15:21 Still haven't gotten into lein yet.

15:21 raek: I have unfortunately never used cljr, but I know how to get it working with leiningen

15:22 cmihai: Which fork? I got technomancy's git hub, but I'd need to build that :-).

15:22 cmihai: Kind of an issue, since I haven't used lein and such before :-)

15:22 raek: there are jars on clojars

15:23 seancron: Chousuke: Do you think the problem might be that lookup-dns returns 0 on a successful lookup?

15:23 raek: and then start a repl with "java -cp clojure.jar:clojure-contrib.jar:swank-clojure.jar clojure.main"

15:23 cmihai: Aha, thanks, found the jars :-)

15:24 raek: then you'll have to run something like:

15:24 (ns my-app (:use [swank.swank :as swank]))

15:24 (swank/start-repl)

15:25 then you should be able to connect to it with emacs using slime-connect

15:25 cmihai: Thanks mate :-). I'll give that a try then.

15:25 raek: np.

15:26 Chousuke: seancron: er, right?

15:26 seancron: the return value of the function you send to an agent becomes the agent's new value

15:26 seancron: so the agent's value on a successful lookup would of course be 0

15:27 seancron: if that's what the function returns

15:28 seancron: Chousuke: Yeah. Never mind. I thought returning a 0 might be causing an error.

15:29 Chousuke: seancron: you could try running agent-errors on the agents to see if there are any exceptions thrown in lookup-dns

15:35 seancron: Chousuke: No exceptions. agent-error returns nil

15:39 chouser: this is rather intriguing: http://olabini.com/blog/2010/07/preannouncing-seph/

15:39 "Seph will steal/has stolen Clojures persistent data structures, all the concurrency primitives and the STM."

15:46 Chousuke: seancron: hmm :/

15:49 seancron: Chousuke: I'm not committed to using agents. Do you think futures is a better choice for this type of parallel dns lookup?

15:54 Chousuke: seancron: well I suppose it depends on what you're doing but in general agents are intended to be a long-lived "identity" that changes its value over time

15:55 seancron: but you seem to be using them as a convenient way to get off-the-main-thread execution, where futures are a better conceptual fit

15:58 cmihai: Sorry, still can't figure it out, with cljr or leiningen (which I can't figure out how to run...)

15:59 I'm guessing it needs more stuff in CLASSPATH

15:59 technomancy: cmihai: are you on Windows?

15:59 cmihai: Linux

16:00 technomancy: it's very easy to run Leiningen if you're not on Windows. what problems are you having?

16:00 I mean, to just install and run it. It may be tricky to do certain things.

16:01 seancron: Chousuke: Well I want to repeatedly lookup the hosts to see when they're up or down

16:02 Hm.. yeah, looks for 1.2.0

16:02 technomancy: cmihai: did you follow the instructions for self-install?

16:03 sorry, I've just never heard of anyone having a hard time installing leiningen unless they were on Windows.

16:03 need to take off, but you can email the leiningen mailing list if you hit issues that aren't covered in the readme

16:04 cmihai: K.

16:08 Did run self-install though.

16:08 slyrus: anyone around use fnparse?

16:08 cmihai: Aha, the jar files are corrupt

16:08 slyrus: cmihai: are you trying to self-install from the git HEAD?

16:08 jfields: chouser, Chousuke, et al. Do you think using a destructured value in the next destructure is a bad idea? e.g: (let [x (fn [{y :k} {z y}] z)] (println (x {:k :v} {:v :s})))

16:09 cmihai: No, I used the self-install command, but the downloaded jars are full of html :-)

16:10 slyrus: yes, but you used the self-install command from some particular version of leiningen. if that was the head, it won't work.

16:10 cmihai: Aha the jar contains: Octocat is sad That page doesn't exist!

16:10 Fuck me.

16:10 slyrus: you need to check out a pre-1.2.1 version, do lein self-install, then I think you can checkout master

16:11 there's no jar for 1.2.1 in the repo. I was griping at technomancy about this yesterday. it's a trivial fix.

16:11 chouser: jfields: wow, that's subtle

16:12 jfields: my first instinct is that it wouldn't work. I see now why it does, but I guess I wouldn't even be sure future implementations of destructuring would support it.

16:12 jfields: chouser, I can actually use that in some prod code, it's exactly what I want, but it seems like it might work by accident.

16:12 chouser: yeah

16:13 I can see that it could be useful, but we usually think of fn args as binding simultaneously.

16:13 and you're neatly skirting that little assumption.

16:14 jfields: chouser, yeah, like you I didn't think it would work either, which is why I'm concerned that it wont always. =)

16:14 cmihai: Yeah, sorry, I can't figure this out at all. The more things I fix the more errors come up, and I'm getting dizzy. Maybe another day :-)

16:15 slyrus: cmihai: git checkout 3dc47c1382ae3f05e3ae79267d9d3aa3120b13d8 ; lein self-install

16:15 jfields: chouser, thanks for your input. I guess I'll use it for now. it should be obvious when it stops working, so i guess it's not a risk.

16:16 chouser: heh. ok.

16:16 I guess personally I wouldn't. It wouldn't be that hard to do the second part in a separate 'let', right?

16:17 technomancy: slyrus: it is documented now at least.

16:18 slyrus: technomancy: ah, good.

16:19 jfields: chouser, the actual prod code is: (defmethod decode :ack [_ {id :id} {order id}] (assoc order :type :ack :to :client))

16:21 chouser, I could just grab the map in the fn body, but it doesn't seem necessary. Or maybe it is. I can't see anything that's motivating me to go either way. I think the sequential destrucure reads a bit better.

16:22 chouser: (defmethod decode :ack [_ {id :id} ordermap] (assoc (get order id) :type :ack :to :client)) ; would be the "other way"?

16:22 er

16:22 (defmethod decode :ack [_ {id :id} ordermap] (assoc (get ordermap id) :type :ack :to :client))

16:22 cmihai: slyrus: Wow, amazing.

16:23 jfields: chouser, yes.

16:23 cmihai: I tried doing the same fix by hand, but failed with the -SNAPSHOT thing btw.

16:23 It worked with the older git revision. Thanks a bunch

16:23 slyrus: yw

16:24 cmihai: Now to remember what the hell I installed this for

16:24 Installing thee things is like tracing a java error...

16:24 Oh, right, getting swank-clojure working.

16:24 And that to get slime.

16:26 technomancy: cmihai: so... why didn't you just use the install instructions in the readme? you don't need a checkout at all.

16:26 cmihai: Bloody hell, that was easy :-)

16:26 technomancy: I'm pretty sure I did....

16:27 * slyrus discovers partial

16:27 cmihai: I think I must have gotten the wrong lein script at *some* point.

16:30 I personally don't like this auto-magic download stuff to something called .m2, whatever. I tends to fail in unpredictable ways.. Anyway, nevermind, slime-connect works, and I can run the bloody thing from emacs. Mission accomplished. Thanks.

16:38 slyrus: cmihai: I'm with you, man. I'm a big fan of (other than the name) the checkouts directory though!

16:40 tomoj: does that mean you'd rather download the source repo for each dep for a project you want to use (and for each of their deps...) and symlink them into checkouts/ than run lein deps ?

16:41 cmihai: Yup.

16:42 slyrus: tomoj: yes

16:42 tomoj: leiningen itself has 27 deps

16:42 sounds like fun

16:42 slyrus: tomoj: auto-dependency-chaining leads to things like leiningen having 27 deps! I view that as a bug not a feature..

16:43 cmihai: Gives me better control over what I'm using, and lets me actually understand what I'm doing and why. Like I've said, I didn't actually want leiningen at this point, just to get a IDE for Clojure up and running (emacs + slime). And that proved to be a PITA.

16:44 tomoj: ok, but when you actually want to run someone else's code or publish your code as a library?

16:44 cmihai: And the way it failed (by downloading a .html page to a .jar without any kind of checking) was quite.. troublesome.

16:44 tomoj: that is troublesome

16:45 cmihai: So every time there's a dead URL or even a captive portal

16:45 I run the risk of nuking all my jars?

16:45 raek: cmihai: did you try to use the bare swank-clojure jar?

16:45 do get swank running, you really only need that one plus clojure and contrib

16:45 ...if you want to do things manually

16:47 cmihai: Tried with cljr swank, it wouldn't start. didn't bother to figure out what main class to load

16:48 raek: if you have the swank jar file, you can start swank by hand

16:48 it's just clojure...

16:49 the main class is clojure.main to start the clojure repl

16:49 cmihai: I mean with swank-clojure

16:49 raek: java -cp 'dir-with-jars/*' clojure.main

16:49 you start it in clojure

16:49 I don't think it has a main class

16:50 cmihai: Oh.

16:50 Didn't know that :-)

16:50 raek: (require 'swank.swank) (swank.swank/start-repl)

16:50 it's under the section "embedding" in the swank readme

16:51 which in this case should be read as "starting swank manually"

16:51 the most common way is to start swank with some tool that sets the classpath automatically

16:53 slyrus: cmihai: of course if you follow the path I took, you'll figure all this stuff out, then finally succumb and just start using lein swank (and even lein deps to an extent)

16:57 cmihai: slyrus: yeah, that worked, thanks.

16:59 I'll go with that until I figure all this stuff out. Like I said, atm I just want a slimy emacs + basic clojure & contrib, and learn the basics. I'd rather have my environment setup and editor first, then learn the language, then the internals.

16:59 Should not be too different from CLISP I guess. Documentation is kind of lacking though. Any books worth getting?

17:05 Oh, and maybe a minor question, how can I use it a scripted interpreter? Eg: send it something like clojure '(+ 3 1)'

17:10 dnolen: cmihai: raek: that is going to be painfully slow. I highly recommend using cake if you don't want to buy into a particular IDE, or Vim, Emacs. cake uses persistent VMs so it's fast

17:10 and supports: cake eval '(println (+ 4 5))'

17:11 I'm an Emacs person myself, but cake opens so doors for people who prefer text editors like TextMate

17:13 lancepantz: dnolen: i saw your github tickets, are you using the gem install?

17:13 dnolen: lancepantz: everything is working beautifully now, ninjudd dropped a bunch of patches, 0.3.4 is slick

17:15 lancepantz: dnolen: awesome, its still kinda flaky at times, i'm working on a bunch of tests, but that's just become an excuse to add new features to the test task

17:16 cmihai: I'm an Emacs guy, so it has to be slime. I've got that setup already, and now it works with clojure too. So I'm fine with that. I'll look into cake, thanks.

17:16 lancepantz: cake supports swank as well

17:17 C-c C-k updates the persistent jvm as well

17:17 cmihai: Got a url handy for cake btw?

17:18 dnolen: lancepantz: yeah I can see that there are issues, but I think the ground work is there for getting good Clojure support in simpler environments with cake.

17:18 lancepantz: http://github.com/ninjudd/cake

17:18 cmihai: Ah, emacs-cake not clojure?

17:19 Oh. :-)

17:19 dnolen: I'm not going to use it much myself, but I'm thinking about putting a basic TextMate bundle together for people who want a simpler install 1) gem install cake 2) install TextMate Clojure bundle 3) hack

17:20 cmihai: Strange, I grepped github for cake written in clojure and no hits.

17:24 Lajla: ahh, technomaz, I have crossed oceans of time to be with you.

17:30 jweiss: I'm trying to sharpen my FP skills by getting rid of imperative constructs where possible. I have a list of "tests" to run, and a list of "results". My "execute" function needs to go through the list of tests, and build up results. but it's not a simple map function. Each test depends on the entire result set to date. is there a FP way to do this (without loop/recur)?

17:33 gregh: start with a function that takes a result set and a sequence of tests, and runs the first test in the sequence

17:34 call itself recursively with the new result set, and the rest of the sequence of tests

17:34 standard initial and termination conditions apply

17:34 jweiss: gregh: ok, that's pretty much what i have now, minor quibble between a recursive fn and loop/recur

17:37 gregh: yeah, it's a pretty fine line

17:38 clojure provides loop/recur as a limited version of tail recursion just because the jvm doesn't allow the real thing

17:40 jweiss: yeah i was thinking more along the lines of a function like map, where it makes a lazy seq of results

17:40 pdk: ,(binding [x 1] x)

17:40 clojurebot: java.lang.Exception: Unable to resolve var: x in this context

17:40 pdk: that is so dumb

17:41 (doc binding

17:41 pdk: (doc binding)

17:41 clojurebot: "([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."

17:42 pdk: ok whats the workaround

17:42 dnolen: pdk, *already existing* vars

17:42 pdk: ah heh figures

17:42 jweiss: it probably fails in the init

17:42 pdk: i saw some little footnote on the site that said root bindings were optional and i guess i took it out of context then

17:43 prob applies to something else

17:51 shoover: is this technically a race condition on *loaded-libs* since it's dereferenced outside a transaction and then updated later? http://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4757

17:57 technomancy: cmihai: the problem is that curl silently fails on 404s; I thought it would give an error message

17:58 cmihai: could you create a bug report?

17:58 (btw; self-install is a special case since it has to be implemented in the shell; you'd never see HTML-files-as-jars from a lein deps run)

18:09 lancepantz: is it considered bad form to copy a function from contrib into your src? in the case where that's all the project will ever use from contrib

18:11 i'm playing around with difform, it has contrib 1.1 as a dep all for a single one line function

18:11 technomancy: cmihai: anyway, what I meant about the instructions is that it works better if you download the stable version of the lein script

18:11 lancepantz: so then i end up with contrib 1.1 and 1.2 in as well as a clojure 1.1 jar in my lib

18:12 technomancy: slyrus: I'm not sold on the name of the checkouts dir; open to suggestions

18:12 slyrus: lib-src?

18:16 jweiss: is there a more concise way to express (if x x 0) ?

18:16 well that's pretty concise, but more obvious i guess

18:16 cmihai: technomancy: Yeah. I'll dig a bit deeper tomorrow, I'm shutting down for the night now :-).

18:17 technomancy: jweiss: (or x 0)

18:24 neotyk: ,((fn [f & {:as options}] (f options)) (fn [& {:as options}] (println options)) :a 1)

18:24 clojurebot: java.lang.IllegalArgumentException: No value supplied for key: {:a 1}

18:25 neotyk: How do one make {:as options} fall through?

18:28 in example :a 1 gets converted to map, is there a way to splice it?

18:33 arohner: neotyk: I don't know what you mean by fall through or split it

18:39 slyrus: hmm.. in what interface would I find second?

18:41 neotyk: arohner: ((fn [& {:as a}] (println a)) :key "value")

18:42 so :key "value" gets converted to map named a

18:42 what if from that fn I would like to call another fn with [& {:as

18:42 *** a}] ?

18:43 how would I splice a that was converted from :key "value" to

18:43 *** {:key "value"} back to :key "value"

18:46 arohner: oh, apply

18:47 hrm, though that gets weird with maps

18:47 slyrus: or, put another way, what interfaces do I need to support s.t. (let [[x1 x2] my-obj] ...) works?

18:47 I thought nth would be enough, but apparently that's not the case

18:48 oh, I think I need to support next

18:48 neotyk: ,((fn [f & {:as options}] (apply f options)) (fn [{a :a}] (println a)) :a :b)

18:48 clojurebot: nil

18:49 neotyk: would expect :b

18:49 sorry, not that example

18:51 here it is

18:51 ,((fn [f & {:as options}] (apply f options)) (fn [& {:as options}] (println options)) :a :b)

18:51 clojurebot: java.lang.IllegalArgumentException: No value supplied for key: [:a :b]

18:53 arohner: ,((fn [f & {:as options}] (apply f (flatten (seq options)))) (fn [& {:as options}] (println options)) :a :b)

18:53 clojurebot: {:a :b}

18:53 arohner: since it's a map, you need to flatten before applying

18:53 if those were seqs/vectors, the flatten wouldn't be necessary

18:53 neotyk: arohner: thank you very much :)

19:22 lancepantz: this is the clojure project i've been working on, if anyone cares. finally got it into production. http://blog.geni.com/2010/07/new-beta-feature-revisions.html

20:09 slyrus: yay: (add-bond (reduce add-atom (make-molecule) [c1 c2]) c1 c2) finally works.

21:03 aldebrn: I sort of wish #"string" yielded a raw string, rather than compiling to a Pattern, so that I could do (format #"<b>%s</b>" bolded-statement), e.g.

21:04 Well, that example was horrible, I meant something involving escapes: (format #"{\em %s}" emph-statement)

21:08 Bahman: Hi all!

21:20 eckroth: is there some advantage to using (fn) over #() ?

21:21 rhudson: I'd say the longer the function, the more appropriate fn is

21:21 eckroth: rhudson: sure, because of the % issue

21:21 rhudson: but is (fn [_] (blah)) better than #(blah) ?

21:22 rhudson: also, nested anonymous functions

21:22 eckroth: rhudson: like, in how its executed? performance difference? debugging issues?

21:23 rhudson: The reader translates the #() form into the fn form, so they run identically

21:23 eckroth: rhudson: ah ok

21:23 rhudson: #(blah) is better than (fn [] (blah))

21:24 eckroth: rhudson: I see in rhickey's ant code that he used (fn [_] (blah)) http://clojure.googlegroups.com/web/ants.clj

21:24 rhudson: though perhaps that's no longer idiomatic

21:25 rhudson: Note that (fn [_] blah) is a function that takes one argument that's ignored; #(blah) is 0-argument

21:25 eckroth: rhudson: but #(blah %) is 1-argument? so it checks inside and counts % ?

21:26 rhudson: right

21:26 #(blah %1 %2) is a 2-arg function

21:26 eckroth: rhudson: as is #(blah %2) I suppose

21:26 rhudson: 2-arg that is

21:27 rhudson: I would guess so; dunno

21:27 eckroth: ,(#(print %2) 1)

21:27 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox$eval500439$fn

21:28 eckroth: ,(#(print %2) 1 11)

21:28 clojurebot: 11

21:28 rhudson: hah

22:16 lancepantz: anyone know what i could have done to aquamacs that would make M-s print a beta?

22:19 well, (setq mac-option-modifier 'meta) fixed it

22:57 tomoj: lancepantz: was it a ß?

22:57 lancepantz: yep

22:58 don't know how it got unbound, bizzare

22:58 tomoj: that's just mac's default thing

22:58 option for extra characters

22:58 oh you mean the variable, dunno

22:58 lancepantz: yeah

23:18 cais2002: hi guys, did any of you encounter a StackOverflowError with latest 1.2.0-master-20100727.210144-91? at clojure.lang.Keyword.intern(Keyword.java:39)

23:19 it does not happen for 1.2.0-beta1

23:37 daaku: i've been searching for a bit, but can't seem to find any code coverage libraries, anyone know if one exists?

23:38 lancepantz: daaku: i don't believe so

23:38 daaku: lancepantz: cool, thanks

23:39 lancepantz: daaku: i was looking at something, i think it may have been swank or clojure-test-mode that basically assumed that tests for the foo ns were going to be in test_foo

23:40 daaku: lancepantz: i don't get how that would translate to code coverage info

23:41 lancepantz: it just made me assume that there wasn't a code coverage library

23:44 scottj: Is there a version of -> that with more than two args isn't defined in terms of itself?

23:46 and can you monkey patch functions? :) like add a new arity function to an existing one from core?

23:48 tomoj: you can, but you shouldn't

23:53 ttmrichter: There's nothing wrong with monkey-patching that a good caning wouldn't solve.

Logging service provided by n01se.net