#clojure logs

2011-06-15

00:01duck1123I actually am making progress, but I'm using maven, so am not much help
00:01duck1123I got it to run the feature and start my server
00:35technomancydoes anyone use derive to specify ad-hoc type hierarchies?
00:50dnolentechnomancy: I have in the past, why?
00:51technomancydnolen: I'm just mulling over some issues of exception handling and wondering why it is that "catch" works based on types... is it because that's how it's done in Java, or because catching based on types is a good idea?
00:52dnolencalculating the isa? relationship on hierarchies is quite slow compared to instance?
00:52technomancysure, but for exception handling that's less of an issue than arbitrary dispatch
00:53technomancycontext: https://github.com/technomancy/slingshot/tree/handle
00:54dnolentechnomancy: so little has happened around error handling in any way in core that I think this just a part of Clojure that is particularly conservative. how do you plan do deal with catching custom error types from the Java side?
00:54chouserI think using types for exception categorization is pretty clumsy.
00:54technomancydnolen: there's a gen-classed data-carrying exception that descends from RuntimeException
00:54chousererror-kit does it, but I think it was a bad idea
00:55chouserwouldn't we rather have tags than folders?
00:55dnolentechnomancy: huh and that's used in core?
00:55technomancydnolen: could be =)
00:55technomancyworking largely from http://dev.clojure.org/display/design/Error+Handling
00:56technomancychouser: leaning that way myself
00:56dnolenchouser: it's not that I disagree per se, it's just I thought something cool would have happened by now around error handling :)
00:56technomancychouser: on the other hand, it could be that we don't like using types because it's only recently that we've been able to define low-ceremony types
00:57technomancy(playing devil's advocate)
00:57technomancyanyway, that link has an implementation of arbitrary-predicate catch
00:57technomancyas well as a derive-aware catch
00:58technomancy(bonus goodness: you can destructure, which is pretty sweet)
00:58technomancyand the question is whether type-based catch dispatch is primarily for interop purposes
00:58chouserthat's my understanding.
00:59technomancywe'll get this out on a the mailing list soon, I'm just mulling it over in my head trying to boil it down to the core issues
01:01technomancythe open issue is whether in (catch :keyword ex [...]) :keyword should be interpreted as an ifn or as an isa? type
01:01scgilardiI'm in favor if isa? type (as implemented by :type metadata)
01:02technomancyif the former then you can just stick with try/catch; if the latter then I think it's best to introduce try/catch/handle (as I've been calling it) where handle explicitly calls out the fact that you're providing an arbitrary ifn
01:02technomancyscgilardi: sorry, meant to wait till we had hashed it out internally more, but I got carried away =)
01:02scgilardiif we fix the degenerate case of partial (where we partial just an ifn), then (partial :a-keyword) becomes a great way to make it clearly a predicate
01:02scgilardiwhich I really think is going to be a rarely used/desired case
01:04scgilardi(partial :my-keyword) isn't currently legal, but I'm suggesting it be made legal
01:06scgilarditechnomancy: no problem. good to get lots of input.
01:06technomancydnolen: re: something happening by now: c.c.condition provides a fair bit of this goodness, but we haven't been using it as much as we could if it were baked in everywhere
01:07technomancyso we're playing around with clj-nstools to let us pretend like try+ and throw+ are in clojure.core without performing actual monkeypatching
01:13dnolentechnomancy: both c.c.condition and slingshot look interesting. I wonder if throw+/catch terminology should be avoided as it was in c.c.condition?
01:13hiredmancondition had raise
01:14hiredman(has)
01:14hiredmanraise/handle/handle-case
01:15technomancydnolen: handler-case in c.c.condition didn't use the word catch because it was structured differently; you had to specify a single predicate up-front, and each clause matched against the value of running that predicate against the raised condition
01:15technomancydnolen: whereas try+ and throw+ are entirely additive; the structure is the same as try and throw
01:15hiredmanit wasn't really a predicate
01:16hiredmana "selector"
01:16hiredmanmore like condp
01:16technomancyhiredman: true; exactly like condp
01:16technomancyexcept for being slightly different
01:16dnoleneven so throw/catch will probably always denote a low level Java thing. just thinking some newer should well ... look newer.
01:17technomancyI've been thinking of it as similar to how slurp "gained super powers" with the introduction of c.j.io
01:17technomancyit's still called slurp, but it works on more than just filenames
01:18technomancybut I don't really care, as long as I can throw maps, dispatch on keywords, and destructure in catch.
01:19hiredmanit is hard to image how else something like try/catch would be structured given the limitations of the jvm
01:20hiredmanthe other thing I don't think technomancy or scgilardi mentioned is slingshot exceptions carry locals information
01:20hiredmanfrom &env
01:22technomancyhiredman: yeah... actually the wiki page actually explicitly called that out as being too high a price to pay all the time. so that will probably need to depend upon (System/getProperty "clojure.debug")
01:22technomancybut!~ cool to have.
01:23hiredmandunno, if you are really concerned about exception costs then try/catch instead of try+/catch
01:23dnolentechnomancy: well one thing I never loved about ad-hoc hierarchies was that it's a global mutable thing. and I'm not a fan that complex hierarchies push towards prefers.
01:24technomancydnolen: yes, that's a big downside. pulling in unrelated 3rd-party libraries could change the result of an isa? call unexpectedly
01:24hiredmanmmm, and the isa? in try+ doesn't allow for specifing your own hierarchy
01:25technomancyanyway, my battery's not long for this cycle; will get this onto the mailing list soon
01:25sexpbotjava.lang.Exception: EOF while reading
04:50tsdhI'm trying to work with some external java objects. How can it be that (class x) returns foo.bar.Baz, but foo.bar.Baz at the REPL or (Class/forName "foo.bar.Baz") throws a ClassNotFoundException?
05:10Klankeram I doing something wrong.... I put 7000 integers into sorted set, then when I try to execute (into '() sort-set) it runs for more than 30 minutes
05:11KlankerI could sort those numbers faster than clojure sorted map/set by hand
05:18tsdhKlanker: (into '() (sorted-set (range 0 7000))) works instantly here...
05:19tsdhKlanker: Ditto for (into '() (sorted-set (shuffle (range 0 7000)))) where there's real sorting going on.
05:19bsteubertsdh: here, too - but you mean (apply sorted-set ...)
05:19bsteuberotherwise the set just gets one element
05:20tsdhbsteuber: Oh, indeed. Well, still instantly.
05:22no_mindI have a sequence of maps and I want to create one map by merging all maps. How do I do this ?
05:22Klankerinto?
05:22Klankerreduce into I guess
05:24fliebelOr merge/merge-with
05:25fliebelEither apply or reduce works, I've heard arguments for either.
05:25bsteuber,(apply merge [{:a 1} {:b 2}])
05:25clojurebot{:b 2, :a 1}
05:27tsdhWhat's the clojure way to define some new exception classes?
05:28Klankeryou can use gen-class to generate new class files
05:29Klankerbut I see no reason why not to just write a java class
05:31tsdhKlanker: Hm, my app is plain clojure and I guess putting in java classes will put a setup burden on me, or not?
05:31Klankernot really
05:31Klankerif you just put compiled class files in classpath
05:32tsdhKlanker: Yeah, so I have to tell lein/cake somehow that it should also compile the java files to class files somehow.
05:49ilyakI have a macro with (.. some some some) in it
05:49ilyakand apparently it doesn't get expanded
05:49ilyakbecause it would then complain
05:49ilyakHow would I force macro expansion inside macro `body?
05:50Klankerhow do I paralelize filter operation?
05:51fliebel$source filter
05:51sexpbotfilter is http://is.gd/vU4rfX
05:52fliebelKlanker: Easiest would be to split up the task with partition and then stitch it back together.
05:52Klankerpartition?
05:52clojurebotpartition is probably not what you want; see partition-all.
05:52fliebel$source pmap
05:52sexpbotpmap is http://is.gd/mVHNdG
05:53KlankerI thought about something like pmap?
05:53the-kennyLooks like sexpot is off a few lines
05:54ilyakIs there a good doc on macros covering all obscure symbols you have to use?
05:54fliebelKlanker: Well, if the filter is expensive, you could run pmap and then filter identity.
05:54KlankerI guess
05:55fliebelOr (apply concat (pmap #(filter pred %) (partition 32 seq)))
05:55fliebelOr do ith the hard way and write pfilter.
05:56Klanker:)
05:56KlankerI just ran it on a part of the problem
05:56Klankersince I need cores for work
05:57Klankerbut later when this workstation will be idle I'll just add the rest on paralel :)
06:00beyeranhi, is there any way to set up a clojure repl in emacs without using the ELPA package?
06:00the-kennySetup Slime by hand
06:00the-kennyThen start the swank-server somehow (lein swank, whatever), M-x slime-connect
06:01beyeranI've tried it but after a few seconds I get a runtime exception and the server quits
06:04the-kennyThat's strange
06:07beyeranIt seems that I'm not the only one with this problem but the only solution I've read would be installing slime through ELPA. This isn't what I want because other Lisp dialects are configured with slime manually. Both versions would be odd.
06:09mrBlissbeyeran: I have a working Slime setup that supports Clojure & Common Lisp at the same time (without restarting!). Do you want me to explain it?
06:11beyeranmrBliss: that would be nice!
06:12mrBlissbeyeran: ok, use this version of Slime: https://github.com/hugoduncan/swank-clj/tree/develop/slime
06:12mrBlissand clone this repo: https://github.com/TerjeNorderhaug/swank-clojure
06:12mrBlisscompile and install it locally,
06:13mrBlisscall it swank-clojure-1.3.1-slime or something
06:13mrBlisslein plugin install swank-...
06:14mrBlissremove existing swank-clojure dependencies from your poject.cljs and you should be good to go
06:15beyeranmrBliss: thank you, I try it
06:27beyeranmrBliss: and how do you actually switch between a lisp and a clojure repl?
06:28mrBlissC-c C-x c to bring up a list of repls and 'd' to select the default
06:28dbgsterhow do I import clojure.set into repl?
06:28the-kennydbgster: (use 'clojure.set)
06:28ilyak(defmacro [item & args] `(.. item ~@args something)) <- what's the correst way of writing this?
06:28ilyaki.e. one that would actually work
06:28mrBlissbeyeran: clojure repls are started with (lein swank), slime-connect and CL repls with slime
06:29dbgsterthe-kenny: hanks
06:29dbgsterthanks
06:30beyeranmrBliss: very nice, thank you!
06:31mrBlissbeyeran: I'm glad it works for you too
06:32beyeranmrBliss: yes, I've tried several solutions but none of them fits for me with lisp and scheme running, now it finally works!
06:32the-kennymrBliss: Oh, it is possible to have multiple connections open at the same time? Nice
06:33the-kennyDidn't know that
06:33mrBlissbeyeran: do you use slime Scheme as well? I use geiser for Scheme.
06:33mrBlissthe-kenny: It's not always easy to assign a buffer to a particular connection though.
06:38beyeranmrBliss: Geiser? Never heard of it, I'm going to look it up
06:39mrBlissbeyeran: Geiser is to Scheme as Slime is to CL :-)
06:40mrBlissbeyeran: it only works well with Guile and Racket though
06:41beyeranmrBliss: looks very interesting!
06:41ilyakFigured it out, had misaligned ()s
06:41beyeranmrBliss: I've used Scheme mainly for educational reasons, not as much as CL, that may be the cause why I haven't heard of it...
06:43mrBlissbeyeran: I've only used it (mit-scheme) for The Little Schemer, but I'm planning to do SICP. I just like tinkering with my Emacs config, so I installed geiser for fun (and SICP after my exams) ;-)
06:44beyeranmrBliss: Yes, it'
06:44beyeranmrBliss: Yes, it's massive :-)
06:51gilechamwww.freenode.org
06:58jonasenFeedback / proof reading request: https://github.com/jonase/cljcsv/wiki/Intro
07:03manutterjonasen: typo in second paragraph: separetad should be separated
07:06jonasenmanutter: thanks
07:08manutterand one other typo: in "The forth line parses every row of stock data as we saw in the previous section.", should be "fourth" not "forth".
07:09manutterOther than that it looks pretty good, you have absolutely no need for the disclaimer about "English is not my native language" :)
07:11jonasenfourth, not the programming language forth! :)
07:11manutterExactly :)
07:12jonasenOk. I removed "Enlish is not...". Thanks for your time :)
07:12manutternp, anytime
07:23zoldarNeither I'm an English native speaker, but I think that here: "...want to provide feedback*,* do not hesitate to contact..." and here "...In order to have some data to work with*,* I visited..." commas would be helpful
07:25zoldarand here "... replaced with ((juxt ...) #(apply ...)))*,* we'll get both the highest increase as well decrease: ..."
07:30timvisherhey all
07:32timvisheri'm dealing with a utf-8 string encoded by java.net.URLEncoder and I'm trying to get it back into clojure through a compojure route.
07:32zoldarand this: "highest increase as well *as* decrease:"
07:33timvisherThe title is `Musée gallo-romain de Fourvière` and the encoded url is `/thumbnail/Mus%8Ee+gallo-romain+de+Fourvi%8Fre`
07:33timvisherIs there anything special I need to do to tell clojure that that is a utf-8 string for comparison with another string?
07:33jonasenzoldar: fixed
07:35timvisherThis is the context that I'm trying to use the title in. https://gist.github.com/1026917
07:52raektimvisher: the URL should be encoded in UTF-8, but to me it looks like it's in Latin-1
07:52raek,(seq (.getBytes "Musée gallo-romain de Fourvière" "UTF-8"))
07:52clojurebot(77 117 115 -61 -87 101 32 103 97 108 ...)
07:52timvisherraek: ah
07:53raek,(for [i (seq (.getBytes "Musée gallo-romain de Fourvière" "UTF-8"))] (format "%02x" i))
07:53clojurebot("4d" "75" "73" "c3" "a9" "65" "20" "67" "61" "6c" ...)
07:53raek,(for [i (seq (.getBytes "Musée gallo-romain de Fourvière" "ISO-8859-1"))] (format "%02x" i))
07:53clojurebot("4d" "75" "73" "e9" "65" "20" "67" "61" "6c" "6c" ...)
07:53timvisherbah! I'm using the deprecated encode(String) method
07:54timvisherI'm not specifying the encoding.
07:57timvisherraek: that did it. I'm an idiot. :)
07:58opqdonutoh my
07:58opqdonut,(clojure.set/difference (set [0 300 :a]) [:a :b])
07:58clojurebot#{0 300}
07:58opqdonut,(clojure.set/difference (set [0 300 :a]) [:a :b :c :d])
07:58clojurebot#{:a 300}
07:58opqdonut,(clojure.set/difference (set [0 300 :a]) (set [:a :b :c :d]))
07:58clojurebot#{0 300}
08:00raektimvisher: anyway, cred to you for actually caring about encoding. and it's not your fault Sun made bad API design decisions...
08:01raektimvisher: if you use ring, you can also use this function: http://clojuredocs.org/ring/ring.util.codec/url-encode
08:01opqdonuthow do I report a bug?
08:01raekbut it's just a wrapper that defaults to UTF-8 :-)
08:02raekopqdonut: http://dev.clojure.org/display/design/JIRA+workflow
08:03opqdonuthow do I find JIRA?
08:04opqdonutokay, found it
08:04opqdonuta straight link from clojure.org might be nice
08:04raekyeah, there are a lot of links that should be there...
08:04opqdonutso I have to sign up to file a bug?
08:06raekopqdonut: yes, looks like you need to do that
08:06opqdonuthmh.
08:06raekbut you don't need to sign the Contributor Agreement or anything to just report a bug
08:06opqdonutyeah but it's one more account to one more web thingy
08:06opqdonut*sigh*
08:07raekopqdonut: make sure to do a little check on the Clojure and Clojure-dev google groups to see if this has been discussed already
08:07opqdonutsorry, I just want to be a user
08:08opqdonutI'll file the bug and it'll get closed if it's a dupe
08:08opqdonutbut it is still present in master
08:12fliebelDoes anyone have a good resource to make a simple NIO client/server without getting into netty and aleph?
08:15stuartsierrafliebel: "simple" and "NIO" don't really belong in the same sentence.
08:15duck1123aleph really isn't that bad though
08:15duck1123I just recently switched, and I'm really liking it
08:15fliebelduck1123: I like it too, but I want to dig down to the core of it.
08:16duck1123then yeah, simple really won't apply to you
08:17fliebelstuartsierra: Hm, it's Java after all. I was hoping to do something like those async Python things, with a nice loop olling for stuff and invoking callbacks and such.
08:17fliebel*polling
08:17stuartsierraIt's not impossible; the Java NIO tutorials are there. But you have to mess about with byte buffers.
08:18pyrduck1123: can't you just use lamina2
08:18pyrs,lamina2,lamina
08:19duck1123well, lamina is what aleph is using.
08:19duck1123he already wrote all 3 libraries for this very purpose
08:21Klankerdoes clojure demote numbers too?
08:25stuartsierrademote?
08:27fliebelOkay, maybe I should not try to take it from the NIO level, but what I want to do is experiment with different execution and dispatch methods.
08:32gfrlog(defn only [foos] (assert (= 1 (count (take 2 foos)))) (first foos))
08:51tsdhIs there a function to reverse a map, that is, swap keys and values?
08:52Fossiand upon duplicate values does what?
08:53tsdhFossi: Best would be to error.
08:53tsdhBut we may assume the map is a partial bijection for now.
08:54stuartsierratsdh: I think clojure.set/invert-map
08:56tsdhstuartsierra: It's actually map-invert, but that's what I've been looking for.
09:15BorkdudeWhy does this return #{(1 2)} and not #{} ? (apply intersection (set ['(1 2)]) (list))
09:16opqdonutthe set operations are slightly broken when they're given non-sets
09:16opqdonutoh wait, no
09:16opqdonutyou say _apply_
09:16opqdonutso you take the intersection of only one set, (set ['(1 2)])
09:17opqdonut,(clojure.set/intersection (set ['(1 2)]) (set))
09:17clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$set
09:17opqdonut,(clojure.set/intersection (set ['(1 2)]) (set (list)))
09:17fliebelopqdonut: In what way are they broken?
09:17clojurebot#{}
09:17opqdonutfliebel: http://dev.clojure.org/jira/browse/CLJ-810
09:17Borkdudethe list could contain zero or more sets
09:18opqdonutthey do surprising things when given non-sets. but I misread Borkdude's code, he's passing only sets
09:18opqdonutBorkdude: that's kinda like ##(apply - 1 (list))
09:18sexpbot⟹ -1
09:18Borkdudeso if it contains zero sets it is just intersection of one set, ok, that makes sense I guess
09:18opqdonuthmm, bad example
09:18opqdonutbut yeah
09:19Borkdudethen I will have to make a special case for this in my code
09:41ilyakwhat's the best way to transform list of lists to list?
09:41chouser(apply concat listlist)
09:41opqdonutapply concat
09:41opqdonutor flatten, if you don't have three levels anywhere
09:42ilyakI do
09:48chouser,(apply concat '((1 2 3) (4 5 6) (7 (8 (9)))))
09:48clojurebot(1 2 3 4 5 6 7 (8 (9)))
09:48chouser,(flatten '((1 2 3) (4 5 6) (7 (8 (9)))))
09:48clojurebot(1 2 3 4 5 6 7 8 9)
09:49chouser,(apply concat '((1 2 3) 5 (7 (8 (9)))))
09:49clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
10:01dnolenhttps://gist.github.com/1026540 parser for Lisp in core.logic. dog slow until I get a deeper understanding of pruning ....
10:10mrBlissdnolen: I really like the work you're doing. Do you plan on adding comments or docstrings to core.logic? It would make reading the code examples much easier ;-)
10:22ilyakhi *
10:23ilyakI have a construct like (let [^SQLQuery query (.createSQLQuery sF whatever)] (.. query (addScalar foo foo) (setParameterList bar bar)))
10:24ilyakand clojure complains that it can not resolve calls to addScalar and setParameterList
10:24ilyak(i.e. it would use reflection)
10:24jweissi'm getting an NPE in technomancy 's serializable-fn lib, thrown by flatten. i can't figure out what i can pass to flatten to make it throw NPE
10:24ilyakWhy is that? I think that it should be able to
10:24ilyak(Maybe it's because this construct is located inside macro?)
10:25gfrlogilyak: you're trying to call two methods on the query?
10:25chouserilyak: (a) I wouldn't worry about it. turn off reflection and be happy. Or (b) make sure the *arguments* to the methods are hinted enough as well
10:26gfrlogoh never mind I forgot how (..) works
10:26ilyakgfrlog: It's hibernate query, it supports method chaining
10:27gfrlogjweiss: you could redef (flatten) to try to catch whatever is doing it, right?
10:27ilyakchouser: Arguments are literals mostly in another method
10:27gfrlog(just for debugging I mean)
10:27ilyak(since it's macro)
10:27ilyakchouser: How would one turn off reflection and what would happen then?
10:27chousersorry, turn off reflection warnings
10:27ilyakOh
10:28chouser(set! *warn-on-reflection* false)
10:28ilyakBut the problem is that the code is performance sensitive
10:28chouseroh
10:28chouser:-(
10:28gfrlogtell the code to man up
10:28ilyak(tho I understand that SQL query is something which would eat any constant perfomance gains)
10:28ilyak(So I'm probably barking at the wrong tree)
10:30ilyakWould jvm7 have invokedynamic?
10:30ilyak(would jvm7 ever be?)
10:30jweissgfrlog: yeah, but i don't want to redefine flatten, i want to know what it's choking on
10:31jweissit's a well-known enough fn that i would think if it were a bug it'd be fixed by now. so it's not a bug in flatten, it's just certain inputs cause NPE, someone must already know what inputs do that
10:32gfrlogjweiss: I don't mean redef it to make your code run, I mean redef it to find what it's chocking on
10:32gfrlogs/chocking/choking
10:32sexpbot<gfrlog> jweiss: I don't mean redef it to make your code run, I mean redef it to find what it's choking on
10:33gfrlogjweiss: e.g., redef it to wrap a call to the old (flatten) in a try block, and when it catches an error, print out the args that made it choke
10:34jweissgfrlog: i see
10:34gfrlog(let [old-flatten flatten] (binding [flatten (fn [& args] (try (apply old-flatten args) (catch Exception e (prn "(flatten) choked on" args) (throw e))))] (do-stuff)))
10:35gfrlogjweiss: ^ that is of the top of my head, totally untested
10:36gfrlogI don't even know if the parens match
10:38dnolenmrBliss: yeah I will at some point, though I can't promise soon, things are far from being shaken out.
10:39gfrlogCan somebody explain what's up with ^dynamic in 1.3? Specifically, I thought the change meant that you couldn't do (binding [my-var ...]) on a var not declared dynamic, but yet I thought I saw a (with-redefs) somewhere that claimed to work around it somehow. Does that mean that you're still allowed to redef, but not to use the (binding) stack-thing?
10:39cemerickSo, google spreadsheet forms are just as crummy as they were last year… :-/
10:39dnolengfrlog: with-redefs changes the root binding and then restores. only good for mocking nothing else really.
10:39jweissgfrlog: interesting, the underlying problem is that the lib tries to get a field .v on some object that doesn't ahve that field. probably supposed to be some internal clojure class that has it, and whatever it's analyzing isn't of that class
10:40gfrlogso you can change the root binding but you can't use the bindings-stack, is that accurate?
10:40gfrlogif so, I'm surprised that that change affects performance. But that's because I don't know how it's all implemented.
10:42chouserRich talked about how that's implemented and why it's faster in a talk at Clojure Conj 2010
10:42chouserwhich should be available as a video somewhere.
10:42gfrlogchouser: I guess I wasn't listening then, cause I was there
10:42chouserheh. oh. :-)
10:42gfrlogor at least I've since forgotten
10:43gfrlogbut I'll look it up to refresh, thanks
10:43gfrlogI assume it's the talk that wasn't about hammocks
10:44mrBlissapparently that video hasn't been uploaded :-(
10:45gfrlogI remember him talking about the subject but don't remember the technical details
10:46chouseroh no, really?
10:46gfrlogthe clojure blip site has neither of the hickey keynotes
10:47chouserI'm pretty sure he talked about the global var version number, and I doubt that's documented anywhere else other than the code.
10:48gfrlogthat rings a faint bell
10:48gfrlogfaintly rings a bell? rings a very small bell?
11:00chouserSo, I'm watching Halloway's Radical Simplicity talk
11:00chouserand he's dumping on my 'show' function, as is his right
11:01chouserand using it to demostrate the power and benefits of decomposing a problem into simple parts
11:02chouserBut my problem with that line of reasoning is that I know the end of this story, and what we have now at the REPL instead of 'show' is lousy to actually *use* compared to 'show'
11:04wastrelwhat's show?
11:04chouserjust lets to look at the methods and fields provided by a Java class.
11:04halfprogrammerreflection utility
11:06halfprogrammerI would have loved to have both show and whatever Halloway explained the talk. That would have made life simpler
11:28gfrlogleiningen's checkouts feature works splendidly
11:45symboleIs it wise to use clojure 1.2.1 with clojure-contrib 1.2.0? Is it recommended for their versions to match?
11:58pjstadigsymbole: there is no 1.2.1 release of contrib AFAIK
11:59pjstadigi think it's fine to mix 'em
11:59symbolepjstadig: Thanks.
12:07paohi all! do you suggest 1.2 or 1.3 for learning clojure?
12:08gfrlog1.2 is probably more googleable...? :/
12:08fliebelGood point, but I wouldn't shy away from 1.3 if you get the chance.
12:09gfrlogI personally don't even know how to obtain 1.3 :-D
12:09fliebelgfrlog: That's just a matter of finding the right Lein line.
12:09gfrlogyeah, I figured so
12:10dnolen:dependencies [[org.clojure/clojure "1.3.0-alpha8"]]
12:10gfrlogfliebel: was that a pun?
12:10paofliebel, thanks :-)
12:10fliebel[org.clojure/clojure "1.3.0-alpha7"] it is I believe. oh dnolen is fats!
12:10fliebelfats
12:10fliebelgrr!
12:10paofliebel, using leinin is ok even when the initial goal is only to get a repl?
12:11dnolenlisp parser in core.logic that's 40X faster than previously than earlier, https://gist.github.com/1026540
12:11dnolencommited-choice for the the win.
12:11fliebelpao: Yea, or cake. Cake is more customizable as a standalone repl.
12:12gfrlogpao: I believe "lein repl" will launch a repl with no surrounding project
12:12manutter"googling for cake" I shoulda named my new blog that
12:13fliebelgfrlog: cake will do the same, but has a global project somewhere that you can customize.
12:13gfrlogah hah
12:13paogfrlog, but I guess I need to specify the clojure version somewhere, right?
12:13manutterI just typed "lein repl" with no project, and it brought up a repl without complaining
12:13fliebelpao: Right, lein just gets you 1.2.1, cake gets you whatever your global project is.
12:13gfrlogpao: oh right. So if you want to do that, then you probably need a project. I don't know nuthin bout cake, but these folk make it sound good
12:14gfrlogdon't you gotta have rubygems to install cake?
12:14fliebeldnolen: Nice! Whats "than previously than earlier"
12:14fliebelgfrlog: That's the easy way. You cna also get it right from github.
12:14gfrlogoh okay; that's more reasonable
12:15paois cake that written in ruby
12:15pao?
12:15paos/that//
12:15duck1123clojure 1.3 is good, but be prepared to have to hack every single library you touch
12:15fliebelpao: It's wrapped in Ruby sause for convenience. The larges part of it is still Clojure.
12:16paofliebel, thanks
12:16dnolenfliebel: actually much more than 40X faster, I had an earlier version that didn't do pruning, it's runtime grew exponentially on the number of tokens.
12:19fliebeldnolen: Interesting. Any thoughts about ambiguity? Have you compared it to the 'official' reader?
12:22fliebeldnolen: What am I looking at here? A toy, or an aspect of something bigger(types?)?
12:22dnolenfliebel: no thoughts on ambiguity yet. I just got this working. I don't think core.logic DCGs will compete with a crafted parser anytime soon. it is an interested way to measure performance of core.logic on non-trivial programs tho, as well as give insight as to what needs improving.
12:23fliebelDCG?
12:24dnolenfliebel: at the moment just this is just exploration. but yes it would make it easy to build a type checker prototype purely in core.logic.
12:24dnolenDefinite Clause Grammar
12:26Cozeyhello. is there some *warn-on-lazyness*, or other lazyness debugging technique? i have my DB getters executed out of transaction because of this - how would you debug this?
12:28dnolenCozey: few techniques for laziness besides being extra careful, I think if you want to avoid the hassle, wrap your lazy-seqs in doall.
12:28fliebelGood old print statements also help :)
12:28Cozeymhm did that :-) but still haven't traced the problem
12:28Cozeywill be more extra careful :-)
12:29dnolenfliebel: unless those print statement are inside the lazy-seq computation.
12:29cemerickOK, last call for survey questions.
12:29cemerickAlso, any nominations to add to this list of options? https://gist.github.com/bc97ecc5d1c820ce93db
12:31fliebelcemerick: Remind me of the current list again?
12:31hiredman"how much wood would a woodchuck chuck if a woodchuck would chuck wood?"
12:31fliebelhiredman: 42
12:31cemerickfliebel: http://cemerick.com/2010/06/07/results-from-the-state-of-clojure-summer-2010-survey/
12:34amalloyyou don't need to write org.clojure/clojure - plain old "clojure" is fine
12:34fliebelamalloy: I thought that only worked if the prefix is equal to the name?
12:35dnolenwow DCGs in Prolog are insanely fast ...
12:35pjstadigcemerick: how about frequency of releases?
12:35amalloyfliebel: clojure and contrib are special-cased
12:35cemerickpjstadig: good
12:36fliebelcemerick: Environment stuff?
12:36manuttercemerick: and along with frequency of releases, dev dependencies
12:36cemerickfliebel: ?
12:36fliebelKeep it under 3 pages please :P
12:36cemerickmanutter: "dev dependencies"?
12:36manutteras in "I upgraded to 1.3, and clj-foo, on which I depend, now crashes"
12:37fliebelcemerick: Well, are people already using 1.3 or jdk 7 and such..
12:38cemerickpjstadig: perhaps "Lack of public roadmap"?
12:38fliebeldnolen: Any idea why? I bet it's fast predicate dispatch...
12:38pjstadigwell not just that
12:38pjstadigmaybe at least bug fix releases
12:39dnolenfliebel: no specific ideas no ... where are the papers?!
12:39pjstadigcemerick: but roadmap is good too
12:40fliebelcemerick: Everything on your list twice. http://xkcd.com/468/
12:40cemerickheh, right
12:41cemerickpjstadig: I think I'll use "Frequency/predictability of official releases"
12:41fliebelcemerick: I came to that when I was thinking about where people would be using clojure next year.
12:51cemerickHoly shit, I think Google just ate the survey I built.
12:55gfrlogTo the cloud!
12:56Cran1988:D
12:57chousercemerick: undo!
12:57paois it safe to use clojure-contrib 1.2 with clojure 1.3.0-alpha8?
12:58cemerickchouser: no dice: the form builder was never saving anything, and clicking the save button seems to be a no op (aside from the mocking yellow "Saving…" label that shows up at the top of the page).
12:59chouser:-(
13:17dnolenfliebel: hmm ... I wonder if miniKanren's fair scheduling isn't the problem here. DCGs form very long chains of computations ... I've been thinking about making the search strategy configurable, bringing back depth first.
13:23dnolenhmmm ... ISearchStrategy protocol ...
13:25amalloyi'm getting this weird behavior from clojure.test, and i can't find a minimal test-case to reproduce it. https://gist.github.com/1027587 is a gist showing some test cases i have, in which (every? #{1} (a function that returns '(1 1))) fails, as a test
13:25amalloybut (every? #{1}
13:26amalloy'(1 1)) passes
13:26gfrlog&(class '(1 1))
13:26sexpbot⟹ clojure.lang.PersistentList
13:26gfrlogamalloy: your function returns a c.l.PL?
13:27raekamalloy: what are the classes of the numbers?
13:27amalloygfrlog: no, it in fact returns a lazy-seq (which is mentioned in the gist)
13:27amalloyraek: oh man. i bet that's it
13:27gfrlogoh I should go read TFG I guess
13:27gfrlogs/read TFG/RTFG
13:27sexpbot<gfrlog> oh I should go RTFG I guess
13:27raek,(every? #{1} [(int 1) (short 1)])
13:27clojurebotfalse
13:28gfrlog,(every? #(= % 1) [(int 1) (short 1)])
13:28clojurebottrue
13:29amalloyraek: do you think i should map the input sequence to int, or use = instead of #{1} to test? neither seems very clear
13:29raekwell, = has the right semantics
13:29gfrlog,(hash-map (int 1) :foo (short 1) :bar)
13:29clojurebot{1 :foo, 1 :bar}
13:30raekamalloy: so I vote for =
13:31fliebeldnolen: Hm, sounds like an idea.
13:31raek,(every? (partial = 1) [(int 1) (short 1)])
13:31clojurebottrue
13:31gfrlog,(map #(identical? % 1) [(int 1) (short 1)])
13:31clojurebot(true false)
13:31gfrlogthat can't be what #{} is doing though...
13:32amalloygfrlog: it's hashing them
13:32amalloy&(map hash ((juxt int short) 1))
13:32sexpbot⟹ (1 1)
13:32amalloyhm
13:32raekI suspect set-as-function uses .equals
13:32amalloy&(map (comp class hash) ((juxt int short) 1))
13:32sexpbot⟹ (java.lang.Integer java.lang.Integer)
13:32gfrlog,(identical? (hash (int 1)) (hash (short 1)))
13:32clojurebottrue
13:32raek,(.equals (int 1) (short 1))
13:32clojurebotfalse
13:33hiredmanon 1.2 it definitely does
13:35raekthe uniformly boxed numbers of 1.3 sounds like a good idea
13:35dnolenfliebel: yeah I think interleaving is great for constraints, that's why zebra is so fast. but perhaps not so much for DCGs. For example DCG for checking whitespace is 100X on input string of 1e4 vs 1e3, this is because mk starts producing answers right away where Prolog would immediately search for the longest contiguous whitespace.
13:36dnolenmight be wrong of course, need to look into it more.
13:39cemerickThe 2011 State of Clojure survey is open: http://cemerick.com/2011/06/15/the-2011-state-of-clojure-survey-is-open/
13:40cemerickRaynes: that one's for you, buddy :-)
13:42hiredman"Matadata"?
13:42cemerickcrap :-P
13:43cemericksuch things happen after google docs fails you and you have to type things in *twice*
13:43cemerickfixed
13:44amalloycemerick: putting eclipse first on the list, you sly dog
13:44cemerickamalloy: it's alphabetized, except for "Command-line REPL" :-P
13:44amalloy*chuckle*
13:45cemerickGo fork emacs and call it AAEmacs.
13:45gfrlogwhy is "immutability" not on the wins list
13:45amalloyaquamacs already had that idea
13:46cemerickamalloy: good point
13:46cemerickAquamacs, the yellow pages strategy for emacs marketing
13:47technomancyAquamacs: a tricycle bolted to the side of a humvee.
13:47cemerickgfrlog: gratuitous error on my part. #844, actually. Fixed now.
13:47cemerickAnd yet, as hard as I might've pushed on those pedals…
13:47dnolentechnomancy: and sadly the only way to work Mozart/OZ on OS X that's sane.
13:47technomancydnolen: eep
13:48chouserAquamacs: arcane development environment, now with a pretty Mac skin!
13:48chouserand just to be fair... gvim: arcane fixed-width text editor, now pretending to have a gui!
13:49gfrlogcemerick: does that mean I'm going to have to refresh the page and click all the checkboxes all over again? you don't know what that's like!
13:49hiredmangnu emacs is so pretty on my mac
13:50hiredmanemacs 24 with the nextstep fullscreen patch, delicious
13:52cemerickanyway, if someone could post that link on HN, proggit, et al., that'd be nifty
13:55fliebelcemerick: there you go http://news.ycombinator.com/item?id=2658246
14:01Raynescemerick: Yay!
14:03RaynesNothing I enjoy more than filling out surveys
14:40bdeshamis there any difference between (apply conj ...) and (into ...)?
14:41bdeshamspecifically, I don't see any difference if you're dealing with maps
14:41amalloyinto will use a transient, which will be faster
14:41bdeshamok
14:42amalloyi mean, if you look at the source of into, it's just creating a transient, then using reduce conj, then making the thing persistent again
14:43bdeshamright
14:59Dranikhi all!
15:02bdeshamhi Dranik
15:09gfrlog&(clojure.string/blank? ",")
15:09sexpbot⟹ false
15:09gfrlogah HA
15:10gfrlogsorry that was a terrible joke
15:33mattmitchellthis is more of an emacs/paredit question but figured someone here would know... I want to turn ({:one 1}) into (:one 1) how do i do that with paredit?
15:34raekmattmitchell: press M-s within the curly braces
15:35mattmitchellraek: awesome thanks
15:35amalloymattmitchell, raek: i do it by pressing M-<UP> with point before the :
15:36amalloyi didn't even know about M-s. handy
15:38Scriptormattmitchell: just found this: http://www.emacswiki.org/emacs/PareditCheatsheet
15:38Scriptorlooks useful
15:39mattmitchellScriptor: nice, very helpful. thanks.
15:40halfprogrammerI dint know it either. Thanks for the tip
15:40lawfulfalafelI have been trying to setup emacs for writing clojure, and at the bottom (the mode I believe) it says "Clojure Hi Paredit Fill". Is my emacs correctly setup?
15:41amalloylawfulfalafel: those modes all sound fine to me
15:42amalloyi don't use Hi, and usually not Fill either, but they're fine; and Clojure and Paredit are the key modes
15:42halfprogrammerlawfulfalafel: I also have installed autocomplete.el. It's real handy
15:42amalloyagreed
15:42amalloymy modeline is Clojure AC Paredit Slime Abbrev
15:43amalloybut AC is really just a gui layer over M-/ -- it's not really necessary
15:44Scriptorthe shortcut to starting up slime and swank in one go is M-x clojure-jack-in, right?
15:45raekScriptor: yes. (assuming you have a recent version of clojure-mode)
15:46Scriptorargh, getting 'exited abnormally with code 1'
15:46hiredmanyou are missing swank-clojure most likely
15:46halfprogrammeramalloy: I still like the gui it provides
15:47ScriptorI'm pretty sure I have swank-clojure, I can set up a repl by just using lein swank and M-x slime separeately
15:47Scriptor*separately
15:48raekScriptor: M-x slime or M-x slime-connect?
15:48vijaykiranScriptor: I think I saw this error when there's version conflict for swank-clojure
15:48Scriptorraek: M-x slime-connect
15:48Scriptorah
15:49raekScriptor: also, what version of swank-clojure? I think you need a recent one
15:49Scriptorlooks like I have 1.3.1
15:49Scriptor(for swank-clojure)
15:50raekeasisest way is probably to remove it from the project.clj (if it's there) and remove any old version from ~/.lein/plugins/ and then do "lein plugin install swank-clojure 1.3.1"
15:50lawfulfalafelhalfprogrammer: okay, I installed autocomplete through the emacs-starter kit, but what do I have to add to my .emacs to use it?
15:50lawfulfalafelI tried googling it, but none of the tutorials mention it, so I don't know if that's actually important
15:50halfprogrammer_ah..this flakey internet
15:50halfprogrammer_s/internet/wifi
15:50sexpbot<halfprogrammer_> ah..this flakey wifi
15:51vijaykiranScriptor: as raek says - I think you should remove it from dev-deps
15:51halfprogrammer_(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete")
15:51Scriptorraek, vijaykiran: thanks
15:51vijaykiranScriptor: see the "Update" here: http://technomancy.us/149
15:51amalloyhalfprogrammer_: i do too, which is why i use it
15:52halfprogrammer_lawfulfalafel: add (add-to-list 'load-path "~/.emacs.d/plugins/auto-complete") to your .emacs file
15:53jaohmm. so priority-map is not in clojure-contrib 1.2, and i cannot find it elsewhere. am i missing something?
15:54dnolenjao: mark engelberg hasn't requested to move it into's it's own repo. Should probably post something about that on the ML.
15:54jaodnolen, i see. thanks. so my best bet is to get the source code, i guess.
15:55dnolenjao: I think it's important to express interest. priority map seems to be used quite a lot.
15:56lawfulfalafelhalfprogrammer_:thank you, that's an awesome utility
15:56halfprogrammer_auto-complete.el FTW!
15:56jaodnolen, fair enough.
15:56lawfulfalafeljust out of curiosity, how do you guys learn about this sort of stuff?
15:56Scriptorlawfulfalafel: what stuff?
15:57lawfulfalafeluseful emacs utilities
15:57amalloylawfulfalafel: you learn a lot hanging out in #clojure and #emacs
15:57lawfulfalafelbut not websites?
15:58mrBlisslawfulfalafel: http://www.emacswiki.org/
15:58amalloyuhh...how do i answer that question? "yes, sometimes i view websites?"
15:58lawfulfalafelwell no, I mean you know, a "planet emacs" congregation of emacs blogs or something
15:58lawfulfalafelI mean I am used to seeing it for languages, but I'm ignorant of anything like that for emacs
15:59lawfulfalafelmaybe I just have weird expectations
16:00mrBlisslawfulfalafel: there's a planet.emacsen.org (p.s. you have heard of 'The Google' right? ;-)
16:00halfprogrammerlawfulfalafel: Guess wat, there is even a nice SO question reg that
16:00halfprogrammerhttp://stackoverflow.com/questions/271924/what-is-your-favourite-plugin-in-emacs
16:02lawfulfalafelthank you, those links are awesome
16:05Scriptorwhere does lein store the plugins on windows, anywhere other than the project's directory?
16:07mrBlissScriptor: %APPDATA%\.lein\
16:08halfprogrammergoing to crash for the night. see you guys in the morning!
16:11amalloytechnomancy: i've noticed that the slime repl doesn't indent things nearly as well as the clojure-mode buffers. is there an easy way to make that happen?
16:13mrBlissamalloy: does (setq lisp-indent-function 'clojure-indent-function) help?
16:13amalloymrBliss: no difference
16:14mrBlissamalloy: and (set-syntax-table clojure-mode-syntax-table)
16:14amalloyah, that does it. i wondered if setting the syntax table would be enough
16:15amalloymrBliss: thanks, i'll find someplace to add that to my slime hook
16:29mattmitchellanyone every see slime/swank freak out like this? https://gist.github.com/1028011
16:31raekmattmitchell: M-x customize-variable <RET> slime-net-coding-system --> utf-8-unix
16:31raekthen reconnect slime
16:35mattmitchellraek: awesome thanks! would've never figured that out.
16:35Raynesraek is the king of all things unicode.
16:35raektechnomancy: do you think it's possible to make clojure-jack-in rebind slime-net-coding-system?
16:36raekRaynes: my native language is not English; I have to
16:36technomancyraek: seems reasonable. should it ever be set to a value other than utf-8-unix?
16:36RaynesSo, clojure-jack-in automatically assumes the user has leiningen? Is this configurable?
16:36raektechnomancy: IMHO, no
16:37amalloyspeaking of which, raek, wasn't ☃.com a link to a cute little snowman? now it looks like a dns squatter
16:37raekamalloy: no, that was http://☃.net/ ;-)
16:37technomancyRaynes: yes, it's a defvar
16:37RaynesCool!
16:38raekRaynes: https://github.com/technomancy/clojure-mode/blob/master/clojure-mode.el#L833
16:38amalloybest thing ever
16:38technomancyraek: all I know is that sometimes macosecks does crazy things with macroman
16:38RaynesI might actually use slime ever now and then now.
16:38technomancy*mac-roman
16:38RaynesI usually just fire up a cake repl when I need it.
16:38technomancymacroman sounds like a superhero
16:39offby1the macroman movie is coming out this summer from Sony
16:39raektechnomancy: some time ago I think swank-clojure changed its default encoding (I don't have to set it to UTF-8 anymore) is this correct=
16:39raek?
16:39amalloyoffby1: last i heard someone hacked into that movie tho
16:39technomancyraek: ISTR doing that on the clojure side, yes
16:39offby1amalloy: I hear the screenplay is unhygienic
16:40offby1amalloy: of course, I should have said: "The script is unhygienic"
16:40raekyeah, I've heard that the JVM on mac osx think mac-roman is the OS default encoding (but mac osx actually uses utf-8, iirc)
16:40technomancyI guess the problems with platform-specific encodings like MacRoman manifest with command-line interactions, swank is isolated from that via sockets
16:41technomancyRaynes: it doesn't just magically work with other tools though; you have to port the clojure side of jack-in.
16:41Scriptorare there any issues with swank-clojure on windows, regarding clojure-jack-in?
16:41Raynestechnomancy: I know. I'm about to do that.
16:41raekyes, as long as we control both ends, we can set the encoding to whatever we want
16:41technomancyraek: cool; will fix it in clo-mo then
16:41technomancythanks for the heads-up
16:42raekos default encoding is only useful as a default for terminals and text files created locally
16:42raekbut is kinda build on the assumtion that text isn't transferred between computers :/
16:44raektechnomancy: that would be marvellous! that would make any character simply work out of the box. (now you have to config the emacs end manually, if you even know you can)
17:00jcromartieWhat's the best way to "concat" a vector?
17:00jcromartieOr... I have a structure that ends up doing lots of concatenation while "building up" the final structure (using reduce)
17:01jcromartieand I am finding that certain cases result in a stack overflow due to all of the pending lazy concats on certain values...
17:01fliebeljcromartie: As far as I know the answer is "don't do that", lists are more efficient with that.
17:01fliebelor... hm
17:01jcromartiebecause I have dual needs
17:01jcromartieI need to do lots of concatenation
17:01jcromartieand I need to access it with nth
17:02gfrlogfinger trees?
17:02gfrlogI have no idea if they concat well :/
17:02jcromartieline 57 here is the source of all of the concats https://gist.github.com/1023496
17:02fliebelyah, they are awesome for everything...
17:02gfrlogI propose renaming finger trees "chouser-trees"
17:03jcromartie(reduce train-trigrams (make-brain) (.split (slurp "/path/to/stuff.txt") "\n"))
17:03amalloyfinger trees concat quickly, yes
17:04gfrlogand they also nth well?
17:04raekjcromartie: one way is to call doall on the intermediate results
17:04jcromartiegood idea raek
17:04gfrlogwhy not just call vec?
17:04jcromartiethe longest one is 3702... pretty much all one concat at a time
17:04raekjcromartie: then when you evaluate the first element of the resulting seq it won't trigger a cascade of forcings
17:05jcromartie3702 concats
17:05jcromartieall deferred
17:05gfrlog,(class (concat [] []))
17:05clojurebotclojure.lang.LazySeq
17:05raekjcromartie: using (into intermediary-vector some-elements) is another alternative
17:05hiredmandepending on the content of your lists you could also emit [(1 2) [(3 4) (5 6)]] and then write a lazy-seq function to flatten into a single seq in a single pass
17:06raekinteresting
17:06jcromartieyeah the order doesn't really matter until I'm "done" with it
17:07jcromartieto make it ready for reading
17:07gfrlogthe order doesn't matter but you need nth?
17:07jcromartieyes :)
17:07jcromartiethe order doesn't matter when adding
17:07hiredmansort of like erlang io lists
17:07jcromartiebut I use rand-nth to select items at random
17:07jcromartiebasically it's just a "bag" that I randomly pick out of
17:07gfrlogah hah
17:08lawfulfalafelI am getting a weird bug with this code: http://pastebin.com/JMne4AAm
17:08lawfulfalafeljava.lang.Exception: Unable to resolve symbol: lst in this context (euler.clj:5)
17:08jcromartieinstead of counting the occurrences
17:08gfrloglawfulfalafel: don't reinvent the wheel! just use clojure.contrib.fib
17:09lawfulfalafelgfrlog: I would, but I would rather learn how to implement it myself for the euler problems
17:09gfrlog:) btw, (- limit 1) is (dec limit)
17:09gfrlogbut that's probably not why it's failing
17:10gfrloglawfulfalafel: ah I see
17:11raeklawfulfalafel: you are missing pares around the argument vectors and function bodies
17:11gfrlog^
17:11fliebelHm looking at the survey, I can;t remember when #clojure had 6 people, but I remember when the chunked seq stuff was new. How long ago would that be?
17:11raeklawfulfalafel: (defn f ([x] ...) ([x y] ...))
17:11lawfulfalafelah, thank you
17:11hiredmanpre 1.2
17:12fliebelhiredman: So, how many years?
17:12jcromartieah!
17:12hiredmanfliebel: check the git lot
17:12gfrlogfliebel: I think maybe 2
17:12jcromartie(merge-with into ...) was the answer
17:13jcromartiegood performance all around now
17:13jcromartielove merge-with
17:13jcromartiein fact, amazingly fast compared to before
17:13jcromartieon both ends... building the index and producing text
17:22fliebeljcromartie: What are you making?
17:33lawfulfalafelcan someone help me understand conj?
17:33lawfulfalafeluser=> (conj 3 '(1 2)) gives me "java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection (NO_SOURCE_FILE:0)"
17:34amalloyorder is wrong
17:34dnolenlawfulfalafel: conj takes collection as first arg
17:34amalloy&(conj '(1 2) 3)
17:34sexpbot⟹ (3 1 2)
17:34brehaut,(conj '(1 2) 3)
17:34clojurebot(3 1 2)
17:34dnolen,(doc conj)
17:34clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
17:34lawfulfalafelhow do you add to the back of a list? do I have to add a call to reverse?
17:34jcromartiefliebel: deterministic Markov-chain-based test data generation
17:34dnolenlawfulfalafel: only vectors add efficiently at the back.
17:35amalloylawfulfalafel: don't add to the end of a list; it's slow for immutable lists
17:35jcromartiefliebel: take your real data, and turn it into real-looking gibberish
17:36jcromartie"McEnroy Timerinession Pipervices, Inc." "Linklen and Muse, Weaguels" "Radicinds, LLC."
17:36lawfulfalafelhttp://stackoverflow.com/questions/1147975/in-clojure-when-should-i-use-a-vector-over-a-list-and-the-other-way-around
17:36jcromartie(company names)
17:36lawfulfalafelthat's what made me think that I should use a list, since I only want to append
17:36amalloyaww, so cute to find questions Raynes asked two years ago
17:37amalloylawfulfalafel: the accepted answer is bad
17:37fliebeljcromartie: Have you seen that post about this on HN? Wait, I'll check my history
17:37amalloyarguably all the answers are bad
17:37amalloybut the one Raynes posted himself, quoting rhickey, is true
17:38lawfulfalafelamalloy: really? I always thought so was pretty objective
17:38Raynesamalloy: I generally accepted my own answer as correct, but I didn't want to select my own answer for obvious reasons.
17:38amalloylawfulfalafel: yes, it is objective
17:38amalloythat doesn't make it correct?
17:39lawfulfalafeljust assumed a meritocracy would push the right answers to the top
17:39jcromartiefliebel: hm, not sure
17:39amalloylawfulfalafel: it did. Raynes's answer has more votes than the accepted answer
17:39amalloybut accepted answers are always first
17:39fliebeljcromartie: http://www.cs.bell-labs.com/cm/cs/pearls/sec153.html
17:40lawfulfalafellol, I didn't think of that
17:40jcromartieah yes, fliebel
17:40jcromartiethat's what spurred the whole thing :)
17:40jcromartieI started playing with Markov chains
17:40Raynesamalloy: I went ahead and accepted my own answer just now.
17:40jcromartiethen I thought... how about using this for test data?
17:40jcromartiewhich we need
17:40RaynesChris isn't going to notice, with his 44k reputation.
17:40amalloyRaynes: yeah, when the accepted answer is blatantly wrong i approve of that choice
17:40amalloyit would have been right in java
17:41jcromartieand then I thought: I can use a hash of a value from the training set to seed the PRNG so that the same inputs create the same outputs
17:41jcromartieanyway
17:41jcromartiefun stuff
17:41jcromartieMarkov hash functions :)
17:41fliebeljcromartie: I love them, I did rock-paper-scissor with a markov chain.
17:42jcromartieso far it's been a great learning endeavor
17:42jcromartiehopefully it pays off in usefulness
17:43lawfulfalafelokay, I am trying to change a list '(1 2) to this '[1 2], but paredit is making it really hard for me to figure out how
17:44lawfulfalafelI'm looking at this and don't get which command I should use: http://www.emacswiki.org/emacs/PareditCheatsheet
17:44amalloylawfulfalafel: if you find it, let me know; my method of doing this is pretty bad
17:45chouser%r]^Or[
17:45fliebelchouser: Do you have a cat?
17:45RaynesI'd just do M-s inside of the brackets to get rid of them and then create new brackets after the ' and before the one and then C-rightarrow to slurp up the two numbers.
17:45chouserthat's good old-fashioned vim
17:45RaynesWhich is equally awful.
17:46amalloyRaynes: i have a way more efficient version: wrap in brackets *first*, slurping only once, and then splice :P
17:46RaynesHehe
17:47raeklawfulfalafel: if you select a piece of text and the press [ it will be wrapped in [ and ]
17:48fliebelchouser: Doesn't work for me. Can you explain what it should do?
17:49amalloyraek: i guess i knew that, but i never use it. definitely more convenient than what i'm currently doing
17:49chouserstart on the left paren, % to bounce to the matching right paren, r] to replace it with bracket Ctrl-O to go to previous cursor position (the open paren) then r[ to fix that one.
17:50fliebelchouser: Ah! I was pressing ^ (start of line) and then O (insert above)
17:50chouseryeah, that probably should have been <C-O> or something
17:50amalloychouser: i don't use vim and ^O was fairly clear to me
17:51amalloybut i guess you could have meant ^ then O
17:58lawfulfalafelamalloy: you probably know this, but M-s within a parens removes them
17:58amalloyyes, raek said that earlier today
17:58lawfulfalafellol
17:59lawfulfalafelI just came back from googling this forever
17:59lawfulfalafelRaynes: thanks
17:59hiredmanM-r is also good
18:04TimMcM-x paredit-paren-to-square :-P
18:04amalloyTimMc: you are a cruel tease
18:05TimMcor CM^☃
18:05TimMcerr... C-M-☃
18:07amalloyi love the :let/:when feature in `for`
18:12lawfulfalafelmy solution to a euler problem is really slow: http://pastebin.com/mpSrPcV8
18:13lawfulfalafelsupposed to be working with the first 4000000 fib numbers, and it's been running for a few minutes now
18:13lawfulfalafelI think it's slow because I am misusing vectors, but not sure
18:15the-kennylawfulfalafel: How costly is reverse?
18:15the-kennyyou do it two times, on the same list.
18:16the-kenny(let [[item1 item2 & _] (reverse lst)]) should perform better (not sure if the syntax is correct, though
18:16lawfulfalafelwait, I misread the euler question
18:17lawfulfalafelit's of all fib numbers below 4000000, not the first 4000000 fib numbers
18:17lawfulfalafelmy mistake
18:22amalloylawfulfalafel: yeah, calling reverse like that is kinda crazy anyway
18:23amalloyif you wanted something that uses the same algorithm, you could do like (let [[item2 item1] (take-last 2 lst)])
18:24amalloy(of course, item1 item2 is an ordering that makes more sense, but this preserves identical bindings to your version)
18:24amalloy&(let [lst (range 10), [a b] (take-last 2 lst)] {:a a :b b})
18:24sexpbot⟹ {:a 8, :b 9}
18:27gfrlog(defmacro make-with-keys [& ks] `(hash-map ~@(interleave (map keyword ks) ks)))
18:30amalloyi don't really like that implementation. keywordize in amalloy-utils looks like (into {} (map (juxt keyword identity) ks))) iirc
18:30hiredmanamalloy: can't be that
18:31amalloyhiredman: just checked, at https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils.clj#L30, and it is. why do you think it isn't?
18:31amalloyit's still a macro, of course
18:31hiredmanbecause juxt doesn't work like that
18:31hiredmanoh
18:32amalloy&(let [ks '(a b)] (into {} (map (juxt keyword identity) ks)))
18:32sexpbot⟹ {:a a, :b b}
18:32hiredmanI thought "keywordize" meant take an existing map and turn the keys into keywords
18:32amalloyhiredman: no, i named my function before i heard about keywordize-keys in contrib
18:32hiredmanamalloy: you do know I've had sexpbot on ignore for almost a year now?
18:32amalloyhiredman: yeah, i forget :P
18:34gfrlogamalloy: does sexpbot have hiredman on ignore?
18:35amalloyno, but he does ignore s/foo/bar when coming from hiredman
18:40lawfulfalafelhow do you efficiently remove the last element of a vector list?
18:40technomancyI think dissoc will do it
18:41raeklawfulfalafel: of a vector? pop. of a list or seq? no efficient way.
18:41raek,(pop [1 2 3])
18:41clojurebot[1 2]
18:44lawfulfalafelraek: thanks, pop is what I was looking for
18:44gfrlog,(fn? [])
18:44clojurebotfalse
18:44raek,(ifn? [])
18:44clojurebottrue
18:44gfrloginteresting
18:45raekimplementation vs interface, same thing with list? and seq?
18:47lawfulfalafelokay, I have rewritten my euler code, but it's still generating the wrong number (here's the code: http://pastebin.com/i1WDpcqd)
18:48hiredmanlawfulfalafel: off by one error
18:50amalloy&(doc rseq)
18:50sexpbot⟹ "([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
18:50amalloy&(rseq '(1 2))
18:50sexpbotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Reversible
18:50amalloyhm. that's the behavior i expected, but i'm sure i've seen it behave differently before
18:51raekamalloy: you're not thinking about 'reverse'?
18:51amalloyraek: *chuckle* no, i know about reverse
18:52amalloybut someone solved the 4clojure "reverse a sequence" problem by using rseq, and it surprised me by working
18:52amalloybut looking at it now, i see we only use vectors and a sorted-set
18:52raeksounds unlikely that it would have worked for seqs
18:53lawfulfalafelhiredman: it's off by one?
18:53raekvectors and sorted-sets know how to traverse their internal structure in the reverse order
18:53lawfulfalafelI keep testing it with low numbers and it's behaving expectantly
18:53amalloyi checked, at the time, that there was a list; but we use the list as what to check answers against, not what to call the function with: http://4clojure.com/problem/23
18:54amalloyso that solves that little mystery for me :P
18:54hiredmanlawfulfalafel: that would be my guess, I would check the start of the sequence of numbers you are generating against the actually sequence, perhaps on the wikipedia article
18:55gfrloghiredman: the euler problem specifies the start of the sequence and he's doing it right
18:56hiredmangfrlog: could be, but his code says 'fib' and the start of his sequence doesn't match the start of fib
18:57lawfulfalafelwell only even numbers matter, so I don't think cutting off the 0,1 at the very beginning matter
18:57lawfulfalafelbut that's my assumption, probly wrong
19:00gfrloglawfulfalafel: I've done this problem before and my answer agrees with what your code gets (4613732)
19:00gfrlogI think you're wrong about getting it wrong
19:01lawfulfalafelgfrlog: lol, yep you're right. I was screwing up the confirmation code.
19:01lawfulfalafelsorry about wasting people's time with that
19:01gfrlog:)
19:02amalloy&(reduce + (filter even? (take-while #(< % 4e6) (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))))
19:02sexpbot⟹ 4613732
19:02technomancyraek: pushed clojure-mode fix
19:02technomancynot sure when it'll make it to a release though
19:03lawfulfalafelamalloy: that's a crazy awesome one-liner
19:04gfrlogamalloy: where's the juxt?
19:05amalloylawfulfalafel: using lazy sequences instead of vectors will make your life easier most of the time
19:05amalloyi mean, yes, vectors are great when you want them
19:05amalloybut for generating lists, you usually don't
19:06gfrloglawfulfalafel: re your apology, every good mystery has a plot twist at the end
19:15aaelonyhi, what is the best way to write a large data structure to a file?
19:15gfrlogtoo large for (spit "filename" (pr-str data-structure))?
19:16aaelonyprobably too large for spit. Is clojure.java.io/make-output-stream a good choice ?
19:18mattmitchellhow do you convert a hash-map to a vector or list?
19:18raekgfrlog: would (with-open [out (io/reader "filename")] (binding [*out* out] (pr data-structure))) be better?
19:18raekthen you skip the intermediate giant string
19:18gfrlograek: that's the sort of thing I was thinking. Nothing mixes me up like the java IO stuff though, so it usually takes me 4 guesses
19:19amalloymattmitchell: seq
19:19amalloy&(seq {1 2})
19:19sexpbot⟹ ([1 2])
19:19raekmattmitchell: what should the result look like, for example for the map {:a 1, :b 2}?
19:19gfrlogmaybe ##(seq {1 2 3 4 5 7}) is slightly clearer
19:19sexpbot⟹ ([1 2] [3 4] [5 7])
19:20amalloygfrlog: yeah
19:20raekgfrlog: er. I meant writer of course... :)
19:20gfrlogyeah :)
19:20zakwilsonI have some code that uses ClojureQL and it seems that the results of function calls are NOT being treated the same as using the values they return in their place. I'm probably doing something dumb here, but I'd really appreciate a second pair of eyes on this: http://pastebin.com/VMUxH9Pq
19:20gfrlogamalloy: ##((comp first (juxt seq)) {1 2 3 4})
19:20sexpbot⟹ ([1 2] [3 4])
19:20gfrlogthat way is clearly superior
19:21aaelonyraek and gfrlog: thanks. also open to hearing how others deal with large outputs. (even if this is antithetical to "no side-effects" I imagine)
19:22gfrlogzakwilson: what the heck is going on here?
19:24raektechnomancy: ok, I've tested it now. works perfectly!
19:25gfrlogzakwilson: do you have a simpler example of what you're wondering about?
19:27zakwilsongfrlog: no, I'm afraid not. I might be able to devise one, but I don't understand what's going wrong here at all.
19:28gfrlogyour (items-by-cat 3) example is not supposed to throw an exception?
19:28zakwilsonCorrect
19:28tremolozakwilson: it sounded like you had traced it to a line where a function didn't return what you expected. Can you elaborate on that a bit more, and maybe tell us which line it happened on?
19:29zakwilsontremolo: No, the function *does* return what is expected. When I substitute that value in to the copy-pasted body of items-by-cat, it works. When I call items-by-cat, it does not work.
19:30zakwilson(by "does not work" I mean it throws the exception mentioned in the past)
19:30zakwilsone
19:30gfrlogzakwilson: I wouldn't think this would be an issue, but one difference is that cat-and-subs will return a lazy-seq
19:30tremolozakwilson: ah, ok. got it.
19:30gfrlogso maybe try, in your final test code, replacing [3 5] with (concat '() [3 5]) or something like that?
19:31gfrlogjust to see if that makes it break
19:31zakwilsonWell, wrapping cat-and-subs with doall didn't change the result.
19:31zakwilsonHowever, using (concat '() [3 5]) *does* break it.
19:31gfrlogthe clojureql doc specifically says "vector"
19:32gfrlogso try wrapping cat-and-subs with (vec)
19:32hiredmanpossibly does something disgusting like calls pr-str
19:32zakwilsonYep, that worked. Thanks.
19:32hiredmandoall doesn't change how lazy-seqs are printed
19:32gfrlogno prob
19:33zakwilsonThis violates my expectation that Clojure collection types can be used in place of each other.
19:34hiredmanerr
19:34amalloyzakwilson: that's not a good expectation to have, really. they compare as equal, but that's about it?
19:34hiredmannot pr-str
19:34gfrlogyeah I'm not sure why clojureql chose to do that
19:34hiredmanpr-str would be more correct
19:34hiredmanthe string problem would be if clojureql calls str or toString
19:35zakwilsonEvidently it is not a reasonable expectation. I will assume there's a good reason I do not understand.
19:35gfrlogzakwilson: at the very least I think it's unusual
19:35gfrlogI didn't expect it either
19:35hiredmansource has calls to str everywhere :/
19:36gfrloghiredman: the function takes either a vector or varargs, so it probably just tests with (vec?)
19:36amalloyzakwilson: well, for example ##(for [coll [[1 2 3] '(1 2 3)]] (conj coll 4))
19:36amalloy&(for [coll [[1 2 3] '(1 2 3)]]] (conj coll 4))
19:36zakwilsonAt least, I would expect a vector, list and lazy seq to be interchangable in places where the lazyness didn't matter.
19:36hiredmangfrlog: could be
19:37amalloywow what am i doing so whrong there
19:37amalloy&(conj [1 2 3] 4)
19:37amalloyRaynes: sexpbot is dead?
19:37gfrloghiredman put everybody on ignoring sexpbot
19:37Raynesamalloy: Is he?
19:37Raynes$kill
19:38amalloy,(for [coll [[1 2 3] '(1 2 3)]] (conj coll 4))
19:38clojurebot([1 2 3 4] (4 1 2 3))
19:38amalloyzakwilson: another example of a difference
19:38RaynesHe would if he could.
19:38zakwilsonEspecially considering that the standard sequence manipulation functions return lazy seqs.
19:38hiredmangfrlog: if only
19:38RaynesApparently, hiredman really really likes me.
19:39raekzakwilson: I think the ClojureQL mini-language assigns special meaning to vectors. in most clojure code vectors and lists work equally well as sequential collection literals
19:39gfrlogI've used clojureql a good bit, and I was surprised by it
19:39amalloyraek: hiccup treats them differently too. a lot of macros do, really
19:39hiredmanclojureql hardly seems worth it
19:39gfrloghiredman: what do you use?
19:39amalloythough i guess the relevant hiccup layer is mostly not macros
19:39hiredmansql
19:40raekI know that in the app macro of Moustache, vectors mean special things (as you wouldn't usually put a vector in the place of a ring handler function)
19:40gfrloghiredman: c.c.sql?
19:40hiredmangfrlog: some of c.c.sql and some direct jdbc calls
19:40zakwilsonHiccup uses vectors is *syntax* though. This is not a place in CQL where it seems like *syntax*; it's a value.
19:40gfrloghiredman: I like the composability of cql
19:41hiredmangfrlog: what composability?
19:41amalloyzakwilson: yeah, that's a reasonable argument. i'd probably feel the same if i were using cql
19:41gfrloghiredman: like I can have a function that joins some tables and limits some things, and in another namespace I can add furthur restrictions, etc.
19:42raekclojureql 'where' looks syntax-y to me, since you can write (and (not (= :super nil)) (= :super cat))
19:42hiredmangfrlog: hmmm
19:42zakwilsoncql feels half-baked right now. I like the idea, but I'm starting to get frustrated with it. I do NOT like writing SQL by string concatination. It's 2011 - WTF are we still doing that?
19:42gfrlogit's been useful for me, but there are other times when spitting out some SQL is much faster and easier
19:42raek...which clearly is not evaluated as Clojure code
19:44tremologfrlog: doesn't that every make query debugging a bit annoying? as in, if the query analyzer tells you that a particular join is slowing things down, how do you locate in your code where the join was "mixed in" from?
19:44tremolo*ever make
19:44hiredmansql is the best language for interacting with an sql database
19:45seancorfieldhiredman: do you have any issues with c.c.sql that you'd like to see fixed?
19:45tremoloyea, I see no reason why you'd need anything besides reqular old SQL
19:45hiredmanI guess after bad experiences with nosql I am bullish on sql
19:46zakwilsontremolo: how do you construct your SQL queries within your code?
19:46hiredmanseancorfield: I think a big one was the inability to get back generated ids which you have already fixed I think
19:46zakwilsonI like relational databases. I like tools that interact with them relationally. I do not like the SQL language. Not one bit.
19:46seancorfieldwhat bad experiences, hiredman ? we're looking to add mongodb at work (in addition to mysql which we're already using)
19:47seancorfieldhiredman: yeah, clojure.java.jdbc returns generated keys from inserts
19:48hiredmanseancorfield: no experience with mongo, just a lot of pain doing anything except lookups by primary key
19:48seancorfieldi'm not finding c.j.j very extensible tho'... i want to expose more places to apply functions, such as allowing manipulation of the PreparedStatement prior to execution etc
19:48zakwilsonIsn't the standard nosql bad experience trying to use something like a key/value store as a general-purpose queryable database when that's not what it's designed for?
19:48amalloyi'm pretty happy with mongo
19:48hiredmanseancorfield: something like that might be nice
19:49seancorfieldi think i need to redesign the API a bit to make that easier... or at least provide a new, cleaner API
19:49amalloyit's the most sql-like of the nosql languages, and (hiredman) you can have indexes that are basically the same as in sql
19:49hiredmanzakwilson: I think that was a large part of it, but you'd expect at least expect something decent for dealing with secondary indices
19:49seancorfieldamalloy:
19:49seancorfieldoops
19:50seancorfieldamalloy: yeah, i got the impression that adding indices was easy and (only) needed for performance
19:50zakwilsonhiredman: I suppose, yes. Was this an application where a relational DB was the obvious Right Thing and somebody wanted to use something trendy instead?
19:50amalloyyes, it's trivial
19:54hiredmanzakwilson: there was something of a push to store things in the nosql db due to concerns of scale and availability
19:54hiredmanwith no analysis of access patterns
19:57aaelonyhi, when outputing to a file everything is going to one line in the resulting file. This is despite (interpose "\n" data) ... The resulting file contains "\n" literals where the new lines should occur... all on one line...!
19:57aaelonyany way to make this an actual new line indicator?
19:58aaelonyI am using prn
19:58zakwilsonAhh. I figure that if my project gets to where it needs that sort of scaling, its data storage layer will have to be redesigned *no matter what*, so I'm using cql/postgres because it seems like it offers the best ways to represent and query the data. I'm starting to get a little iffy on cql though because I keep finding quirks.
20:00seancorfield,(doc prn)
20:00clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
20:01aaelonyi am already using prn
20:01aaelonydespite the docs claim, I get all one line
20:01aaelonywith "\n" literals
20:01seancorfieldaaelony: it outputs a newline at the end - so call it on each line of data
20:01aaelonywhere the new lines should be
20:02aaelonyseancorfield: I could do that. But the "\n" literals are exactly where they need to be, I wish they would just resolve correctly
20:02aaelonysigh...
20:03seancorfieldif you have (interpose "\n" data) then you want newlines between each item in data, yes?
20:03seancorfieldso (doseq [line data] (prn line)) would work?
20:03aaelonyseancorfield: yes
20:04aaelonythis is what I have: delimited-data (map #(interpose delimiter %) (interpose "\n" data))
20:04seancorfieldwhat sort of thing is data?
20:05aaelonydata is a large structure, the result of parsing lots of JSON to delimited columns
20:06amalloyaaelony: is data a seq or what
20:06amalloyis his question
20:06aaelonysec..
20:07seancorfieldi guess it's more "what are you _really_ trying to do?" to see if there's a more elegant solution
20:07aaelonyclojure.lang.LazySeq
20:07amalloyaaelony: you don't really want interpose anyway, because it's going to return a seq like [foo "\n" bar]
20:08amalloyuse clojure.string/join perhaps?
20:08amalloy,(clojure.string/join \newline [1 2])
20:08clojurebotjava.lang.ClassNotFoundException: clojure.string
20:08aaelonyI'm looking for the best way to place actual new line breaks.
20:09aaelonyclojure.string/join \newlie [1 2] looks reasonable, I will try that.
20:09seancorfieldaaelony: if you invoke prn on each "line" of data, you'll get new line breaks where you want them
20:10aaelonyseancorfield: is there a way to edit the following to do that?
20:10aaelonydelimited-data (map #(interpose delimiter %) (interpose "\n" data))
20:11seancorfieldit's more about what you're doing with that
20:11seancorfieldmy suggestion was construct a sequence of the things you want on separate lines and then use prn to print each thing on a separate line
20:12aaelonyyes, that is what I thought I was doing by interposing "\n"
20:12seancorfieldyou're misunderstanding me
20:12aaelonyplease explain
20:12seancorfieldinstead of trying to construct a sequence which mixes delilmiters, data and newlines, just use the plain seq and prn each item in it
20:13aaelonyhow?
20:13clojurebotwith style and grace
20:13seancorfield,(doseq [line ["I" "am" "your" "data"]] (prn (str "|" line "|")))
20:13clojurebot"|I|"
20:13clojurebot"|am|"
20:13clojurebot"|your|"
20:13clojurebot"|data|"
20:13seancorfieldassuming | was your delimiter
20:14aaelonyI will try that, thanks!
20:17aaelonythat doesn't work... Each record should end with a new line. There are many fields that need to be delimited. No worries, I'll keep digging.
20:20gfrlogsometimes clojurebot's interjections seem eerily appropriate...
20:20hiredmansometimes?
20:20amalloy,(use '[clojure.string :only [join]])
20:20clojurebotnil
20:21seancorfieldaaelony: if you can structure your data as sequence of records where each record is a sequence of fields, you can manipulate it more easily when printing it
20:21amalloy,(let [data '[[a b c] [1 2 3]]] (print (join \newline (map #(str "|" % "|") data))))
20:21clojurebot|[a b c]|
20:21clojurebot|[1 2 3]|
20:21amalloyoops, guess not
20:22seancorfieldtrying to insert strings and convert the whole thing to a string just to call prn once seems like a lot of work
20:22amalloy,(let [data '[[a b c] [1 2 3]]] (print (join \newline (for [record data] (map #(str "|" % "|") record)))))
20:22clojurebotclojure.lang.LazySeq@73d7b35
20:22clojurebotclojure.lang.LazySeq@726ef65
20:22aaelonyamalloy: I think that should do it
20:22amalloyrarrrgh
20:23amalloy,(let [data '[[a b c] [1 2 3]]] (pr-str (join \newline (for [record data] (map #(str "|" % "|") record)))))
20:23clojurebot"\"clojure.lang.LazySeq@73d7b35\\nclojure.lang.LazySeq@726ef65\""
20:23amalloyi quit
20:23amalloysomething like that
20:23aaelonyi get it... i think that will work. I need to make a few changes..
20:24aaelonywill think it through. thanks for the input!!
20:24aaelonycheers
20:37gfrlogit is hard to glance at a conversation between "amalloy" and "aaelony" and subconciously assign authorship accurately
20:37hiredmangfrlog: they are different colors
20:37gfrlogyeah? your client assigns random colors?
20:37amalloygfrlog: hashes of the name
20:37amalloyso that it's "random" but consistent
20:37gfrlogright
20:38gfrloga random oracle
20:38technomancyhiredman has IRC synesthesia
20:38hiredmansomething like that, with overrides if desired
20:38amalloyeven my crappy client does that
20:38amalloyi like technomancy's answer better though
20:38hiredmantechnomancy: you smell correct
20:38gfrlogthen apparently you all underestimate the crappiness of my client
20:38amalloygfrlog: adium?
20:38gfrlogcenterim
20:38gfrlogit's this terminal thing I found somewhere on the internet
20:39hiredmanoh god
20:39hiredmanhorrible
20:39gfrlogI hate it because it doesn't even distinguish between statements and "has left" events
20:39technomancy yeah, I've had join/parts hidden for years now. so much nicer
20:39gfrlogbut that's how bad I wanted to run it on a headless server
20:39amalloygfrlog: erc
20:39technomancyif someone's left, I'll notice because I can't tab-complete them anymore
20:39amalloyor wait, you're this vim guy
20:39gfrlog:)
20:39gfrlogI switched from qwerty to dvorak; I wonder how that compares to switching to emacs
20:40hiredmanirssi in screen
20:40hiredmanor tmux
20:40gfrloghiredman: yeah, I used irssi for a while actually
20:40amalloytmux in screen? madness
20:40gfrlogbut centerim lets me integrate jabber
20:40hiredmanI have irssi in screen and sqs for growls, it is great
20:40gfrlogamalloy: I've used screen in tmux a few times
20:40hiredmanthere is, infact, a jabber client for irssi
20:40gfrloghiredman: irssi does the coloring?
20:40technomancyperl user!
20:40technomancy~guards
20:40clojurebotSEIZE HIM!
20:41hiredmanhttp://cybione.org/~irssi-xmpp/
20:41hiredmangfrlog: some plugin
20:41gfrlogwhy does everybody know so many clojurebot triggers?
20:41hiredmannickcolor.pl
20:41amalloytechnomancy: wait, who's the perl user?
20:41technomancyamalloy: irissi is extended using perl IIRC
20:41gfrloghiredman: this looks to be an excellent tip
20:42gfrlogman the other day I saw sexpbot react to something clojurebot said
20:42amalloyclojurebot: source?
20:42clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
20:42amalloygfrlog: feel free to dig through there for a command list?
20:43gfrlog:) I knew it was available somewhere, but that still doesn't explain why everybody knows it so well
20:43technomancyI really do not understand how people who write IRC clients can consider releasing them with nick highlighting turned off by default.
20:43technomancyit's like ... like not having readline available... oh wait
20:44amalloygfrlog: word of mouth, and also many of these are "standard" bot features. the bot in #emacs responds to ,guards
20:44gfrlogah ha
20:44amalloyand just listen around, note cool commands, and then remember them :P
20:44technomancyamalloy: well... that was a straight-up thievery
20:44technomancyI don't know if I'd call it standard
20:44hiredmantechnomancy: not true
20:44amalloytechnomancy: standard...for lisp bots?
20:44technomancyhiredman: thievery by yours truly
20:44hiredmanI'd never been in #emacs
20:45hiredmanI chose "," because it is whitespace in clojure
20:45gfrlogI always like that
20:45technomancyhiredman: I was refering to ,guards
20:45hiredmanoh
20:45hiredmanright
20:45hiredmanwell, yes, technomancy knows a lot of factoids because he adds them
20:45technomancywhich I really cannot overstate my amusement over
20:45technomancy~gentlemen
20:46gfrlog~ladies
20:46technomancyhmm; time for some more thievery
20:46technomancy~gentlemen is <reply>You can't fight in here. This is the war room.
20:46hiredmanclojurebot: it's a thing is <reply> #who, it really is!
20:46hiredmanhuh
20:46gfrlogI was about to start guessing which files to click on when I remembered I could clone the repo and grep for "seize him"
20:47hiredmangfrlog: you cannot, actually, that is learned behavior
20:47hiredmanthe hell
20:47gfrlogwell I can do it, but it doesn't help me at all :)
20:48gfrlogwas amalloy sending me on a goose chase?
20:48hiredman~ping
20:48clojurebotPONG!
20:48technomancy~gentlemen
20:48clojurebotgentlemen is you can't fight here, this is the war room.
20:48hiredmanclojurebot: it's a thing is <reply> #who, it really is!
20:48clojurebotRoger.
20:48hiredman~it's a thing
20:48clojurebothiredman, it really is!
20:48technomancyclojurebot: forget gentlemen |is| you can't fight here, this is the war room.
20:48clojurebotI forgot that gentlemen is you can't fight here, this is the war room.
20:49technomancy~gentlemen is <reply> You can't fight in here. This is the war room.
20:49clojurebotRoger.
20:49technomancyyou need a space after <reply>L
20:49technomancy?
20:49hiredmanpossibly
20:49amalloygfrlog: i probably was sending you on a goose chase, yes
20:49hiredmanI guess I could look at the parser or something
20:49gfrlogthis is the craziest thing I have seen today.
20:50gfrlog~goose
20:50clojurebotNo entiendo
20:50gfrlogclojurebot: goose is Not have goose
20:50clojurebotAlles klar
20:51gfrlog~goose
20:51clojurebotgoose is Not have goose
20:51hiredmannot my jdbc layer 4 driver built on top of the rest api of the agile planning website thing we use at work?
20:51gfrlogjust got me confuseder
20:52hiredmannot the delievery of irssi rawlog via sqs? or the interpreter written in shell? the irc bot is the crazy thing?
20:53technomancyI'll tell you what's crazy; when I first joined this channel there was no bot.
20:53technomancycould hardly believe it.
20:53gfrlogDid I unknowingly witness all those things?
20:53hiredmanthey are on the guthub
20:54gfrlogI wasn't reacting to the code, I was reacting to you guyses interaction with the bot
20:54hiredmanthere is a really good sequence
20:54hiredmanlemme see
20:54hiredmanclojurebot: foo bleh blarg
20:54clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
20:54hiredmanclojurebot: what did you say to me?
20:55clojurebotHuh?
20:55hiredmanclojurebot: you heard me
20:55clojurebothiredman: I'm just giving you a second chance
20:55hiredmanclojurebot: don't make me come over there
20:55clojurebotHuh?
20:55technomancygfrlog: you want crazy on tap, you should hang out with rudybot: https://github.com/offby1/rudybot/blob/master/quotes
20:56gfrlogtechnomancy: Golly Willickers
20:57technomancytee hee "you know you're an opensource geek when someone cuts you off on the freeway and you're like \"PATCHES WELCOME!!!!\""
20:58hiredmanthat is pretty good
21:12gfrlog_why do I have such trouble figuring out how to use IRSSI?
21:42dbgsteris there any examples of simple problems and solutions in clojure?
21:42dbgsterthings like: given a list of n items, find the largest 2 items in the list and return it
21:43amalloydbgster: you might like 4clojure.com, perhaps? not actually what you asked for, but useful for the same target audience
21:44amalloy(that said, finding the two biggest is not such a simple problem!)
21:44dbgsteramalloy: are you familiar with koan? i think there was a clojure type version of that
21:44amalloyyes, clojure koans exist
21:44dbgsterin ruby I did it in 7 lines
21:44amalloy$google clojure functional koans
21:45dbgsterk
21:45ataggartalso this: http://rosettacode.org/wiki/Category:Clojure
21:45amalloyataggart: good point
21:47dbgstercan someone clear up wht liens does for me?
21:48dbgsterit is a project generator and build tool?
21:48dbgsteri.e it generates the structure for a project
21:48dbgsterand builds and runs it for you?
21:48dbgsterit has NOTHING to do with repl correct?
21:49bdeshamyou can do "lein repl" which will run a repl for you
21:52bdeshamif I'm distributing a library, should I use "defn-" for anything I don't expect the end user to call? what if I want to run tests against the would-be hidden functions?
21:52amalloydbgster: https://gist.github.com/1028531 for this particular problem
21:53dbgsterbdesham: and it will do what compared to the normal repl? load my proj?
21:53amalloythough i guess my solution isn't very robust
21:54dbgsteramalloy: http://www.pastie.org/2075362 surprised, thought it would be a 2 liner in clojure for some reason :)
21:55amalloydbgster: run your ruby version on the list [-1 -2 -3] :P
21:56amalloywow actually your version is wrong in a lot of ways
21:56amalloytry it also on [10 4] - i think it returns [10 0]
21:57dbgsterok it works for positve numbers?
21:57dbgsterone sec
21:58dbgsterhmm..ok
21:59amalloyso yes, you can get a very short version provided you're not worried about getting the right answer :)
22:02amalloyand as i said, even my version isn't perfect; it takes the first two numbers of the list and starts them as largest/second. if i used 0 0 i'd be okay for non-negative numbers, but the *right* way is to sort the first two numbers, since the algorithm assumes they're sorted
22:03bdeshamdbgster: yes, as long as you have :gen-class in your project.clj file
22:03bdeshamalthough I've never quite undersood gen-class, so don't press me for details ;-)
22:04amalloydbgster: updated https://gist.github.com/1028531 with a version that i think works for any seq of integers, if you're interested
22:04amalloybut now, i'm off!
22:40offby1technomancy: I resemble that remark ("crazy on tap")
23:03seancorfield__is there a cleaner way of converting java's system properties into a clojure map than (into {} (map (juxt #(.getKey %) #(.getValue %)) (System/getProperties))) ?
23:03seancorfield__,(into {} (map (juxt #(.getKey %) #(.getValue %)) (System/getProperties)))
23:03clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
23:03seancorfield__heh, figured...
23:04scgilardi(into {} (System/getProperties)) looks like it works
23:04seancorfield__hmm, i thought i'd tried that earlier and got an exception... let me try it again...
23:04tomojkey and val also work on seq of properties
23:05tomojer, java.util.Hashtable$Entry
23:05seancorfield__thanx scgilardi - not sure why i thought that didn't work
23:05scgilardiyou're welcome
23:06seancorfield__tomoj: good to know, tx
23:07tomojdoes Properties not have a Map constructor because people are supposed to just expect Map?
23:10seancorfield__Properties extends HashTable and implements Map but i missed that subtlety :)
23:15seancorfield__what threw me was when i first tried map over properties and got elements that printed as java class references... so i didn't try key/val (which would have worked and saved me some confusion)
23:27seancorfield__(battery died unexpectedly)
23:36bdeshamnew project, I'd appreciate any comments: clj-schulze, an implementation of the Schulze voting method - https://github.com/bdesham/clj-schulze