#clojure logs

2011-02-01

00:02amalloysince it sounds like you just want the handy (for) bindings
00:29arohneramalloy: thanks for the hint. I ended up with (dorun (apply pcalls (for [foo bar] #(body...)))
00:29arohnerI needed to use #() rather than constantly, because constantly is a fn, so it evaluated its body
00:30amalloysure, constantly was just an example
02:13sritchiehey all -- does anyone have any advice on how to read floats out of a binary file with clojure?
02:14sritchiejava's DataInputStream is assuming that the file was written using floatToIntBits, which isn't the case
02:21amalloysritchie: floats, or doubles?
02:22sritchiefloats
02:22sritchieI have an array I usually read in python, using numpy's numpy.fromfile method
02:22sritchieI'm trying to use a datainputstream in java, but i think it's reading the bytes in backwards
02:22sritchieor, rather, opposite of what python does
02:24amalloysritchie: see the docs at http://www.scipy.org/Numpy_Example_List_With_Doc#fromfile
02:24amalloythey say not to rely on tofile..fromfile to store data as they will be stored in a platform-dependent way
02:25sritchieyeah, that makes sense --
02:25sritchieI'm actually reading this data set --
02:25sritchiehttp://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NCEP/.CPC/.PRECL/.dataset_documentation.html
02:26sritchieI just happen to have some working python code that uses fromfile
02:26sritchieI think java is just reading the bytes in backwards, from what python does
02:26amalloyso my guess would be that numpy is storing them in whatever order your processor happens to be using while java is using network byte order
02:27sritchieamalloy: do you know of any way I could specify a different byte order? I have to live with this data set, unfortunately
02:27amalloysritchie: flip the bits around yourself
02:29sritchieah, okay, i'll just use to-byte-array, then Float.intBitsToFloat(bits);
02:30amalloysritchie: that will be just as backwards since that's what datainput is doing already
02:30sritchiesorry, I meant I'll take four bytes at a time, flip them,
02:30sritchieand then feed them in to intBitsToFloat
02:30amalloyright, that's probably the way to go
02:31sritchiegreat, thanks
02:32amalloy&(Integer/toHexString (Float/floatToIntBits (float 66.6)))
02:32sexpbot⟹ "42853333"
02:33amalloy&(Integer/toHexString (Float/floatToIntBits (float 7.5))) is probably more useful :P
02:33sexpbot⟹ "40f00000"
02:34amalloysritchie: ^ is something to aim for in your bit-fiddling if it turns out to be more interesting than just reversing all four bytes
02:34sritchieyes, that's really useful
02:35sritchieamalloy: the next step is converting bytes from a byte array into a hex string
02:37amalloysritchie: plenty of implementations of that exist, but why do you need to?
02:38sritchieamalloy: I've got a byte array, and I was thinking that I'd need to take 4 bytes off of the front, and then combine them into a hex string to feed into intbitstofloat
02:38benreesmananyone had luck using ac-slime with swank-clojure?
02:38amalloyintbitstofloat doesn't want a hex string, though
02:38amalloyit wants an int
02:40amalloyand while i'm sure better solutions exist, i wrote https://github.com/amalloy/bit-packer for fun a while back and it would do what you want
02:41amalloy(unpack your-byte-array 256) will do the trick, if the bytes are in the right order (as mentioned in the readme)
02:43sritchiethis assumes big endian, right?
02:43tomojyou have a float, and then what?
02:44amalloyi can never remember which "end" big-endian refers to. it assumes LSB first
02:44sritchieI'm unpacking this binary file into 12 360x720 pixel arrays, where the float on each pixel is mm of rainfall in that .5 degree square on the earth's surface
02:44sritchieamalloy: yeah, I think it assumes what java assumes -- this obnoxious binary file has it backwards
02:44amalloysritchie: so? (reverse)
02:44tomojoh
02:45sritchieoh, reverse before the unpack then after would do the trick, wouldn't it
02:45amalloyum, you shouldn't have to reverse after...the whole point is that the bits are in the wrong order
02:46amalloy&(let [bytes (range 12)] (map reverse (partition 4 bytes)))
02:46sexpbot⟹ ((3 2 1 0) (7 6 5 4) (11 10 9 8))
02:47amalloyand if you had an unpack function, you could map (comp unpack reverse)
02:47amalloybrehaut: if you're looking for reasons to cry, i made take-randnth actually lazy at https://gist.github.com/805546
02:48sritchieamalloy: ah. it's late... I was thinking that each float was reversed,
02:48sritchiebut the order of the whole thing was correct
02:48amalloyeach byte, you mean?
02:49sritchieeach group of four bytes
02:49sritchiethat each float, when converted to bytes, was serialized differently in java vs whatever wrote this particular binary file
02:49amalloyyes, that is the assumption under which we are operating
02:50amalloysuppose that java writes its float as 0x12345678. then, if endian-ness is the only problem, numpy is probably writing it as 0x78563412
02:50sritchiewell, my first groups of four bytes, probably the first few thousands floats, are (0 -64 121 -60)
02:51sritchiethat matches python, if I set numpy to byte format
02:51amalloyand what float does numpy think that represents?
02:51sritchie-999
02:55sritchiemight be time to sleep on this one
02:55sritchieI feel like that's NaN
02:55amalloysritchie: well first of all you want to stop dealing with negative numbers. -64 is, i think, 0xC0, or 192
02:55sritchiejava's reading it as 1.7676097E-38
02:56amalloybut i could def be wrong there. it's been a long time since i looked at how two's complement works :P
02:57amalloysritchie: just (Integer/toHexString (.readInt datainput))
02:58amalloythat will show you what order it's reading the bytes in
02:58amalloythen you will know how to reorder them
03:00sritchiec079c4
03:00amalloyhey, i was right about 0xc0, at least
03:00sritchieyup!
03:01sritchiemight be time to sleep on this
03:02amalloyyeah, i've got to sleep too
03:02sritchiethanks for your help -- this seems simple, I'm just exhausted
03:02sritchieI'll play with the numpy representation tomorrow and this, and see what I find
03:02amalloygood luck
03:02sritchiethanks, man
03:24brehautamalloy: belated :'(
03:24amalloybrehaut: yeah, i'm really trying hard to find a non-awful way to write this
03:25brehauta real unfoldl might help a bunch i think
03:25amalloybrehaut: yeah, i'm writing it with unfold as we speak
03:25amalloyit's shorter but arguably more complicated
03:25brehautwhy isnt unfold in the core?
03:26amalloybrehaut: beats me
03:27brehautim sure theres a good reason though
03:28amalloybrehaut: https://gist.github.com/805583v with unfold
03:28brehauthuh. github is 404ing on that
03:28amalloyoh
03:28amalloyhttps://gist.github.com/805583
03:28amalloyi accidentally pasted a v at the end there
03:29brehauthuh. done? makes a bunch of sense in the absense of proper maybe
03:29amalloybrehaut: what?
03:30brehautoh sorry. in unfold
03:30brehautim more familiar with the haskell version, where the next fn returns a maybe
03:30amalloyright, i know what done? you're referring to, but i don't see the point youo're making
03:31amalloybrehaut: i implemented http://en.wikipedia.org/wiki/Unfold_%28higher-order_function%29#Anamorphisms_on_lists
03:31amalloyi'm not very familiar with haskell, but it looks like that's basically (defn ana [unspool finished x])
03:32brehautamalloy: http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-Sequence.html#v:unfoldl thats the one in haskell
03:33brehautsorry that was an epic sidetrack
03:34amalloybrehaut: ugh, i can't read these curried type definitions
03:34amalloyit's worse than lisp's dang parentheses :)
03:34brehauthaha
03:35brehauthaskells' precedence rules and ops are a head trip to start with
03:38amalloyanyway i'm not sure unfold makes the whole thing that much nicer
03:40brehautyeah apparently not
05:25clgvI try to compile my clojure library (code without a main method) with leiningen but it does not include any implementation file. what might I do wrong?
06:20fliebelmorning
06:20ejacksonwotcha
06:23clgvmorning
06:24fliebelclgv: Hi, I just read your message… I really thought I got it, with 4 and 6
06:25clgvfliebel: you can try to improve it by knowing the solution. as soon as it drops out, your criterion has an error ;)
06:26clgvfliebel: maybe I try a clojure solution next weekend ;)
06:27fliebelWell, I would rather like to know *what* makes my solution incorrect. In my opinion, it fits the constraints and the conversation perfectly.
06:29clgvhmm that's not easy since I have to go throught the argumentation and have a look when it drops out ;)
06:30fliebelclgv: Good, I'll try to find a way to figure out your solution, and then verify both min and the 'official' solution.
06:31clgvah I got the problem
06:31clgv4+6=10=2*5
06:32clgvuhm wait, I might have to reconsider.
06:40fliebelamalloy_: ping
06:43fliebelwhy doesn't rand-int take a start? ##(doc rand-int)
06:43sexpbot⟹ "([n]); Returns a random integer between 0 (inclusive) and n (exclusive)."
06:52gfrlog,(let [fliebels-rand-int (fn [a b] (+ a (rand-int (- b a))))] (fliebels-rand-int 10 12))
06:52clojurebot11
06:54fliebelgfrlog: I figured that out already, but I wonder why something that useful and simple is not in core.
06:54fliebel&(source rand-int)
06:54sexpbotjava.lang.Exception: Unable to resolve symbol: source in this context
06:56raekthis is bad: http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
06:56raekaffects clojure too
06:57fliebelraek: I figured that… I was about to try some other runtimes…
07:15clgvraek: oh thats suprising and will punch all those guys gloating about php in the face. bad incident for java ;)
07:22r0mantechnomancy: ping!
07:39gfrlogfliebel: Yeah, I agree.
07:42gfrlog,(let [map-from-fn (fn [f ks] (into {} (map (juxt identity f) ks)))] (map-from-fn inc [7 9 12]))
07:42clojurebot{7 8, 9 10, 12 13}
07:42Licenseraloa
07:43fliebelLicenser: hi
07:49fliebelgfrlog: What about functions taking multiple arguments?
08:51chouserYet another reason to use rationals instead of floating points
08:58gfrlogfliebel: to be the keys of a map, they'd have to be wrapped in a vector anyhow. So I think that would still work.
09:06robzorhave you guy seen this? works in clojure as well
09:06robzorhttp://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
09:07robzor(Double/parseDouble "2.2250738585072012e-308") goes in to an infinite loop
09:07clgvdid you try that one on sexpbot already? ;)
09:08robzoruhm
09:08robzorok
09:08robzor,(Double/parseDouble "2.2250738585072012e-308")
09:08clojurebotExecution Timed Out
09:08chouseryou don't even have to work that hard. what do you thing the reader does?
09:08robzorhurray for sandboxing
09:08clgvok safe programmed ;)
09:08chouser,2.2250738585072012e-308
09:08clojurebotExecution Timed Out
09:08clgv,2.2250738585072011e-308
09:08clojurebot2.225073858507201E-308
09:09clgv,2.2250738585072013e-308
09:09clojurebot2.2250738585072014E-308
09:09robzorif you look in the addendum of the blog i just linked, there's some other numbers
09:09cemerickThose evaluations are timing out from being reported, but I suspect the relevant worker threads in the execution pool will spin until hiredman bounces the bot.
09:09chouseryou don't think he kills the thread?
09:09cemerick(unless they're being .stop'ped)
09:10cemerickchouser: *dangerous* ;-)
09:10chouseryep
09:10clgvwould be really bad style if he reports timeouts but doesnt kill the execution
09:10cemerickclgv: a thread's execution cannot safely be halted on the JVM
09:10robzor"something went wrong but i'm not going to bother you with that"
09:11clgvcemerick: it doesnt have to be safely if it's timeout has been reached anyway. brutal killing will suffice ;)
09:12cemerickclgv: that depends on what global resources the thread in question is touching at the time of the .stop
09:12chouserthe question is, would it be desriable and possible to add a check to Clojure's reader to avoid passing strings that trigger that bug on to parseDouble
09:12Fossithat's just hiding the real problem
09:12Fossiso i'd say no
09:13chouserBut if it means Clojure programs can work more robustly until the JVM is fixed, is that not a win?
09:13robzorwould oracle fix this all the way back to 1.5?
09:13Fossiafaik there might also be a lot of other numbers which cause this bug
09:13Fossithe one being published is just an example of what i guess might be a bigger problem
09:14chousercemerick: if they are, we could save them. If they're using parseDouble directly, we can't help.
09:14Fossithen again i haven't checked the code
09:14chouseroh, it's already fixed in PHP.
09:15robzorchouser: yes, but how many servers out there are still running an ancient version?
09:16Fossii wonder how often people even have input fields that get converted to a double
09:17Fossisomething like clojure might be a little more "vulnerable", if people really use the reader
09:18Fossithen again as cemerick said it's prolly not such a good idea anyway
09:24AWizzArdcemerick: *lol*
09:25cemerickAWizzArd: ?
09:26AWizzArdcemerick: what you said 12 minutes ago. Just sounded funny :)
09:26cemerickah. :-)
10:42sritchiehey all -- I've written a multimethod to convert various types of arguments into a little-endian HeapByteBuffer, which I'm using as a float array. currently, two of the defmethods change an argument slightly and call the multimethod again -- is there a more idiomatic way to do this?
10:42sritchiehttps://gist.github.com/806027
10:42sritchiethere are the functions in question
10:44nurv101I have a question to the room
10:44nurv101is it possible to create a lisp closure in clojure?
10:55zvrbaare there block comments in clojure?
10:55tonyl(comment )
10:56tonylbut anything inside comment has to be valid forms
10:56zvrbaok, that's fine
11:10shortlordI am using sets of size 1 and 2 to represent different kinds of things (a set with 1 element being a single node and a set with 2 elements being a line between these 2 nodes). Now I often have to implement different method behaviours for single nodes and lines. I could always pass the used set as an argument and then use (case (count my-set)) to distinguish the behaviour or even use a multimethod with count as a dispatch func
11:10shortlordtion, but I guess it would be better to pass the elements of the sets as single argument and then use arity overloading to define the behaviour, right?
11:11shortlordIt would have the disadvantage that I'd have to convert between the set representation used in the datastructure and the call to the method which expect a different number of arguments, but that's still the more idiomatic clojure code, isn't it?
11:13zvrbathat sounds like a lot of overhead
11:13zvrbahow do you store those sets_
11:14shortlordzvrba: in a map. The sets are the keys and the vals are certain attributes of these nodes and lines
11:14zvrbauh
11:14shortlordperformance is not an issue, the maximum number of nodes is 54 and the maximum number of lines is 71
11:15shortlordzvrba: but how would you have done it instead?
11:15gfrlogwhy do you have a set of 1 element instead of just the element?
11:15zvrbaah, ok then
11:16gfrlogshortlord: also why not store the nodes and lines separately?
11:16zvrbashortlord: or, why store nodes at all?
11:16zvrbado you have isolated nodes?
11:17zvrbashortlord: otherwise, depends on the size of the problem. there are many different structures to represent graphs.
11:17zvrbashortlord: for example, use a map where a key is the node and the value is either the other node of the line, or nil if it's an isolated node.
11:17shortlordgfrlog: I had them separated before, I might have been quite a good idea after all ;)
11:18gfrlogshortlord: yeah; without knowing what you're doing, I would think it'd be easier to manually treat them the same when that comes up then to have to manually pull them apart
11:18zvrbaon a larger scale, instantiating a set for each edge/node seems like a lot of overhead.
11:18shortlordzvrba: yes, true. I guess I'll have to think about my datastructure a bit more
11:18gfrlogif that makes sens
11:18zvrba(space overhead)
11:18gfrlogsets are nice for edges when comparing equality; but there's probably a more performant option
11:19shortlordgfrlog: yes, the idea was to treat them equally in a number of situations, but these situations turned out to be a bit different, I guess I might as well handle them differently again
11:20gfrlog(concat edges nodes) is easier than writing multimethods
11:28gfrlog,(let [evens (iterate #(+ 2 %) 0), odds (iterate #(+ 2 %) 1)] (take 20 (concat evens odds)))
11:28clojurebot(0 2 4 6 8 10 12 14 16 18 ...)
11:28gfrloginfinite ordinals in clojure
11:43shortlordwhy is it necessary to put function definitions into parentheses when defining functions with multiple arities? It should be pretty easy for Clojure to figure out that a pair of params and body always makes one definition, similar to let, right?
11:45pdkyou can write things like (fn [x] (form1) (form2) ...)
11:45pdkwithout parens around form1 and form2 etc
11:47pdkso the extra parens disambiguate when you'd be adding a do form or something like that anyway for functions that don't follow the everything-inside-a-let-form format
11:48shortlordpdk: ah, function definitions contain an implicit do. Why is that the case? Although clojure is supposed to be used functional, using a do implicitly nearly everywhere seems rather imperative
11:49tonylI think he meant the (defn ([] (do-something)) ([x] (do-something-else)))
11:49pdkthey have an implicit do yes
11:49pdkthough in cases like what tonyl is showing
11:50pdksomething like (defn x [] (do-stuff) [x] (do-other-stuff))
11:50pdkthe lack of extra parens doesn't really help to distinguish for it whether the [x] is supposed to be a return value for the [] version or become the start of its own version of the function
11:50pdkso it cries
11:51shortlordpdk: I understand the problem, I was just surprised to find so many things in clojure having an implicit 'do', since do encourages destructive functions
11:52pdkhm there's something
12:05fliebelI love incanter :)
12:06jweiss,(apply list "" "")
12:06clojurebot("")
12:06jweissi don't get it ^
12:07technomancyjweiss: apply's last arg is treated as a seq
12:07fliebelSome nice scatter plots :) http://yfrog.com/7228285886p http://yfrog.com/7283555419p
12:07jweisstechnomancy: yeah i was just realizing that
12:08jweissso i guess i should wrap my args into a seq to begin with before calling apply
12:08technomancyif you don't have a seq already you don't need apply
12:08fliebeljweiss: Why would you call apply, if you don't have a seq of arguments?
12:09jweissfliebel: well, in my code i do have a seq
12:09fliebelah
12:10jweissthe error i'm getting is wrong # of args
12:10jweissthe first 2 args are empty strings in this case
12:11tonyl&(apply list "" "" ["wer" "gdf"])
12:11sexpbot⟹ ("" "" "wer" "gdf")
12:20edoloughlinAnyone using CounterClockwise had it go wierd for just one file? Syntax highlighting & colour parens still work but indentation, backspace, element selection are broken. Other files are unaffected.
12:34LauJensen&(double 2.2250738585072012e-308)
12:35fliebelLauJensen: Did you crash it?
12:35LauJensenfliebel: Yes
12:35fliebelclojurebot did this fine this morning...
12:35LauJensen,(double 2.2250738585072012e-308)
12:35robonoboyeah
12:35clojurebotExecution Timed Out
12:35fliebelsee...
12:35robonoboaha!
12:35LauJensenHmm...
12:35LauJensenThey both should do that. I think they use the same code almost
12:35robonobowould be weird if it did crash it
12:36LauJensen&(println "hello?")
12:36sexpbot⟹ hello? nil
12:36fliebelhuh...
12:36fliebeloh, right, threads...
12:36fliebelLauJensen: Maybe sexpbot kills the thread silently?
12:36LauJensenfliebel: yea I think so
12:36robonobois there a difference beteen sexbot and clojurebot?
12:36robonobowoops
12:36robonobosexpbot
12:37LauJensenrobonobo: Yes, big differences
12:38fliebel&(dorun (repeat 42))
12:38sexpbotExecution Timed Out!
12:38fliebel… huh?
12:49semperos^ is now preferred to #^, right?
12:51dnolensemperos: yup
12:51semperosdnolen: thx
13:06arohnerwhat do I put in my project.clj to download all of contrib-1.3? I have [org.clojure.contrib/complete "1.3.0-SNAPSHOT"]. That successfully downloads complete, but I don't see the other libraries in lib, and starting up complains about not finding org.clojure.contrib.shell
13:08mattmitchellaravind: [org.clojure.contrib "1.3.0-SNAPSHOT"] would probably do it
13:09mattmitchellaravind: sorry, this is what I have in mine: [org.clojure/clojure-contrib "1.2.0"]
13:11raekarohner: there's standalone too. I don't remember what the difference with complete was
13:11arohnerwell, it looks like one of my issues is that contrib.shell has disappeared
13:12raeknow that you mention it, I think clojure.java.shell has replaced it
13:13arohnerraek: aha! thanks
13:28jkdufairanyone have a setup they're happy with for developing/deploying to GAE?
13:29fliebeljkdufair: I heard appengine-magic is nice
13:29fliebelamalloy: ping
13:30amalloyfliebel: pong
13:30fliebelamalloy: I wrote and benchmarked a few take-randnth functions :)
13:31amalloyexciting
13:31jkdufairah! haven't heard of appengine-magic. will check it out. thx
13:32fliebelamalloy: https://gist.github.com/805747
13:33fliebelSo, there are the simple functions, which should be very bad, and then mine and yours, for the more complicated approach.
13:33jkdufairfliebel: wow! thank you
13:34fliebelamalloy: But as you can see in the graphs(linked), the first 2 do quite well.
13:34amalloyfliebel: neat, i'm looking now
13:35fliebelFirst graph is constant number of items from a growing vector, second is a growing number of items to take from a constant vector.
13:35amalloydid you check out https://gist.github.com/805546 and https://gist.github.com/805583, where i implemented it two more times myself?
13:35fliebelno...
13:35amalloythey're not that interesting really
13:36fliebelamalloy: Did you try them performance-wise?
13:36amalloynope
13:37amalloyi don't expect them to be any better really
13:37amalloyone was a lazy-taking approach, and one was writing it with unfold
13:39fliebelthe distinct one in my code is also lazy, but as you see in the second plot, it gets bad once n gets close to the length of coll.
13:43fliebelamalloy: How do you figure out this big o thing?
13:44amalloyfliebel: http://en.wikipedia.org/wiki/Big_O_notation#Example is a reasonable description
13:48ohpauleezIs Enrico Franchi in here?
13:48amalloyeg for take-rand3, (count coll) takes O(coll) time, (range nr) takes O(nr) time; each step in the reduces takes constant time, and there are coll + nr reduce steps, so the total algorithmic complexity is O(coll+nr)
13:49amalloyand the same is probably true of any similar implementation, including mine; the simple ones probably have smaller constant factors
13:50amalloyi think the main benefit of the complicated algorithm comes when (vec coll) is already passed in to you, so that you only have to do the O(nr) steps
13:51amalloyi'd be interested to see how that performs: create a large vector once, then call take-randnth on it many times. i dunno
13:51fliebelamalloy: What about nr 2? I can;t figure that one out.
13:53amalloy$source distinct
13:53sexpbotdistinct is http://is.gd/9IzW0R
13:54fliebelamalloy: The problem is that we have to deal with the probability that rand-nth takes a duplicate.
13:54fliebelalso, count on a vector seems to be constant.
13:54amalloyfliebel: yes, it gets murky
13:54amalloyand yeah, count is definitely constant there
13:54amalloybut in take-rand3, coll isn't a vec
13:55fliebelI pass it a vec...
13:56amalloyfliebel: i don't see that happening. plot-len and plot-take both pass it a (range foo), and the very first line of take-rand3 is (count coll)
13:56amalloybut it doesn't really matter, since there's an O(coll) step later anyway
13:57fliebelOh, I didn't put that in the gist yet, but I do.
13:57fliebelwhere?
13:57clojurebotwhere is your source code
13:58amalloyfliebel: (reduce f (vec coll))
13:58amalloyis going to have (count coll) steps
13:59amalloyer wait, those ->> forms confuse me
13:59fliebelamac: Wrong! Right!
14:00fliebelBut still, there must be something that gets worse with coll, otherwise the first graph would be constant...
14:00amalloy$source vec
14:00sexpbotvec is http://is.gd/jXPZMI
14:00ohpauleezIs reduce lazy, in that it'll only realize the next element of a lazySeq?
14:00amalloyoh, of course that doesn't say anything useful
14:00amalloyohpauleez: no
14:00ohpauleezamalloy: So it'll realize the full seq, just like apply?
14:01fliebelIt goes down to RT, which calls LazilyPersistentVector
14:01amalloyfliebel: (vec coll) is O((count coll))
14:01fliebelhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazilyPersistentVector.java
14:01amalloythanks
14:01fliebel… I'm trying that
14:02amalloyfliebel: i've often wondered why (vec [1 2 3 4]) isn't a no-op
14:02fliebelyea...
14:03amalloybut either way, (count coll) and (vec coll) are both linear-time
14:03amalloyohpauleez: i don't understand the question. realize which full seq?
14:03fliebelokay
14:03jkdufairis there some .emacs code i can use to start swank from within emacs (i.e. not have to launch another terminal)?
14:04fliebelamalloy: Bingo! removing the vec made 3 and 4 constant.
14:04amalloyfliebel: really? that's good, i think. can you link me to an updated gist?
14:04technomancyjkdufair: http://github.com/technomancy/durendal
14:05fliebelamalloy: You want updated plots as well?
14:05amalloyfliebel: if you want. i'm willing to take your word for it
14:06jkdufairtechnomancy: thank you!
14:07fliebelamalloy: https://gist.github.com/805747 http://yfrog.com/5r80779474p http://yfrog.com/mr42647628p
14:07technomancyno problem
14:08amalloyfliebel: excellent, just as we hoped
14:10fliebelamalloy: Still, picking and filtering random items, is faster for picking a small number of items from a larger vector.
14:10amalloyyeah
14:10fliebeluh, no, I mean… well
14:10amalloyfliebel: well, shuffling then picking
14:11fliebelright
14:11amalloyfiltering is not so hot
14:11fliebelI was talking about the red line, which is… the shuffle one.
14:12amalloyas N approaches M, the filter solution is probably O(N!), but figuring out what it's like in the middle is too hard for me :P
14:13fliebelamalloy: I think some math person in here explained something related to me once...
14:14fliebelSomething with birthdays and pigeonholes.
14:14amalloyyes, probably related to the birthday problem
14:14amalloybut more complicated i think
14:15fliebelSo, it will be O(N!@#$%M^&)
14:16amalloy*laugh* indeed
14:17fliebelI'll update the gist to reflect that...
14:17ejacksonfliebel: hilarious
14:19fliebelhttps://gist.github.com/805747
14:22jkdufairtechnomancy: great tools. thx a bunch.
14:32danlarkin$4
14:38ieuretechnomancy, What’s the accepted way of depending on a Java lib (with Leiningen) which isn’t in a public Maven repo?
14:38ieureI dropped it in lib/ and lein nukes it every time I run deps.
14:41danlarkinieure: it has to be in a repo
14:41danlarkinyour local .m2 cache is technically a repo
14:41amalloyieure: you can install it to your local repo
14:41ieureGross.
14:42ieureOkay.
14:42ieureCan I just cp it in there or what?
14:42ieureI don’t know fuck-all about the varied crazy Java build tools.
14:43ldhno, you've got to tell maven to install it. example: http://jeff.langcode.com/archives/27
14:45ohpauleezI basically have to sum a comprehension, and I've timed a few approaches, two have similar times and so I want to understand how they differ. One is doing (reduce #(+ (op-on %1)) coll), another is doing (apply + (map #(op-on %1) coll)), but the apply is going to realize the entire collection, and I have a situation where that collection could be extremely large. (amalloy)
14:47amalloyohpauleez: i think you made some kind of typo with your first example, but neither one of those will realize the whole collection at once
14:47ohpauleezoh really? I thought apply would
14:48ohpauleezamalloy: ^. Thanks though, I'll just go with which ever one is fastest then
14:48amalloynah, it passes a lazy seq as the &rest arg
14:48ohpauleezahh, cool
14:48amalloy&(apply + (range 1e6))
14:48sexpbot⟹ 499999500000
14:49ohpauleezthanks amalloy
14:50amalloy&(= (doall (range 1e6)))
14:50sexpbotToo much is happening at once. Wait until other operations cease.
14:50fliebelamalloy: Why was your php code using 2 arrays?
14:50amalloy*blink*
14:50amalloyRaynes: ping
14:50fliebelHm, I think sexpbot is having trouble with big numbers ;)
14:51amalloy$login
14:51sexpbotYou've been logged in.
14:51amalloy$reload
14:51sexpbotReloaded successfully.
14:51amalloy$logout
14:51sexpbotYou've been logged out.
14:51amalloy&1
14:51sexpbot⟹ 1
14:51amalloyfliebel: i suppose i could have done it with a single array
14:52amalloyuse the below-i chunk of the array to store the return value, and then split it when it's time to return
14:53fliebelright, that is what my reduce thing is doing. made me feel real smart for a moment :)
14:54amalloyfliebel: ahh, is that what's going on. your reduce was too clever for me
14:54fliebelamalloy: Your iterate was to smart for me...
14:55amalloyfliebel: it's funny, because i knew the classic algorithm involved swapping a[i] with a[idx], but i couldn't remember why, so i just didn't do it
14:59amalloyfliebel: are you sure take-rand3 selects uniformly?
14:59amalloy(reduce #(conj %1 [%2 (rand-int %2 len)]) [] (range n)) looks like it will be biased towards higher numbers, though i still don't see how it all fits together
14:59fliebeluhm, no… but not less uniformly than your code I think… I just collapsed your separate vector inot the unused part of the first vector.
15:00amalloyoh, i think i get it
15:00amalloyokay, clever
15:01fliebelamalloy: You might have trouble with my ->>, I'm having trouble with your nesting.
15:01amalloylol
15:01amalloyyou create a list of swaps first, and then perform them all in a row on the coll?
15:01fliebelyea :)
15:01tonylwhat gist is it?
15:01amalloyhttps://gist.github.com/805747
15:02amalloyfliebel: i like ->> as much as the next guy, it's just harder to read other people's code :)
15:03fliebelyea, but I think I understand your code now. *phew*
15:05amalloytonyl: your turn to write one
15:05fliebeltonyl: I second that :)
15:05tonylI am working on one
15:05fliebelgreat :)
15:05tonylare we looking for O(n)
15:06fliebelO(lean and mean) is what we want.
15:06tonylright
15:07fliebeltonyl: Have you seen the plots?
15:08tonylfliebel: I am looking at your post for that, are those the ones?
15:08fliebelyes
15:10amalloyfliebel: i love that immutability lets you write (assoc a i (a b) b (a i)) instead of needing a temporary swap area
15:10fliebel:)
15:11fliebelI wish update-in does that. or…. ##(doc update-in)
15:11sexpbot⟹ "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
15:11amalloyfliebel: what for? isn't that what assoc is for?
15:12fliebelamalloy: Wouldn't it be great if you could update multiple nested values in one go?
15:14fliebelBut yea, I am really starting to appreciate those little features. Same thing for map, equality and math operators.
15:14amalloy&(update-in {:a {:b 10 :c 5}} [:a] assoc :b 1 :c 2) is an approximation
15:14sexpbot⟹ {:a {:b 1, :c 2}}
15:14mfexhi, can anyone point me to the slides for mark mcgranaghans conj talk?
15:14amalloyyou can't easily operate on the existing values of :b/:c, afaik
15:15amalloyfliebel: i've wanted to be able to do that in the past, but someone convinced me it was a confused idea. if only i could remember why...
15:15fliebelhey, nr2 became O(M-ish) as well by removing the vec.
15:16amalloyfliebel: surely not if N ~= M?
15:18fliebelhmhm
15:18fliebelIt just that the vec does not make it increase anymore.
15:19fliebelpost updated
15:21fliebelI cant help seeing a patter like /// in the shuffle line. GC? Chunking?
15:22technomancyieure: I recommend setting up a private archiva instance for private jars if you've got a team of more than 1
15:23technomancyieure: if you're solo then you can add the dependency to project.clj even if it's not in any remote maven repos and run lein deps; it will give you a line you can use to put the jar in m2
15:23amalloyfliebel: gc i think. every one of the plots has those outliers
15:24amalloyshuffle probably feels the most impact because it's allocating a new M-sized array every time, even if you only need N elements out of it
15:25fliebelthat's true...
15:26fliebelAlthough I would expect to see out-of-line dots, as with the others, but what I see is more like a gradual decline in speed, and then a drop again.
15:27fliebeltonyl: How are you doing?
15:28tonylcan't make it any better then m+n
15:28tonylI need to learn more about clojure internals for this one
15:29tonylit's puzzling me, but good thought and clojure-training exercise
15:29fliebeltonyl: http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html
15:29fliebel(shift the headers >)
15:31fliebeltonyl: When you're done, I'd love to see your code.
15:32tonylthanks for the link, i have another idea. i will show the code for critique
15:33bartjI am looking for a soundex library and am thoroughly confused as to which I should pick
15:33bartjor even which is the most appropriate
15:33bartjbecause the soundex returned by the in-built mysql function
15:35bartjis different from that of Apache commons library - http://commons.apache.org/codec/apidocs/src-html/org/apache/commons/codec/language/Soundex.html#line.252
15:36amalloyfliebel: oh, i see, you mean in the plot-take, not plot-len
15:37fliebelright
15:37amalloyyeah, that is interesting
15:38amalloytonyl: you should certainly learn lein or cake. incanter is neat but i feel like i don't have enough uses for it to spend time learning it
15:39tonyli've used a personal bash script to run my clj scripts, but now projects getting bigger or managing dependecies is getting to be a problem.
15:39fliebeltonyl: crash course: lein/cake deps, lein/cake repl, lein/cake uberjar. incanter: (view (xy-plot xs ys))
15:39amalloyfliebel: don't forget lein/cake new
15:39tonylso no big differences between lein and cake, besides cake having a persistent jvm?
15:39amalloytonyl: mostly just different plugin frameworks
15:40amalloylein has optional persistent jvm too
15:40tonyloh ok
15:40raekthey are very similar for basic tasks. their plugin/task features are more different, though
15:40tonylI'll try lein first since it was the first one to come out
15:40tonylthen I'll test this code I have to see the scattering and time
15:40tonylfliebel: I
15:41tonylfliebel: I'll try not to keep you waiting to much for the code :)
15:41shortlordthere is nothing like select-keys or find that takes a pred instead of fixed keys, is there?
15:41tonylmaybe some can help you there
15:41fliebeltonyl: I have tea :) so, if you do it within a hour, I'm fine :)
15:41amalloyshortlord: filter
15:41fliebelOtherwise I'll see you tomorrow.
15:42shortlordamalloy: but filter does not return a map, but a sequence, which requires some ugly stitching together afterwards
15:42fliebelmeh, just (into {})
15:42amalloy&(into {} (filter (comp even? key) {1 2, 4 3, 5 6 8 7}))
15:42sexpbot⟹ {4 3, 8 7}
15:43amalloyfliebel: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle is apparently what the shuffle algorithm is called
15:43jkdufairjust want to say thanks to the whole clojure community. i got a production-ready GAE/slime/swank/clojure/cygwin setup together in a matter of hours and already have a hello world app on GAE
15:48shortlordfliebel, amalloy: thx, into {} together with some as the pred was exactly what I needed, great :)
15:50raekif you want to make it map type independent, you can do it like (into (empty m) (filter pred m))
15:57jweissanyone here use clojure.contrib.logging with java.util.logging? the method/line# logging doesn't work - it always prints "lojure.contrib.logging$impl_write_BANG_.invoke"
15:57jweissrather "clojure.contrib.logging$impl_write_BANG_.invoke"
16:06fliebeltonyl: Done yet? My tea is done, and I'm soon going to bed ;)
16:06tonylfliebel: I guess I'll bother you tomorrow then
16:07fliebeltonyl: Thanks :)
16:09semperos&(first "/")
16:09sexpbot⟹ \/
16:09semperoswhat's the right way to just have that char?
16:10ieureUgh.
16:10tonylsemperos: it seems that you have it
16:10ieureWhat am I doing wrong here? https://gist.github.com/a9aeeb52bfe1514b7b55
16:10ieure"No matching ctor found for class com.google.i18n.phonenumbers.Phonenumber"
16:10ieureNo idea what that is supposed to mean.
16:11semperostonyl: I do, but it seems a bit round-about to ask (first some-string) to "get" a single char
16:11tonylieure: means there is no constructor that just takes no arguments for that class
16:11tonyl&\/
16:11sexpbot⟹ \/
16:11semperostonyl: coulda sworn I tried that at the repl; thanks
16:11tonylsemperos: just prepend it with a \ ##\/
16:12bartjieure, I can help you
16:12bartjas a matter of great coincidence I am using the Phonenumber lib right now :)
16:12semperossame as with all char's, must have mistyped originally
16:12ieurebartj, Awesome.
16:12bartjieure, let me look at gist
16:13ieurebartj, I guess I’m supposed to use PhonenumberUtil.getInstance() to get an instance back.
16:13ieureFuckin’ Java.
16:13bartjoh, that is easy
16:14bartj(PhoneNumberUtil/getInstance)
16:14bartjhere is how to format phone numbers:
16:14bartj(.format (PhoneNumberUtil/getInstance) phone com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat/INTERNATIONAL)
16:14bartjwhere "phone" will be a number of course
16:14ieureYeah.
16:14bartjthis will return a Phonenumber class
16:15ieureThrows an exception, but I think I can thrash around from here.
16:15bartjyou would have to use (PhoneNumberUtils/getInstance)
16:16bartjok
16:16amalloytonyl: sexpbot only evals ##code that starts with parens, to avoid annoying people in ##java and similar channels
16:16tonylI figured it might be because of that
16:16ieurebartj, Is there a less insane way of saying "com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat/INTERNATIONAL"?
16:16bartjieure, yeah :)
16:17bartj(import-static com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat INTERNATIONAL)
16:17tonylaliasing it
16:17bartjand then
16:17bartj(.format (PhoneNumberUtil/getInstance) INTERNATIONAL)
16:17bartjI believe raek told me this a few days back
16:17amalloybartj: sweet, i always forget we have import-static
16:17ieureLooks like that’s not an option with the `ns' macro, though.
16:18amalloyieure: no, you have to do it separately
16:18ieureIs that a 1.3 feature?
16:19ieureUnable to resolve symbol: import-static in this context
16:19ieureOn 1.2.x.
16:19tonylit is in contrib
16:19ieureAh, okay.
16:19tonylhttp://clojuredocs.org/clojure_contrib/clojure.contrib.import-static/import-static
16:19mattmitchell,(doc defn)
16:19clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any do...
16:20amalloy&(doc defn)
16:20sexpbot⟹ "Macro ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
16:20markskilbeckDeja vu.
16:21mattmitchellmarkskilbeck: funny :)
16:25mattmitchellhmm, i'm trying to add :doc and :arglists to a defn. but (doc my-func) doesn't show anything
16:25mattmitchellis this correct? (defn t #^{:doc "test"} [] (prn "t"))
16:26tonyli think it is (defn ^{:doc "test"} t [] (prn "t"))
16:27mattmitchelltonyl: there we go thanks.
16:27technomancymattmitchell: (defn t "test" [] (prn "t"))
16:27ohpauleezmattmitchell: also what technomancy ^
16:27ohpauleezI think that's more widely used
16:27amalloyyes, for sure that is used most, but if you want to supply arglists you have to do it tony's way
16:28ohpauleezahh, yes
16:28brehautmattmitchell: the #^ is old style meta (pre 1.2)
16:28mattmitchellok i thought i read that somewhere.
16:32tonylgotta get some things done, nice talking to you guys
16:33ieureIs there a CSV library (or wrapper around a Java one) which will lazily read lines from *in*?
16:34ieureI found clojure-csv, but it seems to want the entire CSV to be read in as a string.
16:34ieureI guess I could parse one line at a time and always call first, but that seems somewhat ugly.
16:34raek(defn t "test" {:arglists '([foo bar])} [x y] ...)
16:38ohpauleezieure: http://clojuredocs.org/clojure_core/clojure.core/line-seq
16:38ohpauleez&(doc line-seq)
16:38sexpbot⟹ "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
16:39ohpauleeznot sure how you'd make sure you were processing the csv correctly
16:39ieureohpauleez, So, #1, this will not with with *in*, which is a LineNumberingPushbackReader, not a BufferedReader. And #2, I can already lazily read from *in*, it’s just that the clojure-csv semantics aren’t a good match.
16:39ohpauleezbut you might be able to write a nice small DSL, using the existing functions in the library
16:41ohpauleezieure: I was assuming you would just rebind *in*. Sorry for misunderstanding the question
16:41ieureNo, I want to read from stdin.
16:41ohpauleezthe answer is just see if the functions in the library are small enough for you to build up a lazy version of the DSL
16:42ohpauleezand then contribute the changes back to the project
16:42ieureThough it seems like I might be better off using with-open and/or line-seq.
16:42ieureI really don’t think I need to build up a DSL here.
16:43ohpauleezis this because you want to pipe the csv to it?
16:43ieureYes.
16:44amalloyieure: i think ohpauleez is using DSL to mean "library" here
16:44ohpauleezyes
16:44ohpauleezloosely using DSL
16:48ieureWell, I was hoping to avoid parsing command-line arguments, which was the main reason to use *in*
16:48ieureBut this LineNumberingPushbackReader stuff that *in* uses seems crazy.
16:49ieureIt’s way easier to just use (read-lines).
16:49mattmitchellis it common to use the :test meta key for embedding tests to your functions?
17:05aamarMissed connection: I saw a clojure package for couchdb, quite a bit more high-level than clojure-couchdb or clutch; more support for view handling etc. Anyone know of it?
17:05aamarCan't find it anymore
17:11ohpauleezaamar: eames, clojurize-couchdb, net.experimentalworks/couchdb ?
17:11ohpauleezthere's also evil-couchdb
17:12sritchiehey all -- I'm reading about the various matrix packages in java, and I see references to "large" matrices, or really large vectors
17:12sritchiewhere would the "large" range start?
17:12brehautdont forget https://github.com/mmcgrana/hammockdb
17:12sritchieI'd like to read in a 360x720 2d vector
17:12sritchieof floats
17:15aamarohpauleez, brehaut: I bet it's one of those, I'll take a look. Thanks!
17:15brehautaamar: its not hammock ;)
17:17Leonidashi. I tried `binding' a variable from another namespace but that does not seem to be possible. any ideas what I could do?
17:17ohpauleezsritchie: I think it depends what you're doing with that matrix, but I'm not sure what qualify as "large"
17:17ohpauleezsritchie: typically in Clojure, large things are operated on lazily
17:17ohpauleezif possible
17:18ohpauleezLeonidas: http://clojuredocs.org/clojure_contrib/clojure.contrib.with-ns/with-ns
17:18ohpauleezyou can use with-ns, and rebind
17:18sritchieohpauleez: yeah, I've got these as lazy vectors, as of now -- I'm working on a cascalog operation that needs to return a sequence of float arrays
17:19Leonidasohpauleez: that looks nice, so with-ns and binding. cool, will try that
17:19sritchiecascalog builds mapreduce jobs, so presumably these are going to get serialized by hadoop --
17:19raekLeonidas: are you 1) using clojure 1.3 or 2) trying to rebing something in clojure.core=
17:19ohpauleezsritchie: and as long as it's using streaming underneath, you should be fine, right?
17:20sritchieohpauleez: sounds like it
17:20sritchieohpauleez: great, I'll test this out, then
17:20ohpauleezcool
17:20raekyou should be able to rebind vars using binding without with-ns
17:20ohpauleezraek: really, even in other ns's?
17:20raekyes
17:20dnoleneames, not ready nor public yet. I really should get back to that :)
17:21raek(dynamic rebinding using 'binding')
17:21ohpauleezdnolen: :)
17:21ohpauleezI have a cassandra wrapper in a similar state
17:21raekthe way you can rebing *in* and *out*, for instance
17:22raek1) in clojure 1.3. only vars marked as :dynamic can be rebound, 2) some of the vars in clojure.core are special and cannot be rebindable.
17:22ohpauleezraek: ah yes, totally
17:23ohpauleezas long as you qualify correctly, I don't know what i was thinking
17:23raekyes. good point. the symbol used in 'binding' must of course resolve to the var in question
17:25Leonidasohpauleez: uhm, now I can't access my formal parameters from inside the with-ns body. Whats the solution to that?
17:26ohpauleezLeonidas: you should scroll up and read what raek and I were saying on the subject
17:26ohpauleezlet me know if that helps you
17:28Leonidasohpauleez: oh sorry, I missed that somehow.
17:28Leonidasraek: no, I am on Clojure 1.2 and trying to rebind something that is defined in some other module of my software.
17:29amalloysritchie: btw, "lazy vectors" is a contradiction. presumably you meant lazy sequences
17:30sritchieamalloy: yeah, sorry about that, I meant lazy sequences. I've got a byte-buffer, and I've written a function that returns a lazy sequence for a bytebuffer, by calling .getFloat
17:30sritchieamalloy: The next step is to use this lazy seq to create an array inside of incanter
17:30raekLeonidas: also, watch out for combining dynamic rebinding with lazy sequences (map, for, filter and friends)
17:30sritchieamalloy: so I'll have to realize the sequence eventually
17:31Leonidasraek: I am trying to rebind a boolean value.
17:31raekif you return a lazy sequence out of the binding form, the binding can revert before the lazy seq is forced
17:31Leonidas(def force-color false)
17:31amalloyLeonidas: whoa, that is not rebinding
17:31Leonidasin the one file and in the other (binding [force-color true] body)
17:31raekit is a convention to name rebindable variables with *earmuffs*
17:32raek(the naming shouldn't make any difference in 1.2, though)
17:32Leonidasoh, good point. I will adjust that.
17:32amalloyraek: or in 1.3, i'm pretty sure
17:32LeonidasI'd prefer to get this thing working first.
17:32amalloyLeonidas: that should work as long as force-color resolves to the same var as the one you're def-ing
17:32ohpauleezLeonidas: it needs to be (binding [the-ns/*force-color* true] body)
17:32raekah, have they removed the automatic :dynamic on *earmuffs*=
17:32amalloyie, you have a :use or :require for that ns
17:33ohpauleezLeonidas: what amalloy said
17:33amalloyraek: i'm not an authority by any means, but last i heard
17:33raekLeonidas: what does (resolve 'force-color) return?
17:33raekif it returns #'the-ns/*force-color*, then it should work
17:34jweisshow do i do this in clojure: x =1; try { doStuff(); x=2; } finally { System.out.println(x); }
17:34Leonidasohpauleez: I thought the same and tried to :use my.namespace :only (force-color), is that enough or do I still need to prefix my.namespace/ to *force-color*?
17:34raekLeonidas: also, what does (binding [*force-color* :lala] *force-color*) return?
17:34raekLeonidas: the usual rules for symbol resolution applies
17:35raek,(binding [*out* :lala] *out*)
17:35clojurebot:lala
17:36raek,(binding [*out* :lala] (lazy-seq [*out*])) ; common gotcha
17:36clojurebot(#<StringWriter >)
17:36Leonidasraek: resolve returns nil, both before and inside the binding form
17:37mefestoIs it possible to extend a protocol to a byte array?
17:37ohpauleezLeonidas: can you paste up a gist for us?
17:37raek,(resolve '*out*)
17:37clojurebot#'clojure.core/*out*
17:37Leonidasohpauleez: sure.
17:37ohpauleezthanks!
17:37amalloyjweiss: (let [x (try (dostuff) 2 (catch Exception _ 1))] (println x))
17:38jweissamalloy: but i want a finally clause, not catch
17:38raekLeonidas: then either you should get an exception when trying to evaluate anything using *force-color*, or you have a let or function parameter shadowing it
17:38jweissi want the printout whether an exception occurs or not
17:38jweissdo i have to rethrow?
17:40raekno, (try ... (finally (println x))) should work
17:40Leonidasohpauleez: https://gist.github.com/806871 (it isn't actually running, I hope that's enough)
17:40amalloyjweiss: that or use some mutable/reference variable
17:40amalloyraek: but he needs x to be bound in the finally scope, and "changed" in the try scope
17:40jweissso the finally clause can't know what the try clause returned?
17:40jweissi guess not since it's inside the try :)
17:40amalloyjweiss: i don't think so
17:41Leonidasraek: yeah, I'm also surprised why I get nil but inside the (binding [force-color true] force-color) is still true.
17:41ieureYou guys have invalidated my rule about IRC.
17:41ieure"All channels of the form #(programming-language) are useless."
17:41ohpauleezieure: Which is?
17:41Leonidasieure: what rule?
17:41ieureYou guys are really helpful, and I appreciate it more than you know.
17:41jweissthis channel rocks
17:41raekah. change. clojure does not allow that to locals.
17:41ohpauleezah, thanks ieure
17:41amalloyieure: only people with lots of vowels in their name are worth listening to?
17:42ohpauleezhaha
17:42raekLeonidas: can you test evaling force-color and (binding [force-color :foo] force-color) at the repl?
17:42amalloyi guess with 3.5 of each i'm on the border
17:42arohneris defining multi-methods with #'foo as a dispatch function fully legal?
17:43raekafter a (in-ns 'karmawhore.parser)
17:43amalloyarohner: yes
17:43arohneramalloy: it appears to give me a syntax error in 1.3-alpha4
17:43amalloygist?
17:43arohnerone sec
17:43Leonidasraek: I get :foo back.
17:43ohpauleezLeonidas: is force-color originally bound to true?
17:44Leonidasohpauleez: no, it is originally false
17:44ohpauleezand is it still false in that binding block?
17:44Leonidasraek: and (resolve 'force-color returns non-nil)
17:45Leonidasohpauleez: no, it is true inside the block. But only to the block, the functions that I call (red) see it as false
17:45jweissisn't there an alternative to swap! that just takes a value instead of a function?
17:45raekjweiss: reset!
17:46jweissah there you go. it's not mentioned here: http://clojure.org/atoms
17:46Leonidas#'karmawhore.color/force-color
17:46jweisswhich i find strange
17:46Leonidasis what it resolves to. Looks fine to me
17:46raekLeonidas: can you paste the definition of 'red'?
17:46Leonidasbut somehow the binding does not traverse over to inside karmawhore.color
17:47raekcould be that you look up the value of force-color "in advance"
17:48raekfor instance, (def foo force-color) will deref force-color and bind foo to the value it had at that point
17:48sritchiequick question on lazy seqs -- if I build a lazy seq with a generator, and want to return a lazy-seq of the first 1000 elements, say, os the way to do this with (def lazy-return (take 1000 lazy-generator))
17:48amalloyjweiss: it's not exactly good practice. but it is mentioned in http://clojure.org/cheatsheet, at least
17:48Leonidasraek: the relevant bits: https://gist.github.com/806871#file_parser.clj
17:49jweissamalloy: yeah, i left my paper cheatsheet copy at home :)
17:49amalloysritchie: (take 1000 (lazy-generator))
17:49Leonidasraek: erm, I mean https://gist.github.com/806871#file_color.clj
17:49amalloyie, you should never bind a variable to the entire sequence, or none of it can be freed
17:51sritchieamalloy: ah, got it
17:51sritchieamalloy: how about (map %(take 1000 %) lazy-generators), where lazy-generators is a sequence of those lazy-gens?
17:52brehautamalloy: caveat: the sequence is expensive to compute and you want to have it automemoized
17:52raekLeonidas: what does (binding [force-color true] (red "foo")) return?
17:52amalloythat's not lazy either
17:52raekI don't see any reason for why you code shouldn't work...
17:52amalloybecause lazy-generators is itself holding the head of all the sequences
17:53raekLeonidas: so if force-color is true, then fill-color always returns ""?
17:55sritchieamalloy: okay, one more try. https://gist.github.com/806902
17:56sritchieamalloy: I've got a large ByteBuffer, containing 24 (* 360 720) sized groups of floats. Every other group corresponds to a month, so i wrote extract-month, which returns another ByteBuffer, sized (* 360 720)
17:56Leonidasraek, ohpauleez: thank you both for your help. The problem was caused because of my own stupidity, missing a (not ...).
17:57sritchieso the idea is that this returns, back to hadoop, lazy sequences of floats
17:57amalloysritchie: looks good to me
17:57sritchieamalloy: great, thanks for taking a look
17:57amalloyi'm not sure you want to hint it as HeapByteBuffer, though. probably just ByteBuffer?
17:57arohnerwhere did c.c.java-utils/wall-hack-method go, in contrib 1.3?
17:57raekLeonidas: ok. glad you found the problem... :-)
17:57Leonidasbut while at it, I might also try to learn something. What is with-ns for? I cannot access the enclosing namespace from it, so it seems quite limiting.
17:59arohneraha, c.c.reflect/call-method
17:59raekI think it's for evaling something in another namespace. I've never needed to use it
18:00amalloysritchie: and you might actually want to use Channels or Streams, java's lazy constructs, instead of Buffers
18:00amalloybut i guess if you're returning a lazy seq of bytebuffers that's probably equivalent
18:01sritchieamalloy: I'm reading a binary file of floats written in little endian order -- I was just using bytebuffer as it was easy to set the byte order, so channels and streams might be better
18:02raekLeonidas: for future compability, you might as well add the :dynamic metadata: (def ^{:dynamic true} *force-color* false)
18:02raekin 1.3, only vars marked as dynamic will be reboundable
18:02amalloysritchie: well, channels basically create buffers, or fill up existing buffers
18:03mabesIf I have the string "inc" how would I get a hold of the var for that function?
18:03amalloyso it would reduce the amount of alloc/dealloc that needs to be done, but probably won't affect the amount of actual memory you use up
18:03mabes,(symbol "inc")
18:03clojurebotinc
18:03amalloy,(-> inc symbol resolve)
18:03clojurebotjava.lang.ClassCastException: clojure.core$inc cannot be cast to java.lang.String
18:03mabesah
18:03sritchieamalloy: sounds like a good way to tighten up this damned code
18:03mabesthanks amalloy
18:03amalloy,(-> "inc" symbol resolve)
18:03clojurebot#'clojure.core/inc
18:04sritchieamalloy: once I get this working, I'll try out streams, I'm sure I'll shed a few lines
18:04sritchieamalloy: thanks for the help
18:04amalloysritchie: welcome
18:09Leonidasraek: ok, will do. While renaming all my rebindable stuff to have *stars*.
18:19brehauthas anyone got any suggestions for a deployment management tool for small scale clojure powered websites hosted on a simple linux vps?
18:20brehaut(ie, something better than ducktape-and-string)
18:22danlarkinchef
18:24zoldarI know, that it's not clojure specific, but I have problem debugging code working in separate thread - code is ran by scheduled executor and I can see that at some moment it stops - probably due to some exception. Is there a way to get to the stacktrace when such problem occurs?
18:26brehautdanlarkin: cheers
18:28danlarkinchef definitely does have a learning curve, but I think once you "get" it then anything else seems like nonsense
18:28technomancychef is probably overkill for a couple of servers
18:28danlarkinI disagree
18:29brehauttechnomancy: i have one server and i doubt i'll outgrow it
18:29technomancywell if you are going to grow to 5+ then by all means take the time to learn it early, but if you'll never outgrow one it's a hard sell
18:29technomancyit also depends on how much you need to install that's not in apt
18:30danlarkininfrastructure as code
18:30technomancydanlarkin: you can write a hell of a lot of perfectly serviceable bash scripts in the time it takes to learn chef.
18:30technomancywhatever you use absolutely needs to be checked in of course
18:31technomancyI just can't see the setup of a single server being more than a couple pages of script
18:31danlarkinsure, but once you know chef, you know chef. writing your own almost-chef replacement is a wasted learning opportunity
18:32danlarkinwhich is not to say that writing things from scratch is never good, because it certainly is
18:32danlarkinbut chef's story is pretty good
18:34brehautim leaning towards the couple of pages of scripts i think
18:34brehautive got 1 uberjar to run and a directory of media for nginx
18:34danlarkinI'm going to take some artistic liberty and make this comparison, homegrown deploy script : chef :: homegrown vcs : git
18:35danlarkinwhy not just use a well-thought-out tool
18:36brehautbecause i have a limited amount of spare time and i'd rather spend it learning other things?
18:36technomancythat is a pretty apt comparison because they both have huge learning curves and they both have small-scale situations where they're not appropriate
18:36technomancyI wouldn't tell my cousin to use git for his term papers, etc.
18:38danlarkinbrehaut: I see why you would make that trade off, though I do not think it is correct
18:39brehautthere is no correct answer with a tradeoff; it wouldnt be a tradeoff otherwise
18:40danlarkinyes that's true
18:40danlarkinI'll rephrase then and just say I wouldn't make the same decision
18:40brehautfair nuff
18:41ieureHow do I figure out what index an elt exists at in a vector?
18:44technomancy,(keep-indexed #(if (= :x %2) %1) [:w :x :y :z])
18:44clojurebot(1)
18:44technomancyprobably something better in contrib?
18:46ieureHm… Maybe there’s a better approach to this.
18:46technomancyieure: clojure.contrib.seq/positions, which is essentially what I have above packaged up nicer
18:47technomancynicer but slightly slower
18:47ieureGiven a strong "foo", can I generate a :foo symbol from that somehow?
18:47brehaut,(keyword "foo")
18:47clojurebot:foo
18:47hiredman:foo is a keyword, not a symbol
18:47ieurebrehaut, Perfect, thank you.
18:48ieurehiredman, Yeah, I don’t quite have the Clojure lingo down.
18:50mefestois there a way to run clojure scripts using leiningen? something like: lein scripts/clean-db.clj ?
18:50technomancymefesto: leiningen is for projects, so it only runs namespaces that are part of your project (using the run task)
18:51ieuretechnomancy, For whatever it’s worth, Python’s setuptools lets you define arbitrary entrypoints and creates wrapper scripts to invoke those.
18:51ieureI’ve found it useful.
18:51brehautieure: lets not use pythons package management as something to emulate
18:51technomancyieure: yeah, I think that makes sense in Ruby too, but the JVM's limitations on the classpath call for different customs, I think.
18:51ieurebrehaut, Tall words.
18:52mefestotechnomancy: i see. these scripts are useful to the project while developing but aren't part of the end product... so do these go in test/ ?
18:52technomancymefesto: sure.
18:52mefestoI'm think along the lines of: lein run -m test.namespace
18:52technomancyreally simple stuff can just be new tasks in project.clj too
18:54brehautieure: why? i think most python programmers are willing to concede that package management is a weakpoint for the platform
18:55technomancymefesto: if it's something that would be useful to multiple projects it should be a leiningen plugin though
18:55mefestolooks like there is one called lein-run
18:56technomancyI mean like a lein-db plugin
18:56ieurebrehaut, Package management universally sucks, in my experience. But god knows the Java community has some seriously fucked up build/pakaging shit.
18:56technomancysurely your project is not the only one that would benefit from a task for cleaning the db =)
18:57mefestotechnomancy: :)
18:57technomancyieure: http://twitter.com/#!/derarthur/status/30434562785939456 =)
18:58ieuretechnomancy, Yeah. Leiningen is literally the only reason I try to hack Clojure.
18:58technomancyheh; nice
19:02brehauttechnomancy: lein (sensibly) tells you off for trying to make a release that depends on a snapshot. is there a way to disable that? (eg because you depend on a project that only has snapshots on clojars)
19:03technomancybrehaut: depending on a numbered snapshot should do it
19:03technomancyfoo/bar "1.0.0-20110128" instead of "1.0.0-SNAPSHOT"
19:03technomancybut also don't forget to get on their case about not doing proper releases!
19:03brehautah right. that makes sense
19:03brehaut:)
19:04technomancy*cough*enlive*cough*
19:04brehautmoustache too?
19:07technomancylet's all just stare at cgrand intently until we see stable releases
19:07brehautexcellent
19:07brehauti'll just get my own crap in order first
19:11brehauttechnomancy: if im browsing clojars, would i expect to see the date stamped snapshots there (eg in http://clojars.org/repo/clj-time/clj-time/), or would i need to work out the datestamp from the metadata?
19:11technomancybrehaut: they're in here http://clojars.org/repo/clj-time/clj-time/0.1.0-SNAPSHOT/ or you can look at the filename in lib
19:12technomancyugh; wtf. all snapshots an no releases?
19:12technomancybradfooooooooooord!
19:12brehautyeah
19:12brehautme thinks there needs to be some yelling and shouting to get this ship in order
19:13hiredmanmutiny then
19:13technomancythis is spartaaaaaaaa
19:15technomancydysinger is in SF right now, we should get him to do it.
20:21jkdufairwhich is more idiomatic? (defrecord inventory-log [foo bar]) or (defrecord InventoryLog [foo bar])?
20:21brehautlater; it creates a class
20:22pdkjava conventions for class names capitalize each word
20:22pdkrecords are effectively creating classes
20:23jkdufairok thx. wasn't sure in which Rome I was with defrecord
20:25amalloyjkdufair: though it is also idiomatic to (defn make-inventory-log [whatever args] (InventoryLog. some args))
20:32jkdufairthx!
20:46jkdufairi'm a bit confused about namespaces. if have data.clj with (ns foo.data) at the top and i have core.clj with (ns foo.core (:use foo.data)) at the top. i can't seem to refer to foo.data.SomeRecord in core.clj
20:47jkdufairi can't refer to it as SomeRecord. but I *can* refer to it if i qualify it
20:47brehautjkdufair thats correct
20:47brehautbecause its a class, you need to import it
20:47brehaut(:import 'foo.data.SomeRecord)
20:47jkdufairah! thank you
20:47brehautapproximately
20:48brehautjkdufair: its common for people to write a constructor function (eg some-record) for consumers
20:49jkdufairah ok. so you typically don't refer directly to the class defined in a defrecord?
20:49jkdufairif i do that, do i still need to import it?
20:50brehautnope
20:50jkdufairsuper. thx so much
20:51amalloybrehaut: you don't need to quote imports
20:51amalloy(in or outside of the ns macro)
20:51brehautoh. huh.
20:51mattmitchellif anyone knows the enlive html library -- is there any way to have classic template tags embedded in the html template?
20:52brehautmattmitchell: you mean jamming clojure code into your markup?
20:52mattmitchellbrehaut: well, i not necessarily. I'd be happy with simple placeholders like @title etc..
20:53brehautmattmitchell: place holders is done with elements
20:53mattmitchelltrying to find a way to allow a cms user embed pre defined tags
20:53brehautsay you have a blog snippet, you might have <section class="blog"><h2>title</h2></section>
20:55brehautyou could then have a defsnippet with [:.blog :h2] (content title)
20:56brehautand [:.blog :h2] (after content)
20:56brehaut(flying by memory there with after)
20:56brehaut(you might be better off with [:.blog] (append content)
20:57brehautmattmitchell: the result is that instead of having magic text in your structured markup, you are using the classnames and whatever to achieve similar results.
20:57mattmitchellbrehaut: yeah totally, that makes a lot of sense. your example looks nice. i think i'll just have to spend the night reading the enlive docs!
20:58brehautmattmitchell: have you followed dnolen's tutorial?
20:58mattmitchellbrehaut: not completely! maybe i'll finish that up first.
20:59brehautits worth the effort IMO
21:31mattmitchellwhat is the main diff between an array map and a hash set?
21:31brehautappart from one being a map and the other a set?
21:33brehaut,[(hash-set :a 1 :b 2) (array-map :a 1 :b 2)]
21:33clojurebot[#{1 2 :a :b} {:a 1, :b 2}]
21:34mattmitchellbrehaut: thanks. interesting. I think i'm confused because a hash in languages i've worked with are maps, so mixing hash and set together caused a little confusion.
21:34brehautif that doesnt answer the question: a map is a mapping from keys to values, where a set is a group of things. the keys of a map form a set for instance
21:35brehautthe prefix tells you the implementation choice
21:35brehautyou dont need to care most of the time
21:35brehautclojure also has ##(hash-map 1 2 3 4)
21:35sexpbot⟹ {1 2, 3 4}
21:35brehautboth array-maps and hash-maps are persistentmaps
21:36brehautand the system choses the implement based on the number of items and will change implementation silently as dictated by usage
21:37mattmitchellbrehaut: that's really nice. good to know!
21:46ieureAaaaaargh. Is there some non-horrible way to line-seq to read from *in* or System/in ?
21:47ieureThis should be simple, but Java’s type system is fucking me in the ear.
21:47ieureCannot create a BufferedReader from System/in.
21:47ieureCalling (reader System/in) returns an empty seq even when there’s stuff sent to sedin.
21:47amalloy&(class *in*)
21:47sexpbot⟹ clojure.lang.LineNumberingPushbackReader
21:48ieureEr, (line-seq (reader System/in))
21:48amalloy&(supers (class *in*))
21:48sexpbot⟹ #{java.lang.Readable java.lang.Object java.io.FilterReader java.io.PushbackReader java.io.Closeable java.io.Reader}
21:48amalloyieure: it's a reader, so wrapping it in bufferedreader should work. are you trying to do this from slime?
21:49ieureamalloy, No, I can’t send anything to stdin there. It’s in my -main method in a Leiningen project.
21:49brehautamalloy: line-seq *in* throws a classcastexception
21:50brehaut(use '[clojure.java.io :only [reader]]) (line-seq (io/reader *in*))
21:50ieure(line-seq (reader *in*)) just gives me an empty list.
21:50ieureI wonder if this is a leiningen thing.
21:50ieureI’m using `lein run' and piping stuff to it.
21:51ieureUgh, fuck. It is.
21:51ieureWorks fine with `java -jar'.
21:51devnmy coworker described namespaces as "state" -- what say you?
21:52ieuredevn, Seems incorrect on its face.
21:52pdkthat's
21:52pdkum
21:52pdka unique way to interpret them
21:53devni know it's ridiculous, but he makes an argument which i've never heard, which is that if you define the ns at the top of a file, it is ieffectively setting the context in which functions will be defined
21:53devnand therefore qualifies as state
21:53devni dont agree with it, but im curious what other people have to say about it
21:53brehautdevn in the exact same way that any lexical scope is defined though surely?
21:54brehauteg (let [foo 1] (defn add-foo [x] (+ x foo))
21:54brehautyou wouldnt call foo state, but that seems to me to be no different than defining the namespace
21:57devnbrehaut: he's never used clojure, so my assumption is that he saw that (ns ...) didn't wrap the (defn) that came later in the file and so on
21:57devnso he saw it as being a stateful thing
21:57brehautwould he agree that (def foo 1) (defn add-foo [x] (+ x foo)) is not state?
21:58devni can ask him when he's done playing guitar hero
21:58brehautstate is context but not all context is state right?
21:59phenom_what's the easiest way to run some defntest's I've got in a clj file ?
21:59brehautphenom_: is it a lein (or presumably cake) project?
22:01devnbrehaut: he has conceeded
22:01brehautwoo :)
22:01devnconceded*
22:01phenom_brehaut: why do you presume cake? :P
22:02devnbrehaut: it took me by surprise at first because yes, as you say, context is not state -- it depends on how you wish to define statefulness
22:02brehautphenom_: im presuming cake behaves the same as lein in this instance
22:02devnyou might say that a (let ...) is a state, but that would incorrect for most intents and purposes
22:02ieureCan someone point me to a clear example of how -> and ->> work? The documentation is completely inscrutable. I have no idea what they do or why I’d want to use them.
22:03brehautieure: they rewrite your forms. (-> a (b) (c)) becomes (c (b (a)))
22:03brehautthats a terrible example
22:03seancorfieldthey are convenient when you want to apply a sequence of operations to the same thing, one after the other
22:03amalloy&(macroexpand-all '(->> (range) (filter even?) (take 100) (reduce +)))
22:03sexpbotjava.lang.Exception: Unable to resolve symbol: macroexpand-all in this context
22:03amalloy&(use 'clojure.walk)
22:03sexpbot⟹ nil
22:03amalloy&(macroexpand-all '(->> (range) (filter even?) (take 100) (reduce +)))
22:03sexpbot⟹ (reduce + (take 100 (filter even? (range))))
22:03amalloyieure: ^
22:04brehautdevn: i think if you are unfamiliar with pervasive immutability its reasonable to make that assumption i think
22:04seancorfieldthe difference is that -> puts the 'thing' as the first argument in each call and ->> puts the 'thing' as the last argument in each call
22:05seancorfield&(macroexpand-all '(-> x f g h))
22:05sexpbot⟹ (h (g (f x)))
22:06ieureIs macroexpand-all in -contrib somewhere?
22:06seancorfield&(macroexpand-all '(-> x (f a b) (g c d) (h e f)))
22:06sexpbot⟹ (h (g (f x a b) c d) e f)
22:06amalloyieure: you just saw me (use 'clojure.walk), right?
22:06seancorfield&(macroexpand-all '(->> x (f a b) (g c d) (h e f)))
22:06sexpbot⟹ (h e f (g c d (f a b x)))
22:07brehautdevn my solution to that problem was to stop having coworkers
22:07ieureamalloy, I didn’t realize that the bot had persistent state like that.
22:07devni think one unfortunate thing we need to really approach as a community is how we mention immutability in passing
22:07devnpeople hearing immutability and have no idea how to approach a world that looks like that
22:07ieuredevn, It is incredibly daunting at first.
22:08ieureThen you play with it and realize that you don’t need nearly as much as you thought.
22:08devnieure: it's taken me 2 years from 0 to lisp to "get" what was going on here
22:08devni dont blame anyone
22:08seancorfielddevn: true, when folks are used to writing for (x = 1; x < 10; ++x) doSomething(x);
22:08ieuredevn, I make zero claims that I know what is going on here. :)
22:08devnit's just something that is so undervalued and misunderstood
22:08brehautseancorfield: at my last job i wrote a nice little F# program. i had to rewrite it in VBS.
22:08devnieure: i think that's funny
22:08seancorfieldbrehaut: my sympathies
22:08devnieure: it's scary, but we're smart
22:09brehautseancorfield: its not all bad. i got to write it in F# first ;)
22:09devnieure: btw, thank you for your php-repl
22:09devn:X i hate to admit i used that at one time
22:09ieuredevn, Ha, you’re welcome.
22:09devnbut thank you :)
22:09amalloyieure: oh, is that yours? i was using it just today
22:09mattmitchellphp-repl?
22:09devnit's a repl, but you know, for a shitty language
22:09ieuremattmitchell, An attempt to make a REPL for PHP that wasn’t horrible.
22:10mattmitchellhaha :)
22:10mattmitchellwhy not?
22:10devneither way, ieure is awesome
22:10devneveryone should remind him of how awesome he is more often
22:10devnIMO
22:10ieureJesus, I had no idea I had a fan club.
22:10devnieure: it's not a fan club *yet* :)
22:11devnim just happy to see you around these parts -- i hope you'll stick around
22:11ieureOh, I’ve been meaning to get serious about Clojure for a long time. Still haven’t had much reason to do that, though.
22:11seancorfieldbrehaut: i often prototype something in clojure to make sure i understand the problem and have then been coding it in "language X" for production use
22:11ieureBut I’ve been screwing around with it the last couple weeks when I felt like it.
22:11seancorfieldbut that will change... clojure is coming to production soon :)
22:11mattmitchellieure is awesome. brehaut is too. i'm amazed at how i can ask dumb questions and get a serious answer here. very helpful.
22:12devnthe thing that's missing big time in clojure ATM is a CRUD-like setup for web development
22:12seancorfieldieure: btw, did amalloy and i help answer the -> / ->> question?
22:12brehautmattmitchell: i wouldnt say im awesome. ive just made the dumb mistakes before you did ;)
22:12mattmitchellbrehaut: :)
22:12devnieure: can i make a suggestion on -> and ->>?
22:12ieuredevn, of course.
22:12devnieure: https://github.com/tcrayford/clojure-refactoring
22:12ieureseancorfield, I do not fully understand it yet. But I don’t know if anyone can help me with that just yet.
22:12seancorfielddevn: well, i plan to use clojure for the Model portion of an MVC web app with the VC portion written in CFML :)
22:13ieureI learn by doing.
22:13devnget that. play with thread-first and thread-last
22:13devnyou can write some code and automatically refactor to -> and ->>
22:13devnit helps you see how it works and gives you insight into when to use it
22:13devnalso ieure, another link:
22:14brehautseancorfield: wait. cold fusion?!
22:14seancorfieldyup, although it's been one word not two for a decade or so
22:14devnieure: https://github.com/raganwald/homoiconic/blob/master/2008-10-30/thrush.markdown
22:14seancorfieldi use the railo open source cfml engine (it's a jboss project)
22:15ieureOkay, I think I see what -> is doing now.
22:15devnieure: -> and ->> are simply ways of reversing the order of computation
22:15devnso it reads left to right
22:15brehautdevn: ieure http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
22:16devnbrehaut: great link
22:16ieureYeah. So if I understand, I can use that to create with partial to create a nested function to map across a seq.
22:16devnieure: id need a repl to test that because im not a magician or a god or anything when it comes to programming
22:16brehautieure: with thrush yeah; its a point-free operator
22:17devnbut the basic idea if you get to switch up the order and read left to right
22:17devni have a much more abstract idea of how it works i guess
22:17devn*shrug*
22:18devnbtw, On explaining clojure to coworkers in an OOP mindset: Practical Clojure does an excellent job of covering the how and why
22:19ieuredevn, I also found the introduction to Programming Clojure to be a good introduction.
22:19devnmodularity, polymorphism, encapsulation, reusability
22:20devn"objects everywhere" really screws up the implementation of these ideas on their own
22:20brehautdevn Stuart Halloway's Clojure Conj presentation might also be good
22:20devnbrehaut: i was there :)
22:20devnbrehaut: is that online yet?
22:20brehautlucky bastard :)
22:20brehautit is
22:20devnlink please!
22:21devnstuart -> pure awesome
22:21devnsuch a gracious host with a wonderful family and what i could only characterize as a heartfelt commitment to the community writ-large
22:22brehaut… taking longer to find this than i thought
22:23seancorfieldhttp://clojure.blip.tv/?sort=custom;date=;view=archive;user=clojure;nsfw=dc;s=posts;page=1 is it here?
22:23brehautnot that i could see
22:24devnyeah i dont see it
22:24devnbummer -- i loved that talk
22:24devnperhaps he's witholding it given the beer that was involved
22:25devnprobably need to edit out the label or something :D
22:25brehauti know its on the web somewhere
22:25brehauttry http://www.infoq.com/presentations/Clojure-Java-Interop ?
22:25seancorfieldstuart's talk... simplicity ain't easy?
22:26devnthat's the topic
22:26brehautsorry, ive got extrodinarily slow internet
22:26devnbut i dont know of any video on it yet
22:26seancorfieldi don't see it on blip.tv so it may not have been released yet
22:27seancorfieldbut these two talks might be useful for OO folks: http://clojure.blip.tv/file/982823/ and http://clojure.blip.tv/file/982957/ - clojure for java programmers parts 1 & 2
22:27devnive seen those
22:27devnid really like to see stuart's talk again, though
22:27seancorfieldrich's preso to the NYC java study group
22:27brehauthttps://github.com/downloads/stuarthalloway/clojure-presentations/Clojure-Simplicity.pdf thats the slides anyway
22:27seancorfieldi had to miss the first conj but i am _not_ missing the second one!!
22:28devn:)
22:28Scriptorit's in NC, right?
22:28devni refused to miss the first one
22:28seancorfieldi may even bring one of my coworkers since he'll have had to learn clojure by then :)
22:28brehautid like to not miss any of them, but unfortunately its the wrong hemisphere entirely
22:28seancorfieldi was already committed to being in albuquerque and los angeles when the dates for the conj were announced :(
22:29seancorfieldthis year i'm keeping september and october free until the conj dates are finalized!
22:29seancorfieldwell, strangeloop is mid-september and javaone is early october... but other than that, i'm free...
22:29Scriptorwait, does anyone know where the 2nd conj will take place?
22:29seancorfieldi expect it'll be the same place...?
22:30Scriptorso Durham again?
22:30Scriptorargh, I'll stick to the meetups here :)
22:30seancorfieldaccording to alan dipert "Conj 2011 will most likely be in either Raleigh or Durham, North Carolina, and probably will happen around the same time of year as the
22:30seancorfieldlast Conj."
22:31seancorfieldthat's from his post to the clojure list on 12/27/10
22:31seancorfieldat least scala days is close to home for me :)
22:32seancorfieldbut i'm doing conferences in dallas, edinburgh (UK) and minneapolis in february, march, may so this year has a lot of travel in store
22:32seancorfieldmaybe one in kansas city, mo too in july
22:33seancorfieldscala days in june (locally), strange loop in mid-september in st louis, javaone locally... and clojure conj :D
22:55ieureIf someone feels like reviewing this code I wrote, I would greatly appreciate being told all the things I did wrong: https://gist.github.com/05f59e7b01f5b0d260f1
23:01brehautnothing obvious jumps out at me
23:02amalloyieure: (apply hash-map (interleave foo bar)) is (zipmap foo bar)
23:03amalloy(partial get some-map) is the same as some-map
23:04amalloy#(first (parse-csv %)) is equivalent to (comp first parse-csv), which imo is more readable but tastes vary
23:06amalloy(. util format ...) is weird to read because it violates the usual "function first" style - i'd write (.format util ...) unless there's some reason you can't
23:07ieureamalloy, I have no major reason for doing most stuff there, except that it seems to mostly work.
23:07ieureI really appreciate the input.
23:07amalloywelcome
23:10amalloyoh, and (conj m {:k v}) is (assoc m :k v)
23:10brehautamalloy wins
23:11brehautamalloy: i should get you to pick apart my code some time ;P
23:12amalloybrehaut: do it. i generally enjoy review/editing
23:13brehautamalloy: how about https://github.com/brehaut/clj-pingback/blob/master/src/clj_pingback/client.clj
23:14ieureamalloy, Excellent, this is significantly clearer. Thank you very much.
23:14ieureAny idea why if I change the (println …) to (print …), I get no output whatsoever?
23:14amalloyieure: you need to flush the output stream
23:15amalloy\n automatically flushes by default
23:15ieureamalloy, Awesome, thank you. I’m used to Python, where it gets flushed on close/exit.
23:16amalloyieure: i'd sorta expect it to get flushed on close too
23:16amalloybut if it doesn't, that's why :P
23:16amalloybrehaut: (when-let [[_ url] (...)] url) sounds a lot like (second (...))
23:17brehauthuh so it is
23:17amalloy(fn [t] [t (foo t)]) == (juxt identity foo)
23:19brehauttrue
23:19brehautcheers :)
23:20brehautand more point free :D
23:20amalloyhah, and you're importing your necessary-evil project as xml-rpc. i like it
23:20brehaut:)
23:21brehautits the best name ive ever come up with for a project; pitty its wasted on such a lame protocol
23:21amalloybrehaut: what about using clojure.contrib.-?>> to replace the when-let/if-let construct?
23:22brehautsorry, which function?
23:22amalloythat is, c.c.core/-?>>
23:22brehautsorry, in the pingback code
23:22amalloyin discover-pingback-endpoint
23:22brehautoh right
23:23brehauti think i could replace it with or actually
23:24amalloybrehaut: i don't think so, cause you reuse url
23:24brehautim not though, i accidentally masked it in the when-let
23:25brehautwhich was replaced with (second ...) anyway
23:25amalloyah
23:27brehautso that if-let is now (or (get-in response [:headers "x-pingback"])
23:27brehaut (second (re-find link-pattern (:body response))))
23:29brehautamalloy: i just pushed the changed code