#clojure logs

2010-07-28

00:00daakuwwmorgan: aww.. i kept searching for clojurerc -- that's probably what i want
00:00seancronDoes anyone have any suggestions on using agents to look up hosts repeatedly?
00:42slyrusone 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?
00:45tomoj(.getResource (clojure.lang.RT/baseLoader) "<CLASSPATH-relative filename>")
00:46tomojor (.getResourceAsStream ...)
00:46slyrusthanks tomoj
00:49slyrusah, that and a lein resources directory and I'm good to go. great!
01:27gstamphrmm. hash-combine doesn't have a doc string. I assume it creates a new hash from two existing hashes?
01:55dublindanhttp://clojure-games.org (a very very early work in progress)
02:35slyrusok, name me two actors/actresses
02:36ttmrichterslyrus: Aishwarya Rai, Steve Buscemi.
02:36ttmrichter(I would pay loads of money to see those together in a movie.)
02:37slyrus("Steve Buscemi" "Things to Do in Denver When You're Dead" "Andy García" "The Pink Panther 2" "Aishwarya Rai")
02:38slyrusnot in a movie together, but close...
02:39ttmrichterSo why did you want two actors/actresses?
02:39slyrus(map :name (graph/find-node *actor-film-graph* (get-actor-node "Aishwarya Rai") (get-actor-node "Steve Buscemi")))
02:39slyrusmy kevin-bacon-solver
02:39ttmrichterA six degrees of Kevin Bacon with movie stars?
02:39slyrusyeah
02:39ttmrichterDammit!
02:39ttmrichterWhat's your data source?
02:39slyrusfreebase
02:40slyrus100k movies, 75k actors, or so.
02:40ttmrichterOK, let's see if I can't break it.
02:40ttmrichterPeter Falk and Bipasha Bipu
02:41ttmrichterDoris Day and Faye Wong
02:42slyrus("Faye Wong" "2046" "Takuya Kimura" "Howl's Moving Castle" "Lauren Bacall" "Young Man with a Horn" "Doris Day")
02:42ttmrichterDamn!
02:42slyrusunfortunately, the Peter Falk search turned up empty...
02:42ttmrichterHah!
02:42ttmrichterNOBODY stars with Peter Falk!
02:42ttmrichterExcept through Columbo!
02:42ttmrichterWhere everybody stars with Peter Falk! :D
02:42absalomMikhail Gorbachev did...
02:43slyruswell, that's not true, it's just that Bipasha Bipu isn't in there.
02:43slyrusis the spelling right?
02:43ttmrichterOh.
02:43ttmrichterI... think so?
02:43ttmrichterLet me check.
02:43slyrus("Peter Falk" "The Thing About My Folks" "Olympia Dukakis" "The Great New Wonderful" "Naseeruddin Shah" "Dus Kahaniyaan" "Bipasha Basu")
02:43slyrusbasu?
02:43ttmrichterAh, my bad.
02:43ttmrichterBasu.
02:44slyrusthe ya go
02:44slyruss/the/there/
02:44sexpbotthere ya go
02:44ttmrichterGong Li and Charlie Chaplin.
02:45slyrus("Charlie Chaplin" "A King in New York" "Phil Brown" "Johnny Kapahala: Back on Board" "Cary-Hiroyuki Tagawa" "Memoirs of a Geisha" "Gong Li")
02:46ttmrichterMan, that's shorter than I expected.
02:46ttmrichterI guess that goes to show how inbred the movie industry is, right?
02:47Chousukewhat happens if it can't find a connection?
02:47slyrusyeah, don't ask me to run the graph-distance-matrix to compute all pairwise distances though :)
02:47slyrusChousuke: the universal no connection answer, the empty list :)
02:47Chousukeheh
03:05LauJensenGood morning all
03:07unfo-morning LauJensen
03:16slyrusif anyone wants to try out cinematograph, it's here: http://github.com/slyrus/cinematograph
03:28slyrusor you can just keep throwing pairs of actors/movies at me and I'll tell you how they're connected :)
03:28ragnard(doc declare)
03:28clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
03:29ragnardsorry, missed the repl
04:41raekdoes anyone know what seqs are chunked?
05:45cais2002hi, is there a quick guide on how to create my own task for leiningen?
05:49raekhttp://github.com/technomancy/leiningen/blob/master/PLUGINS.md
05:49raekthis is what I know of
05:51raph_amiardHi there
05:51raph_amiardi want to know, if i want simple syntax highlighting for clojure in vim
05:51raph_amiardi don't want slimv nor vimclojure/gorilla
05:51raph_amiardin my opinion they are complicated and way too big and buggy for my tastes
05:52raph_amiardwhat are my options ?
05:54cais2002raph_amiard: I am using vimclojure and mainly just for syntax highlighting and Ctrl+N for autocompletion. you can ignore those adv features
05:55raph_amiardyeah well you're probably right
05:56raph_amiardbut i find installation to be seriously horrible but i guess i can just grab the vimclojure's syntax file ?
06:01bonegaHi - Can anybody share some good thoughts regarding -> and ->>
06:01bonegaI understand the usage - but have a hard time deciding when it's appropriate
06:02bonegaI am using Forth in my job - so I am a bit damaged...
06:02raek(f1 a (f2 c (f3 e (f4 x) f d) b) <--- not very readable
06:03bonegaTry working in forth ;)
06:03bonegaNah - more if there exists some consensus at what complexitivity level it becomes appropriate
06:03raekbonega: if you know forth then I don't have to explain why the -> syntax is no neat...
06:04raekif the code looks simpler and more readable, go for it
06:05bonegayes ty - I am only worried for the ones that have to work with my code...
06:05raekimo, you should expect clojure programmers to understand ->
06:06raekit might be overkill to use it for just 2 forms, but for 3 or more I don't see why it should be bad
06:08bonegaI hate having to base my decisions on what feels right :(
06:09bonegaraph_amiard: You should really use a editor that is parens aware and have REPL integration
06:09bonegaI am a vim user myself, but couldn't seem to get vim setup right for Clojure
06:09bonegaSo for the moment I am using Eclipse and Counterclockwise
06:10bartjbonega, having tried vim to get working with Clojure for nearly 6 months, and using it - I know it is highly frustrating
06:10bOR__stupid simple question. If I want a global var to return a new random number (def myvar (rand)), how should I write it?
06:10cais2002raph_amiard: I just followed the instructions and ignored the ng server related stuff
06:10bartjbonega, my best suggestion to you is to use emacs - paredit, etc just rocks
06:11bonegaI have no time learning another OS ;)
06:11bOR__(def myrand (first (take 1 (repeatedly #(rand))))) doesn't seem to work :).
06:12raph_amiardbonega: I used emacs for 1 year for clojure
06:12raph_amiardbonega: still hate it in the end though
06:13raph_amiardbonega: but the lisp integration is wonderfull
06:13raph_amiardi guess i'm gonna try emacs with vimpulse
06:13raph_amiardmaybe it'll be enough
06:14bOR__I'll just go for (defn myvar [] (rand))
06:14bonegaThat's an abomination
06:14bOR__would have liked a dev solution.
06:14bOR__def.
06:15NikelandjelobOR__: (def myvar (fn [] (rand) ) )
06:15raekbOR__: your first example always gives the same value
06:16raekit evalueates (first ...) and binds that value to the var
06:16bOR__raek - that I noticed.
06:16bonegaplease don't call it something like myvar - it's still a rand function
06:16bOR__bonega - it is just a simple example of something else.
06:16bonegaroger
06:17raekbOR__: how do you want to use it?
06:17Lajla,
06:17clojurebotLajla: Excuse me?
06:17bOR__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)))
06:18raekrand-int is only called once
06:19bOR__raek - yes, but how can I get it to be called each time I look up the def?
06:19Lajlaraek, I long to consume your mortal soul.
06:19bOR__(count (take-while (partial some #(= (:rat %) :healthy)) burrow-stream)) is what I'm using it for.
06:20bOR__counting the time till a whole gerbil burrow is infected with the plague ;).
06:20raekbOR__: you wrap everything in a defn insead
06:20bOR__*nod*, that was my solution.
06:20raekfunctions run code, values are fixed
06:20bOR__was wondering if there was a way to def it.
06:20bOR__good point.
06:21raekthis could be of use maybe: (defn make-rand-int-seq [] (repeatedly rand-int))
06:22raek(let [a-rand-seq (repeatedly rand-int)] [(take 4 a-rand-seq) (take 7 a-rand-seq)])
06:22raek,(let [a-rand-seq (repeatedly rand-int)] [(take 4 a-rand-seq) (take 7 a-rand-seq)])
06:22clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$rand-int
06:22raek,(let [a-rand-seq (repeatedly #(rand-int 10))] [(take 4 a-rand-seq) (take 7 a-rand-seq)])
06:22clojurebot[(4 5 4 4) (4 5 4 4 2 3 8)]
06:22raekthen multiple processes can share the same sequence of random numbers
06:22bOR__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.
06:23serp_,(take 5 (repeatedly (partial rand-int 10)))
06:23clojurebot(0 9 9 3 2)
06:23bOR__ah, raek - yep.
06:25Lajlaserp_, my beloved, I've crossed oceans of time to be with you.
06:28zmila,(bit-not 65535)
06:28clojurebot-65536
06:51raph_amiardRe here
06:51raph_amiardi'm trying to make slime work with liebke's cljr swank command
06:51raph_amiardbut i'm hitting a wall :/
06:51raph_amiard"make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005"
06:52raph_amiardwhen i launch "cljr swank 4005", it's just hanging in there so i imagine it's working
06:55raeki 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
06:55raph_amiardokay
06:55raph_amiardi have got no such line, nothing at all.
06:56raph_amiardthat means few debug information too ..
06:56raektry connecting to the port with telnet or something to check if there is something listening
06:56raph_amiardgood idea
06:56raph_amiardi'm also maybe gonna try starting a swank server with leiningen
06:56raph_amiardto see if it works there
06:57raekwhat is cljr, btw? a packet manager?
06:57raph_amiardwell it is a very cool project from liebke, the guy who does incanter
06:58raekah, read on the project page
06:58raph_amiardhttp://github.com/liebke/cljr
06:58raph_amiardbasically it's a clojure environnement for things that don't fit in the leiningen project model
06:58raekto make starting a repl for things that are not projects easy, right?
06:58raph_amiardyeah exactly
06:58raekneat
06:59raph_amiardyeah also the ability to install libs system wide is very cool
07:00raekwell, now clojure has the best of both worlds, then...
07:00raph_amiardso much of my activity with clojure is fast scripting, testing out ideas
07:00raph_amiardyeah i hope
07:00raph_amiardi don't know leiningen so well though
07:00raph_amiardbut it seems really good
07:02raph_amiardyeah well i think cljr swank server is not working
07:08raek:(
07:43gfrlogcan I access a public instance variable of a java object in clojure? Or does there have to be a method to call?
07:45raek(. instance field)
07:45gfrlogworks perfectly, thanks
07:45rhudsonI think (.field instance) works too
07:46gfrlogoh geez it does
07:46gfrlogI thought I had tried that
07:46gfrlogbut I actually hadn't
07:47raekyeah, the (.field instance) is probably preferred
07:48raekall of this is documented here: http://clojure.org/java_interop
07:48gfrlogthanks; I'm mostly familiar with the interop. Just don't deal with public variables often
07:49raekok. yeah, setters and getters are more common
07:49raekif it has getters, consider using bean
07:49gfrlogright
07:50gfrlogI found a bug in bean actually; at least in older versions (I think 1.1?)
07:50raekoh
07:50raekwhat does it do? have you created a ticket?
07:51gfrlogshould I check it on the master branch before creating a ticket?
07:51gfrlogbean returns a map
07:51gfrlogand if you try to access a nonexisting key it throws an NPE
07:51gfrlogI assume that's a bug
07:51chouserit's on master, but I'm not sure if it's a bug.
07:51gfrlogthere's certainly no warning about it in
07:52gfrlog(doc bean)
07:52clojurebot"([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties."
07:52chouseryou can give a "notfound" value to return...
07:52chouserhm
07:52gfrlogyou can?
07:52gfrlog(bean 128 99)
07:52gfrlog,(bean 128 88)
07:52clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$bean
07:52chouser, (:foo (bean Object) :bar)
07:52clojurebot:bar
07:53gfrlogyes but
07:53gfrlog,(:foo {})
07:53clojurebotnil
07:53gfrlogwhy would we want different behavior?
07:54gfrlog,((bean "jokes") :foo :bar)
07:54clojurebot:bar
07:54chouser,(:foo (assoc (bean Object) :a :b))
07:54clojurebotjava.lang.reflect.InvocationTargetException
07:54gfrlogthat's fine because the docs say it's read-only
07:54chouserhuh. that returns nil for me
07:54chouser,(:a (assoc (bean Object) :a :b))
07:54clojurebotjava.lang.reflect.InvocationTargetException
07:55chouserand that returns :b
07:55gfrlogwhat version are you using?
07:55chousergfrlog: you're probably right that it's a bug. best to start by mentioning it on the google group.
07:55chousergfrlog: some recent master.
07:56gfrlogdoes your recent master throw the NPE as well?
07:56chouseryes
07:56gfrlogokay
07:56gfrlogI'll try the google group, but last time I tried posting it never got there
07:56gfrlogis there some extra registration process I'm unaware of?
07:57chouserhm, no -- your first few posts should be held in a queue until manually approved (to reduce spam) but no other registration.
07:58gfrloghmm
07:58gfrlogokay
07:58gfrlogI guess my post wasn't clever enough
07:58chouserheh
07:58gfrlog,(bean Object)
07:58clojurebotjava.lang.reflect.InvocationTargetException
07:59gfrlog,(bean (Object.))
07:59clojurebot{:class java.lang.Object}
07:59chouserah
07:59chouser,(:foo (assoc (bean "") :a :b))
07:59clojurebotnil
07:59chouser,(:a (assoc (bean "") :a :b))
07:59clojurebot:b
07:59gfrlogyour clojure lets you call bean on a class?
07:59chouseryup
07:59gfrlog,(assoc (bean "") :a :b)
07:59clojurebot{:a :b, :bytes #<byte[] [B@1f1df3f>, :class java.lang.String, :empty true}
07:59gfrlogI wonder what "read-only" means
08:00chouseryou can't call setters of the bean object
08:00gfrlogokay, so it doesn't mean anything important in clojure, just if you were thinking of doing fruity java things with it?
08:00chouserI think so, at least that's how I read it.
08:01chouserand since the thing bean returns allows assoc, I don't see how someone could justify the NPE at all.
08:01gfrlogyeah
08:02gfrlog,(:haha (assoc (bean "") :a :B))
08:02clojurebotnil
08:02rhudson,(class (assoc (bean "") :a :b))
08:02clojurebotclojure.lang.PersistentArrayMap
08:03gfrlog,(class (bean ""))
08:03clojurebotclojure.core.proxy$clojure.lang.APersistentMap$0
08:09rhudsonHmm. The implementation's creating a map of accessor functions 'pmap , then just indexing on 'k as ((pmap k)). No entry for k => NPE
08:15gfrlogI don't suppose you can compile java code from within clojure can you?
08:16bortrebgrflog: sure, use something like lancet
08:16gfrlogokay, I'll look into it, thanks
08:17bortrebexamples are a little thin right now so if you want a working example i can send you one
08:17gfrlogI can't object to that
08:17raekI guess you could also run a leiningen plugin from clojure
08:17gfrlogI've never dynamically compiled java code from java even, so I'd have similar questions there
08:25bortrebok, I packed up a project I'm working on at www.rlmcintyre.com/probes.tar.bz2 for you
08:25gfrlogcool, thanks!
08:26bortrebit also shows how to use clojure as a command line script
08:26bortrebjust unpack it and change the shebang line on the quake file at the base, then run "quake -c"
08:27bortrebquestion: I want to sign the contributor agreement, but how do I fill out the form
08:30bortreblike, do I put under project name, github? or clojure-contrib? help pls...
08:30bortrebgfrlog: you also have to change quake-conf too, sorry
08:36raekbortreb: project name should be "clojure", "clojure-contrib" or both
08:37lozhAnyone know if emacs/slime/paredit has something to comment out the top level form your point is in?
08:37raeksome of the things listed on the page didn't have their own fields, so I wrote them on a blank space on the paper
08:37bortrebbut it also says to include your assembla and github usernames, so how would he know which is which?
08:38bortreboh ok
08:38gfrlogbotreb: I think your server has stopped responding
08:38gfrlogI got 58% through the download
08:38raekI wrote something like "github username: raek" "assebla username: raek"
08:38bortreboh noes maybe wget -c ? let me look for a sec
08:38raekthis form will not be read by a machine
08:39gfrlogI also tried loading it in a browser initially, and that didn't work either
08:39raekso, anything a human can understand will do, I suppose
08:39bortrebyeah, I'm being silly
08:41raekwell, the form does not contain all fields...
08:42bortrebmaybe a pdf on the website showing one acceptably filled out would allievate confusion
08:43bortrebwow my server actually did crash
08:45gfrlogand just now wget retried so many times that it just spit out "Giving up." and stopped
08:46bortrebserver's back
08:46gfrlogalso for some reason after each try it said "probes.tar.bz2 has sprung into existence." -- I'm not sure what that means
08:46gfrlogand it's done
08:46gfrlogthanks
08:47gfrlogheading out now
08:47bortrebsee ya
09:35brandonwhmm
09:35brandonwoh i think i have been unbanned :)
09:36brandonwi 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
09:40raekwelcome back
10:05brandonwunless technomancy worked his magic and somehow got me unbanned :)
10:23eckrothI 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:24ztellman(update-in hash [:xs] #(conj % x))
10:26eckrothztellman: ah perfect, thanks
10:26ztellmaneckroth: no problem, I always thought that was really awkward until I discovered update-in
10:26eckrothztellman: exactly
10:28chouser,(update-in {:a [1]} [:a] conj 2)
10:28clojurebot{:a [1 2]}
10:28mefestodoes it also work w/out the annonomus func?
10:28chouseryou don't need the anon fn
10:28ztellmanchouser's right
10:28ztellmanI always use anonymous functions, but that's a bad habit
10:36rbehi
10:37rbecan someone point me to a documentation for &v (without space) please?
10:37lozhslighly unfortunate that #(fn x %) is shorter than (partial fn x)
10:40rbe,(binding [a 111] (let [[&a b] [1 2]] (list a b)))
10:40clojurebotjava.lang.Exception: Unable to resolve var: a in this context
10:40rbethis works in clojure 1.2
10:40rbe(111 2)
10:41eckrothchouser: thanks; right after I replaced the pattern with update-in, your comment let me delete a lot of #(... % ...) :)
10:41chouser:-)
10:41raek,(binding [a 111] (let [[& a b] [1 2]] (list a b)))
10:41clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form, only :as can follow & parameter
10:42raeknevermind
11:00BahmanHi all!
11:00LajlaAhh, Bahman, my one true love, let me worship Your Shadow.
11:03Lajlattmrichter, ahh, my one true love, never did I love one such as I do you.
11:03ttmrichterKeep it down! My wife's like two feet away from me!
11:06Lajlattmrichter, ah, your wife, my one true love, never had I loved one such as I love her.
11:25tashafahello all
11:25wakko10warnerdoes anyone here know how to get bobot++ to run with free node.
11:26wakko10warnerI think that bobot++ allows lispy scripting and I want to use it.
11:26cemericktashafa: my gawd, he's got voice! ;-)
11:27wakko10warner,(println "help wakko with bobotpp")
11:27clojurebothelp wakko with bobotpp
11:29tashafacemerick: finally figured it out
11:32dnolenlancepantz: ping
11:32tashafacemerick: your tweet about irc and clojure highlighting made me try again
11:32cemerickheh
11:35cemericktashafa: 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:01tashafacemerick: ha
12:39jfields,(do (defn x [{y :k} {z y}] z) (println (x {:k :v} {:v :s})))
12:39clojurebotDENIED
12:41raek,(let [x (fn [{y :k} {z y}] z)] (println (x {:k :v} {:v :s})))
12:41clojurebot:s
12:44bortrebSo I've been trying to get clojure to work as a command line scripting language for some time
12:44bortreband finally came up with this pun that gets it to work
12:45Raynes-> (def x (fn [{y :k} {z y}] z))
12:45sexpbot=> #'net.licenser.sandbox.box3508/x
12:45Raynes-> (println (x {:k :v} {:v :s})))
12:45sexpbot=> :s nil
12:45bortreb":";exec java -cp '.:./lib/*' clojure.main $0 $*;
12:45bortrebwhat do you guys think?
12:45bortrebjust replace the #! with ":"; and everything works
12:46bortrebI got the idea from http://www.emacswiki.org/emacs/EmacsScripts
12:46raekbortreb: seen this? http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure
12:46raekI dunno what works best
12:46jfieldsraek, you got the idea for what I was trying to do
12:47jfieldsI'm destructuring once and using the result to destructure again, is that insane or expected?
12:47jfieldsI'm deciding if I want to do that in my prod code.
12:47raekbut I guess this has ben thunk upon before
12:49raekbtw, that example is a bit outdated... clojure.lang.Script is not used anymore
12:49bortrebusing a #!/usr/bin/env clj directly is lame because you have to have your own clj executable
12:50bortreband 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:51bortrebtheir rediculous three line thing works but is equivalent to my ":";
12:51jstirrell`test
12:54bortrebshould I add it to the wiki or is it bad ?
13:01jstirrell`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:01jstirrell`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:04bortrebcan you give an example?
13:04nickikI don't get what you want to do with this data
13:04nickikyeah plz
13:06jstirrell`shure
13:07jstirrell`I'm parsing an html page which has a number of messages on the page
13:07jstirrell`I end up with a bunch of hashes, each with a type corresponding to a div on that page
13:08pdkhm can you try pastebinning the code with some sample data to run it on that doesn't reveal anything secret about the project
13:08jstirrell`sure (nothing's really secret, just trying to make it as easy as possible to explain :)
13:17jstirrell`http://pastebin.com/2QhKhuNp
13:17jstirrell`ok so that is just the printed seq i'm working with
13:17jstirrell`the first represents the date (and time but i don't need the time here)
13:19jstirrell`after that the seqs alternate between messege-sender and message-text until the next day is reached
13:19jstirrell`I would like to end up with a sequnce of hashes that look like {:date "blah" :time "blah
13:20jstirrell`" :text "blah" :sender "blah"}
13:21jstirrell`This is my first miserable attempt: http://pastebin.com/HPFUZCc7
13:24pdkdo you have the input you fed to that code to produce the result you got in the 2nd pastebin jstirrell`
13:25bortrebI'm still confused :( it looks like it always goes (time, from, text) or is that not the case?
13:26jstirrell`pdk, the first pastebin is what the result of the first binding in the loop looks like
13:27pdkhm do you mean it's output or is that what you fed to it in a sequence
13:27jstirrell`bortreb, it goes (date, time, from, text, time, from, text, time, from, text ... ,date, time, from, text,
13:28jstirrell`that's just the output of another function i used to print the relevent results of the parsed html
13:29jstirrell`so yeah that would be what i'm feeding the function I'm trying to create here
13:30bortrebcan you have two dates in a row?
13:30jstirrell`no
13:30jstirrell`the dates only show up if there are messages for that date
13:30jstirrell`and the messages for a date will be "under" that date
13:31bortrebok
13:31bortrebthen how about starting off with (partition-by date? your-sequence)
13:32jstirrell`yeah actually that makes a lot of sense :)
13:32bortrebthen you get a sequence of (date not-dates)
13:32jstirrell`cool yeah then it should be easy to assoc the rest with that date
13:33bortreboh it doesn't actually do what I thought
13:33pdkhmm
13:33bortreb,(partition-by even? [2 1 1 1 2 1 1])
13:33clojurebot((2) (1 1 1) (2) (1 1))
13:34bortrebbut still very close
13:34pdkis it considered bad form to use let within a doseq if the let binding values are based on the iterator of doseq
13:35bortreb,(partition 2 (partition-by even? [2 1 1 1 2 1 1]))
13:35clojurebot(((2) (1 1 1)) ((2) (1 1)))
13:35bortrebeven better
13:35jstirrell`sweet yeah i THINK i should be able to figure out something from that, thanks for the help
13:36bortrebno problem :)
13:39raekjstirrell`: this is an idea I had: http://gist.github.com/495481
13:40raekwarning: not tested, but compiles
13:40raeka more "manual" solution, perhaps
13:41raekthis keeps "state" in form of parameters
13:57canderaCan anyone tell me why my catch block in this http://gist.github.com/495545 isn't working?
13:57canderaI would expect the fn to return nil, but it throws.
13:59mefestoi'm not sure _why_ but the NumberFormatException is wrapped in a RuntimeException
13:59raekah, this makes sense...
13:59mefestoand the try/catch isn't catching RuntimeException
13:59raek*map* is lazy
14:00canderaI saw the RuntimeException, but sort of ignored it figuring it to be REPL noise.
14:00raekthe exception gets thrown after the nfe-test call is done
14:00rshwhat is the name of that function that takes a seq and a value, and inserts that value between each element of the seq?
14:00raek...when the repl forces the lazy-seq to realize
14:00raekrsh: interpose
14:00rshthanks
14:00canderaraek: No, in this case I would think the call to every? would force the seq.
14:00bortrebbeat me to it
14:01canderaI get the same results with a doall in there.
14:01raekhrm
14:01raekthe lazy-seq catches the exception anyway
14:02raekit doesn't know that it is evaluated in the try-catch
14:02mefestoi think fn's need to wrap checked exceptions
14:02canderaThat said, catching RuntimeException *does* work properly, so good call on that.
14:02mefestoincluding anon fns
14:02mefestobecause fn's need to be able to be used a Runnables which do not throw checked exceptions
14:02canderamefesto: Ah, okay, that sort of makes sense.
14:02mefesto... that's my guess anyway
14:02raekexceptions plus lazy sequences really don't work well together...
14:04canderaThanks!
14:06jweissI'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:07mefestojweiss: clojure.core/*ns*
14:07jweissahh
14:07mefestowhen you switched ns it didn't include clojure.core
14:08jweissalso, in my code, how do i refer to the namespace that the code is part of?
14:08raekjweiss: if you use ns instead of in-ns, it will create the namespace if it doesn't exist
14:08jweissi could refer to it by name, but if i rename the namespace i have to edit in more than 1 place
14:08jweissraek: i think in-ns creates it
14:09raekhrm...
14:09raekbut ns does the refer-clojure part?
14:10mefestoraek is right, it'll implicitly refer 'clojure unless otherwise specified
14:11technomancywhat's the regex character class for "all letters, unicode-aware"?
14:13NikelandjeloCan somebody explain, why does candera's example http://gist.github.com/495545 throw RuntimeException instead of NumberFormatException?
14:14NikelandjeloAs I understande it wraps NumberFormatException in RuntimeException. But why?
14:15raektechnomancy: I think it is \p{L}
14:15raekjust looking at http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html
14:15raekL is the unicode class for letters, anyway
14:15technomancyraek: thanks!
14:15technomancybummer that \w doesn't just DTRT
14:16KaaliIs there a way to load a clojure library dynamically to a swank session? I guess I should modify the classpath somehow?
14:17raeka library that was not on the classpath before?
14:18KaaliYes
14:18KaaliJust downloaded criterium git repository, and don't really want to add it to my project.clj.
14:19KaaliNor do I want to restart my swank session.
14:19raekI know that it is possible to do some ClassLoader magic, but I have never done it
14:19raekyou have the source?
14:19KaaliI noticed that add-classpath is deprecated
14:19qbg,(doc add-classpath)
14:19clojurebot"([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
14:20raekthen one possible solution is to eval all the files by hand...
14:20raeknot very fun to do, though
14:20KaaliYeah, it will be more convenient to restart my session than that ;)
14:20technomancyKaali: 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:21raekyes, what about putting it in your src/ dir temporarily?
14:21Kaaliraek: That sounds like a workable solution
14:21raekthen require it and then delete it
14:23KaaliNice and "clean" solution.
14:24raekwhy was add-classpath deprecated anyway?
14:25raekit can obviously be useful when doing dynamic development and a new lib has to be added to the classpath
14:25qbgIt doesn't add it to the system classpath
14:26qbgThat can cause a few issues IIRC
14:29rshis there a built in case statement in 1.2 that doesn't throw an error when nothing matches?
14:29nickikhow do i atach a docstring to a (fn ....)
14:30NikelandjeloIf any exception is thrown in map function it always throws RuntimeException. Is it specially designed?
14:30qbgrsh: case takes a default expression argument
14:31slyrusraek: 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:33qbgnickik: Why do you want a docstring on an anonymous function?
14:33raeknickik: docstring usually go on the metadata of the var
14:33raek,(meta #'inc)
14:33clojurebot{: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:34raek,(meta inc)
14:34clojurebot{: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:34raekin newer versions, fns can have metadata too
14:34raekthe vars are generally where one would look for it
14:36nickikI have a macro that does something like (def NAME (A-FUNCTION (fn .....) other stuff)) and i want a docstring on that
14:36mefestoNikelandjelo: LazySeq wraps any exception in a RuntimeException
14:36mefestoNikelandjelo: http://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazySeq.java#L37
14:36qbgnickik: Then you put the docstring on the metadata of NAME
14:37Nikelandjelomefesto: I see
14:38jweisswhat's the diff between (defn ^{:foo :bar} [] :baz) and (defn #^{:foo :bar} [] :baz)
14:38Nikelandjelomefesto: 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:38raeknickik: http://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/def.clj
14:38jweisslooks like the reader macro is different in the docs than when i wrote this metadata
14:38raekthose are examples of how this has been done before
14:38qbgjweiss: The second is deprecated in 1.2
14:38mefestoNikelandjelo: only if it throws a checked exception, i think subclasses of runtime exception will just pass through
14:38seancronCan anyone tell me why my agents are not working in http://gist.github.com/495738 ?
14:39jweissqbg: ok so just the ^ is the 'correct' way?
14:39qbg^ is the idiomatic way now
14:39jweissk thx
14:39qbgIt looks nicer too
14:40nickiklike this (fn ^"BLABLA" ....)
14:40Nikelandjelomefesto: It doesn't work in both case: NullPointerException (unchecked) and IOException (checked)
14:40Nikelandjelomefesto: if I want to catch them
14:41mefestoNikelandjelo: I guess all exceptions then :(
14:51NikelandjeloIs handling exception in java way is idiomatic in clojure. Or it exists only for some kind of compatibility?
14:53KaaliThere 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:55nickikMy macro produces this as a output. How can I add a docstring here? (def cdoubler (with-constraints (fn ([n] (* 2 n))) positiv))
15:01technomancyNikelandjelo: it's idiomatic to use Exceptions, but creating your own Exception subclasses is usually inadvisable.
15:01technomancysee clojure.contrib.condition and error-kit for better ways to handle that problem
15:03Nikelandjelotechnomancy: I'm asking because map is one of the popular functions (imho) and handling exception with map seems to be ugly
15:04Chousukenickik: you'll need to attach the :doc metadata to the cdoubler symbol in your macro
15:04Chousukenickik: using with-meta
15:05Chousukenickik: but that looks a lot like a precondition, are you aware of that feature?
15:05nickikim working on the lib to make pre and post conditions usful
15:05nickik:)
15:05nickiktrammel
15:05ChousukeI see.
15:06seancronCan anyone see why my agent send-off is not working in http://gist.github.com/495738 ?
15:06nickiki hoped to avoid the (with-meta )
15:07cmihaiHi. 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:07Nikelandjeloseancron: Does it trow exception?
15:07cmihaiActually, is there some authoritative documentation on the subject? All I've managed to find so far was umh.. let's just say confusing.
15:07seancronNikelandjelo: Nope. It doesn't change the state at all
15:08Chousukeseancron: did you test lookup-dns outside an agent?
15:08Chousukeseancron: ie. does it actually work :)
15:08seancronChousuke: Yeah. It worked before with just one host. I'm trying to make it support multiple host lookups
15:08Nikelandjeloseancron: Why don't you pass host into send-off?
15:09ChousukeNikelandjelo: the host is the agent's value
15:09raekcmihai: the official docs for swank-clojure http://github.com/technomancy/swank-clojure
15:09raekswank-clojure.el
15:09raekPrevious 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:09Chousukeseancron: why are you using agents for something like that though? seems a bit overkill to me.
15:10NikelandjeloChousuke: Oh, sorry :)
15:10Chousukeseancron: I mean, the code pattern looks a bit suspicious to me
15:10Chousukeseancron: oh, hm, are you sure there is no race in the cache clearing that might be giving you errors?
15:11seancronChousuke: 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:11seancronChousuke: I've tried it with just one host and it doesn't work either
15:13seancronChousuke: If you can think of any other ways to lookup the hosts concurrently I'd be glad to hear them
15:14Chousukewell it seems like you could just use futures
15:15Chousukethat 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:16raekcmihai: my tip to get slime and swank working is to start swank outside emacs as described in the link
15:16raekand the use slime-connect from emacs to connect to it
15:17raekbeware that there are a lof of outdated tutorials 'round the net
15:17raekthe getting started guide on clojure's wiki should be up to date too
15:18seancronChousuke: My ultimate goal is to do these lookups every 10 seconds and log the results in a CSV file
15:19cmihairaek: 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:19raekcmihai: how do you indend to start swank? manually?
15:20cmihaiManually, elpa, git builds, some script from the internets.. tried it all :-)
15:20raekdo you use leiningen or cljr?
15:20cmihaiJust finished setting up cljr now.
15:21cmihaiStill haven't gotten into lein yet.
15:21raekI have unfortunately never used cljr, but I know how to get it working with leiningen
15:21raekyou could use it to download the latest version of swank-clojure
15:22cmihaiWhich fork? I got technomancy's git hub, but I'd need to build that :-).
15:22raekhttp://clojars.org/repo/swank-clojure/swank-clojure/1.2.0-SNAPSHOT/swank-clojure-1.2.0-20100308.145053-1.jar
15:22cmihaiKind of an issue, since I haven't used lein and such before :-)
15:22raekthere are jars on clojars
15:23raeklein will automatically download the jar files you need
15:23raekbut you could download that and use it
15:23seancronChousuke: Do you think the problem might be that lookup-dns returns 0 on a successful lookup?
15:23raekand then start a repl with "java -cp clojure.jar:clojure-contrib.jar:swank-clojure.jar clojure.main"
15:23cmihaiAha, thanks, found the jars :-)
15:24raekthen you'll have to run something like:
15:24raek(ns my-app (:use [swank.swank :as swank]))
15:24raek(swank/start-repl)
15:25raekthen you should be able to connect to it with emacs using slime-connect
15:25cmihaiThanks mate :-). I'll give that a try then.
15:25raeknp.
15:26Chousukeseancron: er, right?
15:26Chousukeseancron: the return value of the function you send to an agent becomes the agent's new value
15:26Chousukeseancron: so the agent's value on a successful lookup would of course be 0
15:27Chousukeseancron: if that's what the function returns
15:28seancronChousuke: Yeah. Never mind. I thought returning a 0 might be causing an error.
15:29Chousukeseancron: you could try running agent-errors on the agents to see if there are any exceptions thrown in lookup-dns
15:35seancronChousuke: No exceptions. agent-error returns nil
15:39chouserthis is rather intriguing: http://olabini.com/blog/2010/07/preannouncing-seph/
15:39chouser"Seph will steal/has stolen Clojures persistent data structures, all the concurrency primitives and the STM."
15:46Chousukeseancron: hmm :/
15:49seancronChousuke: I'm not committed to using agents. Do you think futures is a better choice for this type of parallel dns lookup?
15:54Chousukeseancron: 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:55Chousukeseancron: 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:58cmihaiSorry, still can't figure it out, with cljr or leiningen (which I can't figure out how to run...)
15:59cmihaiI'm guessing it needs more stuff in CLASSPATH
15:59technomancycmihai: are you on Windows?
15:59cmihaiLinux
16:00technomancyit's very easy to run Leiningen if you're not on Windows. what problems are you having?
16:00technomancyI mean, to just install and run it. It may be tricky to do certain things.
16:01seancronChousuke: Well I want to repeatedly lookup the hosts to see when they're up or down
16:02cmihaihttp://paste.lisp.org/display/112914
16:02cmihaiHm.. yeah, looks for 1.2.0
16:02technomancycmihai: did you follow the instructions for self-install?
16:03technomancysorry, I've just never heard of anyone having a hard time installing leiningen unless they were on Windows.
16:03technomancyneed to take off, but you can email the leiningen mailing list if you hit issues that aren't covered in the readme
16:04cmihaiK.
16:08cmihaiDid run self-install though.
16:08slyrusanyone around use fnparse?
16:08cmihaiAha, the jar files are corrupt
16:08slyruscmihai: are you trying to self-install from the git HEAD?
16:08jfieldschouser, 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:09cmihaiNo, I used the self-install command, but the downloaded jars are full of html :-)
16:10slyrusyes, but you used the self-install command from some particular version of leiningen. if that was the head, it won't work.
16:10cmihaiAha the jar contains: Octocat is sad That page doesn't exist!
16:10cmihaiFuck me.
16:10slyrusyou need to check out a pre-1.2.1 version, do lein self-install, then I think you can checkout master
16:11slyrusthere's no jar for 1.2.1 in the repo. I was griping at technomancy about this yesterday. it's a trivial fix.
16:11chouserjfields: wow, that's subtle
16:12chouserjfields: 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:12jfieldschouser, 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:12chouseryeah
16:13chouserI can see that it could be useful, but we usually think of fn args as binding simultaneously.
16:13chouserand you're neatly skirting that little assumption.
16:14jfieldschouser, yeah, like you I didn't think it would work either, which is why I'm concerned that it wont always. =)
16:14cmihaiYeah, 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:15slyruscmihai: git checkout 3dc47c1382ae3f05e3ae79267d9d3aa3120b13d8 ; lein self-install
16:15jfieldschouser, 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:16chouserheh. ok.
16:16chouserI guess personally I wouldn't. It wouldn't be that hard to do the second part in a separate 'let', right?
16:17technomancyslyrus: it is documented now at least.
16:18slyrustechnomancy: ah, good.
16:19jfieldschouser, the actual prod code is: (defmethod decode :ack [_ {id :id} {order id}] (assoc order :type :ack :to :client))
16:21jfieldschouser, 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:22chouser(defmethod decode :ack [_ {id :id} ordermap] (assoc (get order id) :type :ack :to :client)) ; would be the "other way"?
16:22chouserer
16:22chouser(defmethod decode :ack [_ {id :id} ordermap] (assoc (get ordermap id) :type :ack :to :client))
16:22cmihaislyrus: Wow, amazing.
16:23jfieldschouser, yes.
16:23cmihaiI tried doing the same fix by hand, but failed with the -SNAPSHOT thing btw.
16:23cmihaiIt worked with the older git revision. Thanks a bunch
16:23slyrusyw
16:24cmihaiNow to remember what the hell I installed this for
16:24cmihaiInstalling thee things is like tracing a java error...
16:24cmihaiOh, right, getting swank-clojure working.
16:24cmihaiAnd that to get slime.
16:26technomancycmihai: so... why didn't you just use the install instructions in the readme? you don't need a checkout at all.
16:26cmihaiBloody hell, that was easy :-)
16:26cmihaitechnomancy: I'm pretty sure I did....
16:27cmihaiI think I must have gotten the wrong lein script at *some* point.
16:30cmihaiI 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:38slyruscmihai: I'm with you, man. I'm a big fan of (other than the name) the checkouts directory though!
16:40tomojdoes 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:41cmihaiYup.
16:42slyrustomoj: yes
16:42tomojleiningen itself has 27 deps
16:42tomojsounds like fun
16:42slyrustomoj: auto-dependency-chaining leads to things like leiningen having 27 deps! I view that as a bug not a feature..
16:43cmihaiGives 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:44tomojok, but when you actually want to run someone else's code or publish your code as a library?
16:44cmihaiAnd the way it failed (by downloading a .html page to a .jar without any kind of checking) was quite.. troublesome.
16:44tomojthat is troublesome
16:45cmihaiSo every time there's a dead URL or even a captive portal
16:45cmihaiI run the risk of nuking all my jars?
16:45raekcmihai: did you try to use the bare swank-clojure jar?
16:45raekdo get swank running, you really only need that one plus clojure and contrib
16:45raek...if you want to do things manually
16:47cmihaiTried with cljr swank, it wouldn't start. didn't bother to figure out what main class to load
16:48raekif you have the swank jar file, you can start swank by hand
16:48raekit's just clojure...
16:49raekthe main class is clojure.main to start the clojure repl
16:49cmihaiI mean with swank-clojure
16:49raekjava -cp 'dir-with-jars/*' clojure.main
16:49raekyou start it in clojure
16:49raekI don't think it has a main class
16:50cmihaiOh.
16:50cmihaiDidn't know that :-)
16:50raek(require 'swank.swank) (swank.swank/start-repl)
16:50raekit's under the section "embedding" in the swank readme
16:51raekwhich in this case should be read as "starting swank manually"
16:51raekthe most common way is to start swank with some tool that sets the classpath automatically
16:53slyruscmihai: 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:57cmihaislyrus: yeah, that worked, thanks.
16:59cmihaiI'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:59cmihaiShould not be too different from CLISP I guess. Documentation is kind of lacking though. Any books worth getting?
17:05cmihaiOh, and maybe a minor question, how can I use it a scripted interpreter? Eg: send it something like clojure '(+ 3 1)'
17:09raekjava -cp 'yada yada yada' clojure.main -e "(+ 3 1)"
17:10dnolencmihai: 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:10dnolenand supports: cake eval '(println (+ 4 5))'
17:11dnolenI'm an Emacs person myself, but cake opens so doors for people who prefer text editors like TextMate
17:13dnolenhttp://github.com/ninjudd/cake
17:13lancepantzdnolen: i saw your github tickets, are you using the gem install?
17:13dnolenlancepantz: everything is working beautifully now, ninjudd dropped a bunch of patches, 0.3.4 is slick
17:15lancepantzdnolen: 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:16cmihaiI'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:16lancepantzcake supports swank as well
17:17lancepantzC-c C-k updates the persistent jvm as well
17:17cmihaiGot a url handy for cake btw?
17:18dnolenlancepantz: 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:18lancepantzhttp://github.com/ninjudd/cake
17:18cmihaiAh, emacs-cake not clojure?
17:19cmihaiOh. :-)
17:19dnolenI'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:20cmihaiStrange, I grepped github for cake written in clojure and no hits.
17:24Lajlaahh, technomaz, I have crossed oceans of time to be with you.
17:30jweissI'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:33greghstart with a function that takes a result set and a sequence of tests, and runs the first test in the sequence
17:34greghcall itself recursively with the new result set, and the rest of the sequence of tests
17:34greghstandard initial and termination conditions apply
17:34jweissgregh: ok, that's pretty much what i have now, minor quibble between a recursive fn and loop/recur
17:37greghyeah, it's a pretty fine line
17:38greghclojure provides loop/recur as a limited version of tail recursion just because the jvm doesn't allow the real thing
17:40jweissyeah i was thinking more along the lines of a function like map, where it makes a lazy seq of results
17:40pdk,(binding [x 1] x)
17:40clojurebotjava.lang.Exception: Unable to resolve var: x in this context
17:40pdkthat is so dumb
17:41pdk(doc binding
17:41clojurebotEOF while reading
17:41pdk(doc binding)
17:41clojurebot"([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:42pdkok whats the workaround
17:42dnolenpdk, *already existing* vars
17:42pdkah heh figures
17:42jweissit probably fails in the init
17:42pdki saw some little footnote on the site that said root bindings were optional and i guess i took it out of context then
17:43pdkprob applies to something else
17:51shooveris 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:57technomancycmihai: the problem is that curl silently fails on 404s; I thought it would give an error message
17:58technomancycmihai: could you create a bug report?
17:58technomancy(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:09lancepantzis 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:11lancepantzi'm playing around with difform, it has contrib 1.1 as a dep all for a single one line function
18:11technomancycmihai: anyway, what I meant about the instructions is that it works better if you download the stable version of the lein script
18:11lancepantzso then i end up with contrib 1.1 and 1.2 in as well as a clojure 1.1 jar in my lib
18:12technomancyslyrus: I'm not sold on the name of the checkouts dir; open to suggestions
18:12slyruslib-src?
18:16jweissis there a more concise way to express (if x x 0) ?
18:16jweisswell that's pretty concise, but more obvious i guess
18:16cmihaitechnomancy: Yeah. I'll dig a bit deeper tomorrow, I'm shutting down for the night now :-).
18:17technomancyjweiss: (or x 0)
18:24neotyk,((fn [f & {:as options}] (f options)) (fn [& {:as options}] (println options)) :a 1)
18:24clojurebotjava.lang.IllegalArgumentException: No value supplied for key: {:a 1}
18:25neotykHow do one make {:as options} fall through?
18:28neotykin example :a 1 gets converted to map, is there a way to splice it?
18:33arohnerneotyk: I don't know what you mean by fall through or split it
18:39slyrushmm.. in what interface would I find second?
18:41neotykarohner: ((fn [& {:as a}] (println a)) :key "value")
18:42neotykso :key "value" gets converted to map named a
18:42neotykwhat if from that fn I would like to call another fn with [& {:as
18:42neotyk*** a}] ?
18:43neotykhow would I splice a that was converted from :key "value" to
18:43neotyk*** {:key "value"} back to :key "value"
18:46arohneroh, apply
18:47arohnerhrm, though that gets weird with maps
18:47slyrusor, put another way, what interfaces do I need to support s.t. (let [[x1 x2] my-obj] ...) works?
18:47slyrusI thought nth would be enough, but apparently that's not the case
18:48slyrusoh, I think I need to support next
18:48neotyk,((fn [f & {:as options}] (apply f options)) (fn [{a :a}] (println a)) :a :b)
18:48clojurebotnil
18:49neotykwould expect :b
18:49neotyksorry, not that example
18:51neotykhere it is
18:51neotyk,((fn [f & {:as options}] (apply f options)) (fn [& {:as options}] (println options)) :a :b)
18:51clojurebotjava.lang.IllegalArgumentException: No value supplied for key: [:a :b]
18:53arohner,((fn [f & {:as options}] (apply f (flatten (seq options)))) (fn [& {:as options}] (println options)) :a :b)
18:53clojurebot{:a :b}
18:53arohnersince it's a map, you need to flatten before applying
18:53arohnerif those were seqs/vectors, the flatten wouldn't be necessary
18:53neotykarohner: thank you very much :)
19:22lancepantzthis 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:09slyrusyay: (add-bond (reduce add-atom (make-molecule) [c1 c2]) c1 c2) finally works.
21:03aldebrnI 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:04aldebrnWell, that example was horrible, I meant something involving escapes: (format #"{\em %s}" emph-statement)
21:08BahmanHi all!
21:20eckrothis there some advantage to using (fn) over #() ?
21:21rhudsonI'd say the longer the function, the more appropriate fn is
21:21eckrothrhudson: sure, because of the % issue
21:21eckrothrhudson: but is (fn [_] (blah)) better than #(blah) ?
21:22rhudsonalso, nested anonymous functions
21:22eckrothrhudson: like, in how its executed? performance difference? debugging issues?
21:23rhudsonThe reader translates the #() form into the fn form, so they run identically
21:23eckrothrhudson: ah ok
21:23rhudson#(blah) is better than (fn [] (blah))
21:24eckrothrhudson: I see in rhickey's ant code that he used (fn [_] (blah)) http://clojure.googlegroups.com/web/ants.clj
21:24eckrothrhudson: though perhaps that's no longer idiomatic
21:25rhudsonNote that (fn [_] blah) is a function that takes one argument that's ignored; #(blah) is 0-argument
21:25eckrothrhudson: but #(blah %) is 1-argument? so it checks inside and counts % ?
21:26rhudsonright
21:26rhudson#(blah %1 %2) is a 2-arg function
21:26eckrothrhudson: as is #(blah %2) I suppose
21:26eckrothrhudson: 2-arg that is
21:27rhudsonI would guess so; dunno
21:27eckroth,(#(print %2) 1)
21:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox$eval500439$fn
21:28eckroth,(#(print %2) 1 11)
21:28clojurebot11
21:28rhudsonhah
22:16lancepantzanyone know what i could have done to aquamacs that would make M-s print a beta?
22:19lancepantzwell, (setq mac-option-modifier 'meta) fixed it
22:57tomojlancepantz: was it a ß?
22:57lancepantzyep
22:58lancepantzdon't know how it got unbound, bizzare
22:58tomojthat's just mac's default thing
22:58tomojoption for extra characters
22:58tomojoh you mean the variable, dunno
22:58lancepantzyeah
23:18cais2002hi 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:19cais2002it does not happen for 1.2.0-beta1
23:37daakui've been searching for a bit, but can't seem to find any code coverage libraries, anyone know if one exists?
23:38lancepantzdaaku: i don't believe so
23:38daakulancepantz: cool, thanks
23:39lancepantzdaaku: 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:40daakulancepantz: i don't get how that would translate to code coverage info
23:41lancepantzit just made me assume that there wasn't a code coverage library
23:44scottjIs there a version of -> that with more than two args isn't defined in terms of itself?
23:46scottjand can you monkey patch functions? :) like add a new arity function to an existing one from core?
23:48tomojyou can, but you shouldn't
23:53ttmrichterThere's nothing wrong with monkey-patching that a good caning wouldn't solve.