#clojure logs

2010-10-29

00:22notsonerdysunnyis there a way to get sources of all the methods that implement a multimethod?
00:23notsonerdysunnyI am looking along the lines of the repl macro "source"
00:25somniumnotsonerdysunny: you can use (.getMethodTable <multimethod>) to get a mapping of dispatch values to function objects
00:26notsonerdysunnythanks somnium
00:27notsonerdysunnywhich is the print command that creates a new line when it encounters one instead of just printing it is just "\n" ...
00:27notsonerdysunny*it as just "\n"
00:29notsonerdysunnyprintln does that .. just thought of sharing .. unfortunately that was the last one I tried .. among pr, prn, pr-str and others
00:32pmooserDoes anyone know if there's a straightforward way to integrate an existing jar I have which can't be fetched via maven with a leiningen build ?
00:34amalloypmooser: put it in ~/.m2 somewhere, i think
00:34pmooserThat's sufficient? I wasn't sure if that got periodically cleared out or something. Thank you!
00:34somniumpmooser: You can also create a project to hold the jar, and then `lein install' it.
00:35amalloypmooser: ~/.m2 never gets cleared as far as i know. but i don't know how strict maven is about directory structure: if you have to put it somewhere specific with all the right decorations or something
00:36technomancypmooser: just add it as a dependency and run lein deps; the resulting failure message will show you how to install it in ~/.m2
00:37pmooserOK. Thanks technomancy.
00:37pmooserI did that earlier but obviously didn't pay enough attention to the error.
00:37technomancyit's kind of verbose
00:43notsonerdysunnysomnium: I get the map yes .. but how can I acess their sources via something like a source command?
00:44replacanotsonerdysunny: print... prints human-friendly stuff and pr... prints clojure-readable stuff (more or less)
00:45replacaso the pr funcs will quote all strings and escape special chars
00:47itistodaywhat are some of the recommended ways of getting the latest clojure-contrib stuff?
00:47itistodayis that still one big jar or has that changed?
00:49amalloy&(pr #"1\|2")
00:49sexpbot⟹ #"1\|2"nil
01:03notsonerdysunnythanks replaca
01:11replacanotsonerdysunny: np!
01:14notsonerdysunnywhat is the lein dependency for clojure 1.3 alpha 2
01:19replacanotsonerdysunny: I think it's [org.clojure/clojure "1.3.0-alpha2"], but I haven't tried it so I'm not positive
04:00raekgood morning
04:01angermanhow would I use multimethods with keyword arguments?
04:01angermanor variadic with kw arguments.
04:03raekangerman: do you want to dispatch on some of the kw arguments, or do you simply want the kw args to get through to the method?
04:03angermanAssume f: a b -> y and f: a -> y. I would write a handler for f: a that calls f: a b
04:04angermanraek: basically I want to push the kw arg though to f: a b &{:keys ...}
04:04angermanbut I want to be able to specify them on f: a as well
04:05angermanor dispatch on the class of a &{:keys ...}
04:05angermane.g. (defmulti f class &{:keys ... }) but I hardly think that's valid
04:05raekwell, first of all the dispatch fn must be variadic (it can ignore the extra arguments, bust must accept being called with them)
04:06angermanyes
04:06raeksay you want to dispatch on the type of the first args: (fn [x & _] (class x))
04:06angermanso the default would be &rest with (apply (comp fn ... ) rest?
04:07raekthe default?
04:07raekas long as your fispatch fn is variadic, the method implementation can be variadic too
04:08angermanwell yes. How would one "usually" handle the passing of additional arguments to a function
04:09raekone way is (defn foo ([x] (foo x 0)) ([x y] ...))
04:09raekthat one is useful when having fixed arities
04:10raekfor any number of arguments (defn foo [x & opts] ...) is common
04:10raek& {:keys [x], :or {x 0}} being a special case
04:10sexpbotjava.lang.Exception: Unable to resolve symbol: x in this context
04:10angermanyes. but say I have a dispatch on class plus 1 fixed arity (different class) and a a set of kw-args
04:11angermannow the first dispatch method just converts the first argument to a different class and calls itself (resulting in a different dispatch)
04:11raekok. so you would call it like (foo a b :x 1, :y 2) ?
04:11angermanyes
04:12raekif they share the same dispatch value, you have to implement them in the same defmethod
04:12angermanlets say (foo a:T1 :x 1 :y 2)
04:12angermanand (foo a:T2 :x 1 :y 2)
04:13angermannow (defmethod foo T1 [a & rest] (apply (comp foo (t1-to-t2 a)) rest)) ?
04:14raekthat should work, I think
04:14angermanand (defmoethod foo T2 [a & {:keys [x y] :or {x 0 y 0}}] (list a x y))
04:15raeklooks good
04:17raekyou'd do it in the same way as if you would have two separate ordinary functions (defn foo-T1 ...) (defn foo-T2 ...)
04:17angermanso (apply (comp ... is the standard way of passing it down
04:18raekah, didn't see the comp
04:18raek(apply fii (t1-to-t2 a) rest) should be sufficient
04:18raek*foo
04:18raek(apply f x args) is the same as (apply f (cons x args))
04:19raekso except for the comp part, yes. that would be the standard way
04:19angermanhmm... & _ doesn't work with {:keys?!}
04:20raekin what way?
04:20angermanwell I'm trying to hunt this down.
04:21angerman(defmulti foo (fn [x & _] (class x)))
04:21angermantells me somthing about 3 args being passed to class.
04:21angermanHmm let's try (comp class first)
04:22raekthe dispatch fn will get all the arguments passed to the multimethods as separate arguments
04:23angermanhmm. maybe reevaluating multimethods using the repl is just not such a great plan
04:23raekoh, yeah. forgot to mention a thing...
04:23angermanbtw: are there any tools to make the REPL a little bit more "friendly"?
04:24raekdefmethod has defonce semantics
04:24raekso you have to remove the var if you want to replace it
04:24raek(ns-unmap 'your-ns 'foo)
04:24raeksimply reavaluating it does not replace it
04:26raekthis is to avoid the situation that used to happen when you reloaded the ns with the defmulti (all method implementations were cleared)
04:26raekangerman: I myself use Emacs with slime. that makes the repl very freindly IMHO.
04:27angermanyes that's what I do as well. but the tracebacks are often not helpful
04:27raekif you compile the ns file with C-c C-k you will get line numbers for your definitions
04:28raekthat makes it much easier to debug
04:29raekalso, pressing v in the exception buffer on a stack trace line with line number info will hilight the code at that location
04:30angermananother thing that iritates me is that pressing 0 on the backtrace buffer takes some time to close it
04:31raekhrm, in my Emacs, it happens instantaneously
04:32angermanhere it takes 1 to 2 seconds or so
04:32angermanmaybe it's caused by AutoComplete mode or so
04:33angermanbtw: is there an issue with using the latest SLIME with the SWANK-clojure form April?
04:33angermanit just tells me each time I connect to the swank server that the versions missmatch
04:34notsonerdysunnyangerman: I face similar problems with emacs ...
04:35notsonerdysunnyand backtrace
04:36angermanstrange stuff
04:52TobiasRaedermorning everybody
05:01angermanHmmm (javax.swing.JComponent.)
05:01angermancauses an instantiation error, does anyone have an idea what that means?
05:03Tordmorangerman: means JComponent is an abstract class and not meant to be instantiated
05:03angerman...
05:10LauJensenGood morning all
05:11sthubnergood morning, LauJensen
05:11sthubnerLauJensen: had a safe trip back?
05:11LauJensensthubner: I was just about to ask you the same, but yes thanks, the trip home went great, touched down @ 2300
05:11angermanwow. gui programming just got easier.
05:12sthuebnerLauJensen: I met some friends after arival in Berlin. Got home around 01:30
05:12angerman(display (scrollable (vstack (map #(hstack (map jcomp (analyze-char %))) (range 1 217))))) -- quite readable, no?
05:13LauJensenangerman: try again with ->> and it might make more sense
05:13LauJensensthuebner: okay, sounds tough
05:15sthuebnerI had lots of time on the train to add some explanatory comments to yesterday's lab's code. And progressed quite a bit with The Joy of Clojure
05:16LauJensenGreat
05:16hoeckangerman: totally, I love gui programming in clojure :)
05:16hoeckangerman: faster than drawing on paper :)
05:17angermaneither i draw too fast or write too slow then
05:48bobo_this php and java stuff at work is no fun at all after 3 days of clojure :-(
05:49sthuebnerbobo_: I can feel, what you're saying ;-)
05:51bobo_would almost be worth it to do half price for consulting on clojure for a while
05:52sthuebnerat least it would be more fun, I'd guess
07:26dprohi
07:26dproany overtone users in here ?
07:27AWizzArddpro: don't forget there is also a german Clojure channel :)
07:28dproAWizzArd: hmmm more german speaking overtone users you reckon ? ;)
07:28cemerickdpro: this is the music library?
07:28dprocemerick: yes clojure -> supercollider bridge
07:29AWizzArdhttp://github.com/samaaron/overtone
07:29dproit's fun so far, but I'm quite new to clojure and I haven't figured out how to set a running synth
07:29dpro's parameter
07:29cemerickdpro: no idea what supercollider is :-) Is this similar to e.g. Archaeopteryx?
07:30dprocemerick: no idea what Archaeopteryx is
07:30dprocemerick: http://supercollider.sf.net
07:33cemerickinteresting
07:34cemerickArchaeopteryx is e.g. http://gilesbowkett.blogspot.com/2008/02/archaeopteryx-ruby-midi-generator.html
07:35cemerickThere was a great screencast showing the author dynamically modifying the music being generated on the fly that is far more impressive than what's there, but I can't find it at the moment.
07:35cemerickCertainly seems like a field ripe for Clojure domination. ;-)
07:42dprohmmm ... is there a way to see all the things defined in a certain namespace ?
07:44AWizzArdYou could try ns-map.
07:48dprofound it in the sources ...
07:50angermandoes anyone have experience with ANN?
07:51dprohmmm some noob question:
07:52dprobar ;; is a synth node -> 6 , (ctl 6 :f 100) ;; (re)sets the frequency , (ctl bar :f 200) ;; error ???
07:55AWizzArdangerman: there is Encog
07:55AWizzArdhttp://www.heatonresearch.com/encog
07:55AWizzArdIst ziemlich umfangreich.
07:56angermanHmm mal schauen. Ich muss es danach zwar eh in ObjC neu schreiben aber für den Prototyp wird's reichen.
07:57AWizzArdWell, when you have to rewrite it, then this lib won't help much.
07:58angermanfor experimentation they will
07:58AWizzArdIt is available for Java and .NET and should work with Clojure for both plattforms.
07:58AWizzArdVery sophisticated stuff in there.
07:58AWizzArdIt also implements the Boltzmann machine.
07:59AWizzArdWhat kind of patters would you like to recognize? Breaking google captchas? ;)
07:59angermannah.
07:59angermantake the money from your pocket and try to recognize the serial number :D
08:00angermanI'm basically done till the point where I need to figure out what the shape in my 20x60 box is.
08:00angermanso pretty simple and stupid OCR for ~20 different characters
08:00angermanon my way there I implemented a somewhat half-assed image processing lib in clojure
08:01angermanworkbench? core?
08:01AWizzArdWe had very nice text recognition results in the past with our CL implementation of the Boltzmann machine.
08:03angermanAWizzArd: any upfront suggestions you could offer? I'm basically completely new to this.
08:03angermanI do have a degree in math though. But machine learning and stochastic calculus have not been my main research area
08:04AWizzArdThen you can be simply a user of the lib and not try to program the lib itself :)
08:04angermanSo I went ahead and looked at some research paper to see what they did... ANN (often Backprop) seemd to be a common choice.
08:05angermanAWizzArd: well I do need to have it in ObjC in the end. But I'd like to explore what works best first, thus a lib seems like a good starting point.
08:05AWizzArdWell, you can't implement non-trivial NNs within 2 days. But with Encog you should be able to get started within a few days.
08:05angermanAWizzArd: that's right. A stupid one-hidden-layer perceptron NN took a day to implement in ObjC. (Though that's not the language I am most fluent with)
08:06angermanafter that I figured I need to prototype it first ... :)
08:07AWizzArdThe workbench will help you to visualize the nets.
08:07angermanso I take there's not clojure wrapping lib for it yet, no?
08:09AWizzArdnot that I know of
08:10angermaninteresting the workbench.sh fails ..
08:16TobiasRaederWhats workbench?
08:16angermanthere's a encog workbench
08:16TobiasRaederah, okay
08:17angermanand for some reason the workbench.sh file that's supplied fails to call java with the classpath correctly
08:17angermanI've no ide why though.
08:18angermanAWizzArd: what dataformat would you use for the images as input into ?
08:26angermanthis is some of my preprocessed data to be fed into the NN (right side) http://skitch.com/angerman/d75gj/untitled
09:11chouserwould anyone be interested in a with-var-root macro that would be used a like 'binding', but would replace the var root bindings instead of pushing new thread-local bindings.
09:11chouser?
09:11clojurebot#<ClassCastException java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;>
09:11chouseryou know, for tests?
09:12@rhickeychouser: yes, is there not already a ticket for that? It's what tests/mocks will need given non-dynamic default
09:12hiredmanwe(sonian) have one
09:12chouserhiredman: will you be putting it in clojure or contrib?
09:15hiredmanI suppose I'd have to ask tim, but I don't see why it couldn't
09:18chouserI have one too, developed on my own time for the book and/or clojure itself
09:19@rhickeychouser: stick it as a patch to core.clj on a ticket
09:19@rhickeyplease
09:19chouserrhickey: ok, looking for an existing ticket now
09:19@rhickeywith-var-roots?
09:20@rhickeywe have with-local vars, maybe with-root-vars?
09:20chouserI used singular, thinking 'binding' was too
09:20chouserbut now I realize that might be a plural verb
09:21@rhickeybinding doesn't say binding what, as with-blah does
09:21chouserright
09:22chousermine's built on alter-var-root with constantly :-/
09:22chouserif we're touching core, would it make more sense to add a set-var-root fn?
09:23@rhickeyset-var-root is a recipe for a total mess
09:24@rhickeyI'd rather have you call .bindRoot
09:24@rhickeymaybe that's a better name - binding-roots
09:24@rhickeyroot-binding
09:24drewrinc
09:26chouserI had 'binding' in the name earlier, but in clojure codebases (if not in functional programming in general) "binding" tends to make people think of thread-local
09:26hiredmanwell thats changing too
09:26chouseryes, but still implies something different that replacing the root value
09:27@rhickeyhiredman: no, binding is the same, but there was always a root binding, just no function with the word binding in it that manipulated it
09:27tonylmorning
09:27chouserI guess having "root" in the name may be sufficient
09:27hiredmanrhickey: I mean the part about binding being thread local
09:27@rhickeyhiredman: I guess more broadly thread local
09:27@rhickeythread-of-control
09:27@rhickeythread of work
09:27@rhickeyhrm
09:28hiredmanthread of process :)
09:28@rhickeywith- is good because it generally implies the dynamic scope
09:28@rhickeywith-bindings would have been a better name for binding maybe
09:29@rhickeyif there ever is a bifurcation of types we might not want 'var' in the name
09:30chouser"root" is key
09:30chouserwith-roots :-)
09:30@rhickeychouser: maybe, but if you never have dynamic bindings, you only have a root, and root of what?
09:31@rhickeythe user experience is - they created with def, this gives temporary defs
09:31chouserhm, this might not have to be a macro
09:31@rhickeyroot distinguishes from dynamic
09:32chouserbleh, good point -- I'm not thinking the new way yet
09:32@rhickeywith-redefs?
09:32chouseryou're unlikely to use this for :dynamic vars, so maybe root is completely wrong
09:32@rhickeychouser: dunno about that
09:33@rhickeynever part
09:33@rhickeyunlikely == eventually
09:33@rhickeybut it is the bit set by def, in any case
09:33@rhickeywith-temp-defs
09:34drewrwith-def ("with" already meaning transience, "def" meaning it's a root-level thing)
09:35@rhickeydrewr: but a) plural, and b)will this establish non-pre-existing defs?
09:35@rhickeyi.e. intern vars?
09:36drewrshould it? I'm guessing not, but I don't know if you plan on changing that
09:36hiredmanand de-intern when it leaves scope? I hope not
09:36@rhickeybecause it won't clean them up if it does
09:36@rhickeyso, either temp defs or redefs
09:37@rhickeyredef implies must already exist
09:37drewry, then I vote for redef
09:37drewrwith-temp-defs has the same problem as with-defs
09:37@rhickeydrewr: yes
09:38@rhickeyredef also implies the global scope of what you're going
09:38chouserhttp://dev.clojure.org/jira/browse/CLJ-665
09:40@rhickeywith-alt-defs
09:42drewrhm, not bad
09:42@rhickeywith-swapped-defs
09:50chouserlooks like it would work fine as a fn. same semantics, just have to quote the vars and provide a fn instead of a body
09:50@rhickeywith-redefs, with-swapped-defs, with-alternate-defs, other - vote!
09:52tonylrhickey: between those three, I would say with-alt-defs.
09:52@rhickeychouser: yes, should be a two-part API. I imagine most callers will be other macros?
09:52tonylbut i don't see anybody having problems with binding, everybody is already using it by that meaning. maybe with-bindings
09:53@rhickeytonyl: binding is not on the table ATM
09:53chouserwith-redefs. with-temp-redefs is more explicit, but temp is already pretty well implied by with-
09:53tonylalright
09:53chouserrhickey: hm, not sure. I was thinking most callers would be either individual tests or bits of code used for groups of tests ("fixtures", or "contexts")
09:54chouserfor testing, anyway, knowledge of the vars to stub and what their behavior should be seem to be pretty local to the test itself
09:54@rhickeychouser: you're expecting use of #'a-var ?
09:57chousernot by users, normally, but a function that does most of the work splits out nicely from the macro
09:58@rhickeyso two names needed then
09:59chouserwith-reders-fn :-)
09:59chouserer
09:59@rhickeywith-redefs with-redefs-fn
09:59chouseryeah
09:59@rhickeygo for it!
09:59@rhickeyand thanks!
10:00chousernp!
10:00chouserugh, docstrings. :-P
10:05cemerickrhickey: will Big* numerics eventually be usable with interop forms requiring non-Big numerics (presumably tossing an overflow exception as necessary)?
10:06@rhickeycemerick: are they not now?
10:07cemerickrhickey: I've only started fiddling with 1.3.0, but not AFAICT.
10:07cemerick(Integer. 1N) => IllegalArgumentException
10:07cemerick(that being a silly but convenient interop target)
10:08@rhickeycemerick: that's an overloading thing
10:10@rhickeyin general, 42N should satisfy an int-taking method
10:10cemerickrhickey: Er, okay. My thinking is that, with contagious Bigs, it would become fairly irritating to perhaps have to wrap args with (int …) and friends.
10:10cemerickah
10:11cemerickrhickey: then how is (Integer. 1N) failing an overloading issue?
10:11@rhickeythis case is reflective, and the reflection matching would have to be augmented to do that match
10:11cemerickThe only other option is a String
10:11cemerickOh, I see.
10:11@rhickeycemerick: because 1N is neither an int nor a String
10:11cemerickSo nonreflective calls work as I'd expect, reflective calls need further enhancement to get up to par.
10:12cemerickI probably should have thought of that on my own.
10:12@rhickeyyou need to patch c.l.Reflector.paramArgTypeMatch
10:15cemerickrhickey: should I bother opening a ticket, or is this something that's on your path already?
10:15@rhickeynot on my path, so yes, ticket please
10:16djpowellon the subject of vars, pprint seems to do some mutable stuff with refs mixed with io (unless I'm misunderstanding it). that looks wrong. would a quick fix be to change the refs to use with-local-vars?
10:18@rhickeydjpowell: you should probably talk it through with Tom to see what he was thinking about
10:23chouserreplaca <- Tom
10:24chouserheh, nice! clojure won't build because I left off the :added metadata
10:27abedrarhickey: there's an old ticket (CLJ-199) that I looked over and commented on the other day regarding dex conversion that is no longer an issue from what I can tell, should we close it?
10:28_rata_hi
10:28@rhickeyabedra: could you ask the original poster if they agree?
10:28abedrai'll email Remco
10:30ymasoryhi all. i'm a little confused by vars at the moment. i seem to able to reassign them one line after another. i thought using STM was required for reassignment?
10:31mrBlissShould I use alter-var-root when I want to rebind private functions used in pmaps and futures for testing?
10:32chousermrBliss: yes, or the with-redefs macro for which a patch will exist in a few minutes
10:33chouserymasory: STM is primarily about refs not vars. Using 'def' to blow away old var values is supported primarily for changing your code on the fly -- not meant to be used by your code during normal running.
10:34mrBlisschouser: thanks, I'm looking forward to the patch :-)
10:34ymasorychouser: so clojure *does* have reassignable variables. "programming clojure" brags about that not being the case
10:35chouserymasory: clojure has access to all the mutable, reassignable everything in Java. And if you use it that way, it's not going to give you very many of the benefits of using Clojure properly.
10:36ymasorybut def is a purely clojure construct. i could reassign with def without ever touching java
10:40chouserYou're frustrated that the book seems to have misled you? What part of the book are you referring to?
10:43@rhickeyymasory: you are presuming re-def == assignment. It may seem the same, but it's not, and the implementation may vary them. set! is assignment and is restricted to non-global bindings
10:51chouser1.2 had direct binding of some core vars, didn't it?
10:52ymasorychouser, rhickey: thank you
10:52angermanif anyone has some past experience with ocr, how bad would you judge my "worst" samples: http://skitch.com/angerman/d757m/untitled ?
10:54cemerickangerman: this is your input?
10:54angermanyes
10:54angermanwell it's the result of quite a bit of preprocessing
10:54chouserI just ran tesseract on some cleanly scanned Courier (mono-space, non-overlapping letters) pages. Each page had a slight rotation. The output was essentially unusable.
10:55cemerickangerman: The washout of e.g. the 5 in the third row will cause problems, I suspect. Same for the 2nd-to-last U.
10:56cemerickchouser: deskewing is essentially assumed by all OCR systems AFAIK
10:56cemerickthough tesseract is *old*
10:56chousercemerick: is there a better option that is free and runs on linux? :-P
10:56cemerickheh
10:56cemerickno
10:56chouserhm, actually, maybe free isn't a requirement.
10:57cemerickBut, deskewing should lead to good results, esp. if the input is clean.
10:57chouserI've got 250+ pages, just for this one PDF. I'm not going to manually deskew them all
10:57angermanI'm not going to tesseract. This is a very limited set of caracters. 0-9 + [EFGHJKLMNPRSTUVWXYZ] and the last number in each row is basically a checksum.
10:57cemerickSurely not, no. Easily automatable though.
10:58cemerickangerman: are these serials off of bills?
10:58angermanyep
10:58cemerickshould be good to go then
10:58angermanI need to figure out how to encode them to feed them into a ANN...
10:59@rhickeychouser: direct was neutered right before 1.2 release as static was on the horizon, and there were still no knobs for direct
10:59angermancemerick: and well some of the source images were really (!) bad
10:59cemerickangerman: That seems overkill given the domain?
11:00angermancemerick: I'm always open for a better idea. I've no experience with Image Processing nor OCR at all.
11:01cemerickangerman: if you can get reliable registration, then determining exclusive sampling points should be straightforward.
11:02angermancemerick: well so far it looks like I don't really get the positions fixed... they seem a little bumpy (e.g. x/y shift)
11:02@rhickeycemerick: was it your intent to strip an arbitrary number of colons in keyword-from-strings?
11:03@rhickeycemerick: goes beyond the scope of (-> :foo str keyword)
11:03@rhickeycemerick: in http://dev.clojure.org/jira/browse/CLJ-463
11:05cais2002hi, guys, is there a way to iterate thru a transient set/map ? first/rest do not seem to work
11:08cemerickrhickey: Yes; was aiming to be liberal in accepted inputs.
11:08chouserrhickey: ah, thanks (re: direct)
11:10cemerickrhickey: to Stu's comment, (keyword "::foo") *is* nonsensical, but tossing an exception doesn't seem warranted.
11:15cemerickangerman: just from the sample you posted, the registration isn't bad. In any case, I'd try sampling – if you can get away with it, that's a *lot* easier than an ANN. Even a simple bayesian net based on those samples (features) would be far easier.
11:16abedrarhickey: re: #199 Remco said to go ahead and close the issue
11:30chousermrBliss: patch is at http://dev.clojure.org/jira/browse/CLJ-665
11:30angermancemerick: so basically figuring out sets of points that belong only to one class for each class and classifying against those, right?
11:30cemerickangerman: Roughly, yes.
11:31angermancemerick: the method is called registration? are there any further keywords that might guide me to relevant material?
11:33cemerickangerman: image registration is the term; totally reasonable overview here, it looks like: http://en.wikipedia.org/wiki/Image_registration
11:33angermancemerick: thanks will read up on that
11:34cemerickangerman: your inputs already looks reasonably well-aligned, so you might be well served by just taking features every 5 pixels on each axis or something, and using that for a bayesian net.
11:34cemerickThe outcome should be as effective as ANNs, but a lot easier to implement and train.
11:34cemerick(at least for this dataset)
11:34mrBlisschouser: perfect, I would most certainly use it
11:35cemerickAnyone who actually knows what they're talking about, feel free to interject. ;-)
11:35angermancemerick: ok, so a 5x5 grid of "on/off" pixels . I really need to read up more on this matter
11:36cemerickangerman: that'd be my first shot.
11:37angermanif that would work that would be great as it would reduce the cost of adaptive thresholding quite a bit :D
11:40dashhmm. anybody feel like helping me understand ensureEditable in PersistentHashMap? I get the idea that sometimes you can directly modify the node arrays but it's not clear to me when that is
11:41KirinDavedash: Transients?
11:41dashright that's what i thought
11:41KirinDaveThat's my guess
11:41KirinDaveI don't know for certain
11:41chouseryes
11:41dashbut this is in PersistentHashMap, not TransientHashMap
11:41KirinDaveI suspect persistent says "No." :)
11:42KirinDaveerr ant
11:42dashhttp://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java#L376
11:43dashOh, hmm
11:43dashi think i see what you mean
11:44KirinDaveI can't get over how weird the clojure source is.
11:44KirinDaveNot that it's bad code
11:44KirinDaveIt's just conceptually a layer cake
11:44dashokay right! the node types implement this stuff because they're used for both persistent and transient hash maps. Right.
11:44KirinDaveIt's like taking a complex frosting and using it to make a simpler cake.
11:45dashexcellent. i can quit confusing myself now :)
11:45dash(FWIW, I am reimplementing PersistentHashMap (partly in C) so that it can be used from Python.)
11:46KirinDaveSounds fun except for the last word. :)
11:46chouseryikes
11:46dashKirinDave: if programming is fun, you're doing it wrong.
11:46dash;)
11:46dashAnyway
11:46chouserdash: you're doing transients too?
11:47dashchouser: not at the moment; i figure if you want that you'll use a regular python dict and then just build an immutable version from it afterward
11:47dashclojure is a box of wonderful ideas, and i think more people should be able to benefit from them, even if they have to write code in other languages. :)
11:49chousersure!
11:50chouserthough it can be a bit clumsy to use immutable collections in imperative languages.
11:50tonylthat is a great idea dash, and it seems fun to try and do it.
11:50chouserI forget, does python have reduce?
11:51arkhyes it does - core library
11:52dashtonyl: if it sounds so fun, you want to finish it for me? ;D
11:52jwr7I don't get it — this morning I was able to log into JIRA and update a ticket, now I can't even log in…
11:52arkhI think python is a great imperative language - clojure is just better : )
11:53tonylI'll try, need to learn python first :P
11:53@rhickeyabedra: cool, go for it - thanks!
11:56jwr7rhickey: so, once I've attached a patch to an issue, should I just leave it as resolved and expect that someone will pick it up?
11:57rata_how can I make an anonymous record?
11:58rata_do I have to use reify?
12:01duncanmdum de dum
12:01BahmanHi all!
12:04duncanmright now, i'm doing some CPU and IO work with a (map (fn [chunk] (future (doseq [c chunk] (work c)))))
12:04duncanmthis is great for the CPU work, but not so great for IO
12:06duncanmso it'd be cool if i can do the CPU work in parallel, and then submit it on a IO queue for writing, and also limit the CPU work so that i don't fill up my memory before the IO can get to writing out the results
12:06chousersounds like a BlockingQueue
12:06@rhickeyjwr7: no, it's not resolved until it is tested and applied.
12:07duncanmchouser: and use promises to send the IO work along?
12:12jwr7rhickey: Ok. I didn't know that and I marked it as resolved. I think a description of the expected workflow would help us contributors do the right thing.
12:12ohpauleezduncanm: Also see this: http://groups.google.com/group/clojure/browse_thread/thread/9b70a51eed8ef1f2
12:12ohpauleezI may have led you astray last night
12:13duncanmohpauleez: thanks
12:13lrenn-> (meta (read-string "(ns ^{:foo \"bar\"} bar)"))
12:14sexpbot⟹ nil
12:14lrennanyone know how I can get that to work? :)
12:14ohpauleezduncanm: the futures weren't starting because of maps laziness, so you need to realize the lazy sequence
12:15ohpauleezyou can do that (obv) with doseq
12:15ohpauleezor any other way, that will realize the seq
12:15VinzentHello. I need to add metadata to my function. Is there a way to do it?
12:18tonylVinzent: (defn ^{:meta "this is my meta} myfn [& args] args)
12:18tonylforgot quote
12:18tonylVinzent: (defn ^{:meta "this is my meta"} myfn [& args] args)
12:21tonylwrong placement too :P (defn myfn {:meta "this is my meta"} [& args] args) this is right
12:22Vinzenttonyl, thanks, but I need metadata on function itself.
12:22VinzentFor example, I have a seq of small lambdas and I pass it to function that divide it into 2 seqs depending on the metadata of lambdas.
12:24tonylif they are lambdas (anonymous fns) then just use the reader macro ^
12:24tonyllike this (meta ^{:meta "my meta"} (fn [& args] args))
12:24tonyl->(meta ^{:meta "my meta"} (fn [& args] args))
12:24sexpbot⟹ nil
12:25tonylmm, that worked in my repl
12:25tonyl->^{:meta "my meta"} (fn [& args] args)
12:25sexpbot⟹ #<box12631$eval12860$fn__12861 net.licenser.sandbox.box12631$eval12860$fn__12861@df2ee2>
12:25tonyl,(meta ^{:meta "my meta"} (fn [& args] args))
12:25clojurebot{:meta "my meta"}
12:26lrenn-> (meta (with-meta (fn []) {:foo "bar"}))
12:26sexpbot⟹ {:foo "bar"}
12:27VinzentYes, I've tried it and got UnsupportedOperationException
12:27tonylyou got the exception with the with-meta form?
12:28VinzentAh! I have clojure 1.1, think that's the problem
12:28rata_how can I make an anonymous record? do I have to use reify?
12:28tonylthat's still weird, but it might be that.
12:30VinzentYes, with 1.2 all works fine. Thank you.
13:09rata_why (binding ...) requires there to be a root binding (def ...)?
13:10chouserrata_: it doesn't. It only requires that the var exist.
13:11rata_chouser, and how can I make a var to exist without (def ...)?
13:12chouserdef is the best way. what are you trying to do?
13:14rata_my fault... I've just realized what I'm doing with binding can be done with let
13:14chouserexcellent!
13:26duncanmohpauleez: what Meikel said is *exactly* what happened to me last night, that's what i figured out also
13:27ohpauleezright, I wasn't even thinking about it
13:27ohpauleezand as soon as I saw it on my newsfeed, I realized what was happening
13:28ohpauleeztotally apologize about that, I was working on a personal project while helping you instead of totally focusing with the issue
13:28duncanmohpauleez: no no, you were very helpful, no worries
13:28ohpauleezcool
13:29rata_how can I make an anonymous record? do I have to use reify? if that's the case, which protocol/interface should I extend?
13:29duncanmohpauleez: i'm now reading this, http://map-str.appspot.com/2010/01/Channels-in-Clojure - i think my current setup isn't ideal, because the IO work is all contended
13:29duncanmrata_: why not just use a structmap?
13:29duncanmor hmm, just a map
13:29rata_because records have way faster access
13:29ohpauleezduncanm: also have a look at aleph
13:30ohpauleezit's a bunch of technology built on NIO, that uses channels
13:30kyleburtonI havne't seen this yet, but is there a way to define a type or a record and then use it as if its a function?
13:30ohpauleezbut you can achieve a lot of what you most likely need with queues and promises
13:30chaslemleyI asked this a few days ago, sent 2 emails and no response: How do I remove jars/groups from clojars.org?
13:30kyleburtonI'm looking for the same behavior that clojure maps implement
13:31ohpauleezkyleburton: if you make it inherit from IFn, most likely
13:31kyleburtonoh, they act as maps, so that behavior may already be defined: to do what maps do
13:31ohpauleezHaven't tried it yet, let me hit the repl and see what I can do
13:31duncanmohpauleez: implements, not extend (inherit) ;-)
13:31ohpauleezyes yes ;)
13:31kyleburtonok, if I create something derived from IFn I can override the 'call' method
13:31kyleburtonohpauleez: thank you
13:32ohpauleeznp
13:32kyleburtonthat's at least a lead
13:32chouserdefrecord currently creates a class that does not implement IFn, but you certainly could add that.
13:32chouserduncanm: sorry, I was gone when you asked about how to use a BlockingQueue
13:32kyleburtonnow that I'm thinking of it, it'd require getting the fields to use 'get'
13:32duncanmchouser: it's okay, i saw a post about it too - but if you have any tips, i'd love to know them
13:33duncanmright now, i'm running my in-efficient thing, trying to render 1100+ images
13:33duncanmi wish i'd gone to Clojure-Conj
13:33duncanmi was *this* close
13:33duncanmoh, well, definitely something for next year
13:33clojurebotHuh?
13:33chouserduncanm: nothing too tricky -- have one thread blocking on pulling from the queue to write out objects, have one (or more) other threads doing computation blocking on pushing into the queue
13:34ohpauleez$(supers (class []))
13:34ohpauleez,(supers (class []))
13:34clojurebot#{clojure.lang.Seqable clojure.lang.ILookup clojure.lang.Associative clojure.lang.Sequential clojure.lang.Indexed clojure.lang.APersistentVector java.lang.Comparable java.lang.Iterable java.util.Rand...
13:35ohpauleezkyleburton: probably is ILookup
13:35kyleburtonohpauleez: thanks, I liked the idea at first, but b/c it interferes with the normal field lookup, I'm thinking of not doing it atm...
13:35ohpauleezcool
13:35chouserkyleburton: (defrecord Foo [a b] clojure.lang.IFn (invoke [t k] (get t k)))
13:36kyleburtonoh, nice, thanks chhouser
13:36kyleburtonthat actually looks pretty simple - and will 'get' still work on the record?
13:36chouser(:x a-record) works by default. The above buys you (a-record :x). The former is probably still more efficient
13:36kyleburtonfantastic, I will try that for what I'm doing
13:37chouserI bet rhickey's going to frown at me for that. sigh.
13:37kyleburtonoh for the record /call override?
13:37ohpauleezchouser: That's at least 10 lashings
13:37kyleburtonhah, ok
13:38chouserkyleburton: just that you don't own IFn or defrecord. extending one to the other is something he chose not to do, so it probably shouldn't be done for some important reason I'm not thinking of.
13:38kyleburtonchouser: yeah, which is one reason why I'm backing off
13:38kyleburtonclojure is moving and evolving quickly, I don't want this code I'm writing for my employer to be stuck on older revs
13:39chouserdefrecord keys are always keywords, right? so (a-keyword a-record) will work, why not just use that
13:39chouser?
13:40angermanhow do I create a liste [x in (range 10) y in (range 10)] ? (for [x (range 10) y (range 10)] [x y]) seems somewhat weird
13:40kyleburtonoh I have more complex structure in my values, was going to override the 'call' behavior to be able to lok into them
13:40chouserrata_: you have a good reason not give your record type a name?
13:40kyleburtonthanks all
13:40chouserangerman: looks good to me
13:41angermanchouser: (reduce + (map #(n % %2 i j) (for [x (range 2) y (range 2)] [x y])) ?
13:41chouserkyleburton: yeah, probably best to define your own function to do that, rather than adding IFn to the record
13:41rata_chouser, I want to create different records each time I call a function
13:41angermanthat "for" list comprehention is quite a bit different from python
13:41angermanyes I should probably move the map into the for.
13:42chouserrata_: a record type is a class, so that would create new bytecode and load it each time you call a function?
13:44chouserangerman: heh, yeah -- python's list comprehension is often best read right-to-left, like regular clojure code.
13:44chouserwhile clojure's 'for' is often best read left-to-right, like regular python.
13:47angermanwhoa I love macros
13:47angerman(defmacro sum [intervals expr] `(reduce + (for ~intervals ~expr)))
13:47angermane.g. (sum [i (range 10) j (range 10) k (range 10)] (* i j k))
13:48chouserfun
13:48angermanI think you can hardly get closer to math notation than that, while retaining flexibility
13:50angermanthat's going to be a good example for macros for my talk about clojure at the faculty next week
13:52angermanis there a way to strip the clojure.core prefix from macroexpand?
13:52chouserpprint has some nice tools for printing code
13:53angermanI know it makes sense to have it there but for readability ...
13:55ohpauleezangerman: you shouldn't need to qualify macroexpand (or anything in core)
13:56angermanno, I mean the output of expandmacro-1
13:56chousertry: (require '[clojure.pprint :as p]) (binding [p/*print-suppress-namespaces* true] (p/pprint (macroexpand-1 ...)))
13:56angermanI see
13:56chouserthere's probably a better way, but I can never remember
14:00rata_chouser: yes, that's what I want, because I access the record much often that call the function is call much fewer times
14:00rata_ chouser: yes, that's what I want, because I access the record much often that call the function
14:02rata_also I don't know at compile time the fields of the record
14:04angermanchouser: the the binding expression i just (def *foo*) ... do I need a default value?
14:04chouserrata_: if you're really sure that's what you want, you can use eval
14:04rata_can't do it with reify?
14:05chouserreify doesn't generate new classes at runtime
14:05apgwozis it considered idiomatic to use a dynamic binding to pass state around?
14:06RaynesI've done it before, so probably not.
14:06apgwozi.e. in lieu of passing as an argument to every function called within
14:06apgwozRaynes: ha
14:06chouser"If you present an interface that implicitly passes a parameter via dynamic binding (e.g. *db* in sql), also provide an identical interface but with the parameter passed explicitly." http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards
14:06Raynesapgwoz: I've discussed this with a lot of people, and the general consensus is that it's less functional to do so, and you should prefer to explicit pass parameters.
14:07apgwozRaynes: yes, i agree that it's not functional, and thus i dislike the idea of it, but since i see it, i wonder if it's encouraged.
14:07Raynesclj-github used to do that, but it got icky when I had to actually implement something using it, so I did the switcharoo.
14:07duncanmchouser: do i use promises in this BlockingQueue scenario?
14:08apgwozchouser: in this case, it'd be private to the namespace, and the exported function would do the binding
14:09apgwozbut, i think i'll pass it around. it's cleaner
14:09chouserduncanm: nope
14:12itistodayso how does one go about getting clojure-contrib stuff today?
14:13ohpauleezitistoday: are you using lein?
14:13ohpauleezor you want to pull all the stuff by hand
14:13itistodayohpauleez: sure, that seeems to be the way to go...
14:13itistoday(lein)
14:14ohpauleezitistoday: Take a look at http://gist.github.com/654050
14:14ohpauleezthat's from a project.clj file I'm working in right now. You can replace the version numbers with what ever you're targeting
14:15itistodayohpauleez: thanks! that seems to be exactly what i want
14:15ohpauleezAwesome! glad i could help
14:15itistodaybtw, how do i say "i want the latest version"?
14:15RaynesCheck out cake as well.
14:15Raynes$whatis cake
14:15sexpbotcake = http://github.com/ninjudd/cake
14:15ohpauleezitistoday: You use SNAPSHOT
14:16ohpauleezbut if you're using 1.3, it's best to use the alpha snapshots
14:16itistodayohpauleez: but you've got this commented out: [org.clojure/clojure "1.3.0-master-SNAPSHOT"]
14:17ohpauleezright, because I'm using alpha2
14:17itistodayohpauleez: ah, so if i wanted the latest and greatest, i'd uncomment it out and comment the other one?
14:17ohpauleezitistoday: You could, but alpha2 is more or less the latest and greatest
14:18ohpauleezthe release cycle for 1.3 is chunked up into alpha drops, which package up rounded off functionality
14:18itistodayohpauleez: i see, so as to avoid bugs i might be better off doing what you're doing?
14:18ohpauleezRight
14:19itistodayk cool :-)
14:19duncanmchouser, ohpauleez: something like this? http://gist.github.com/654059
14:19ohpauleezand it also helps development, because bug reports are relevant to a drop, not a daily build
14:19itistodayohpauleez: gotcha
14:20chouserduncanm: looks about right.
14:21ohpauleezyeah, things look pretty good to me, I'm not too wild about the use of pmap here (I'd bench pmap and map, since future is a non-blocking call), but otherwise this looks good
14:21ohpauleezduncanm: ^^
14:21chouserduncanm: here's what I just wrote: http://gist.github.com/654062
14:21duncanmchouser: and the length of the BlockingQueue determines how many tasks i 'cache'
14:22chouseryeah, I'm not sure about pmap+future. Perhaps just pmap?
14:22ohpauleezor just future
14:22ohpauleez:)
14:23ohpauleezin this case, I would just use pmap
14:24ohpauleezand perhaps isolate the render call to it's own future (make it return a future)
14:26fliebelWould anyone in here mind explaining the representation that is used for floats? I do know some bits about it, but not the full picture yet. So floats are expressed as an integer and an exponent. How is that a approximation? Say we have 0.2 that is just 2e-1 right?
14:27amalloyWhat about 1/3?
14:28fliebelamalloy: You'd run out of space representing and endless series of threes.
14:29amalloyRight. So it's an approximation
14:29chouserhttp://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Tech/Chapter02/floatingPt.html
14:29fliebelamalloy: But how about the (+ 0.2 0.1) that's currently on HN. They seem perfectly representable to me.
14:29replacafliebel: I'd look on wikipedia (http://en.wikipedia.org/wiki/Ieee_floating_point) for details
14:30amalloyThe base and exp are both in base 2
14:30jcromartieis Java IEEE floating point?
14:30amalloyYes
14:30jcromartie(+ 0.1 0.2) blows my mind... I don't know how I haven't seen this before
14:30jcromartieI mean I know floating point is not exact
14:30replacafliebel: but remember that floats are represented as binary fractions, not decimal and sometime the conversion isn't as even as you'd think
14:30chouserfrom that link, "Java follows the IEEE 754 standard in most cases"
14:30itistodayRaynes: thanks (sorry, I had a phone call, couldn't reply earlier), question: why is it that in the Getting Started section here (http://github.com/ninjudd/cake) clojure is obtained by just referencing it as 'clojure', whereas in the link ohpauleez gave me it's referred to as 'org.clojure/clojure'? (http://gist.github.com/654050)
14:31Raynesitistoday: That's actually a little confusing to me as well. I'm not sure why.
14:31Raynesninjudd or lancepantz: ^
14:32jarpiainjava has only one of the IEEE rounding modes and only one NaN value
14:32ohpauleezjcromartie: That happens on most IEEE floating points, like Python too
14:32itistodayanyone happen to know why? :-) (ref: 'clojure' vs 'org.clojure/clojure')?
14:33angermanyikes... implementing some very array intensive code in a functional way is not that easy
14:33fliebelamalloy, replaca: I can't get my mind around binary exponents. Is there any way I can get a clear view on this with the REPL?
14:33chouserangerman: you've looked at amap, areduce?
14:33Raynesitistoday: I suspect that it's nothing cake specific. It must be that clojure is also under clojure in one of the repositories.
14:33ohpauleezgah, you beat me to it chouser
14:34RaynesEither way, it's the same Clojure in any case.
14:34angermanchouser: I'm working down my way on a flow chart from May 1968
14:34angermanchouser: index arrays and fun...
14:34lrennitistoday: cake has special handling for clojure and clojure-contrib. It adds the correct group name.
14:34itistodayRaynes: i'd just like to know for sure, as there seem to be (at least) two ways to do it, which way is the "right" way, or are they both OK?
14:34lrennitistoday: either will work.
14:35itistodaylrenn: so it's a cake thing?
14:35itistodayi don't use cake
14:35itistoday(use lein, as it's clojure based...)
14:35Raynescake is pretty Clojure-based.
14:35itistodayoh shit
14:35itistodayjust noticed that too
14:35itistodayfor some reason i thought it was Ruby
14:36replacawell, binary exponents are just m*2^e where m is the mantissa and e is the exponent part, both represented as binary
14:36RaynesA huge majority of it is written in Clojure, while bin/cake is just a bootstrap script and serves essentially the same purpose as shell scripts in Leiningen.
14:36replacafliebel: but .1 is a nasty binary fraction
14:36fliebelreplaca: I was just playing with bit-shift-left ;)
14:36chouserangerman: recur is goto
14:36lrennitistoday: http://github.com/ninjudd/cake/blob/master/src/cake/project.clj
14:37Raynesmostly just a bootstrap script. It also communicates with the persistent JVMs, but I digress.
14:37hiredmanchouser: crippled
14:37angermanchouser: do I have multiple jumpmarks?
14:37lrennitistoday: look at the group function...it puts the correct group in for clojure and clojure-contri.
14:37chouserhiredman: yes, angerman: no
14:37replacafliebel: you can be more abstract about that
14:37hiredmanhttp://en.wikipedia.org/wiki/COMEFROM is what you want
14:38lrennitistoday: and as Raynes said...cake is clojure. It just uses ruby instead of shell scripts (makes cross platform easier).
14:38replacahow many halfs, how many quaters, how many eigths, how many 16ths, how many 32nds,...
14:38replaca0, 0, 0, 1, ...
14:40fliebelreplaca: Okay, I'm beginning to see. Exponents are just very coarse grained in binary. So what numbers *can* be represented?
14:40angermanWhat's this coding goint to tell me? if (NODE_m = NODE_j_k) then NODE_m = NODE_j_k
14:40itistodaylrenn (and Raynes): thanks, gotcha, i don't know why i thought the whole thing was Ruby
14:40replaca0, 0, 0, 1, 1, 0, 0, 1,...
14:40lrennitistoday: sure. I assume lein does the same thing for clojure and clojure-contrib.
14:41replacafliebel: it's not that they're coarse grained, per se, it's just a different base
14:41chouser(defn binary [x] (apply str (reverse (map #(if (odd? %) \1 \0) (take-while pos? (iterate #(bit-shift-right % 1) x))))))
14:41chouser(binary (Float/floatToIntBits 0.1))
14:41chouser"111101110011001100110011001101"
14:41replacafliebel: so some fractions that seem easy in decimal are hard (or long) in binary
14:42fliebelreplaca: But any binary fraction can be represented in base 10, right?
14:42itistodaylrenn: i see, so "clojure" is resolved by cake to "org.clojure/clojure"?
14:42replacachouser: looks like the "0011" repeats ad infinitum
14:42Raynesitistoday: I've just been told that leiningen actually does the same thing.
14:42jarpiainfliebel: yes because 2 is a factor of 10
14:42lrennitistoday: correct. just got confirmation that lein does the same.
14:42itistodaylrenn Raynes: awesome, thanks! :-)
14:43chouserI suppose because 1/10 does do any better in binary than 3/10 does in decimal
14:43chouser?
14:43replacafliebel: I believe jarpiain, though I haven't thought hard about this stuff in about 20 years
14:43rata_chouser, but with eval I must give it a name too
14:43chouser,(float 0.3)
14:43clojurebot0.3
14:44chouserrata_: but you can just generate a name
14:44rata_ok, I can do a macro also
14:44fliebelbut wait, if we can't represent 0.1, how comes 0.1 still evals to 0.1?
14:44chouserrata_: not if you don't know your field names until runtime
14:45rata_the fields vector must be a literal or can it be an identifier?
14:45fliebelreplaca: ^^
14:46jarpiainfliebel: (str (float x)) returns the shortest decimal that uniquely identifies the float
14:46andyfingerhutfliebel: I'm not certain, but I believe there is sometimes rounding done in various functions that print floating point values. How this rounding is done precisely depends upon which function is used to display it.
14:47andyfingerhutBecause most people don't want to see 0.0999999999999989
14:47rata_,(let [fields [a b]] (defrecord A fields))
14:47clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
14:48rata_mmmm... it must be a literal
14:48fliebelandyfingerhut: But that'd make clear we're dealing with an approximation.
14:48andyfingerhutAnd there are printing functions for floats that will give that to you, but you have to know how to make it show you that.
14:48fliebel,(+ 0.01 0.02) ; these guys do have representations
14:48clojurebot0.03
14:49andyfingerhutThat and any CS department in the world that graduates someone with a bachelor's degree that doesn't know that floating point numbers are approximations ought to have its curriculum developers put up against a wall and shot. (Yes, I exaggerate)
14:50fliebelandyfingerhut: So how do I get the actual number that is 0.1?
14:51chouserfliebel: 1/10
14:51jarpiain,(BigDecimal. 0.1)
14:51clojurebot0.1000000000000000055511151231257827021181583404541015625M
14:51andyfingerhutYou mean, how do you print the full binary representation (or decimal) of the floating point number that is created when you write 0.1?
14:51chouser,(= 3/10 (+ 2/10 1/10))
14:51clojurebottrue
14:51chouser,(= 0.3 (+ 0.2 0.1))
14:51clojurebotfalse
14:52chouserwe have a section in the book on this. ;-)
14:52clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
14:52chouserno, not that book.
14:52andyfingerhutclojurebot needs another book in its library :)
14:52fliebelchouser: I know fractions are awesome, and I have Joy of Clojure, but I'd rather read it on paper.
14:53chouserfliebel: it's coming, it's coming...
14:54fliebelchouser: Awesome! Tomorrow? Oh, I'm not at home tomorrow. After the weekend maybe? Can't wait...
14:54chouserheh
14:54chousermaybe before next year :-P
14:55fliebelOh, it'd be good to have for christmas, or the Dutch thing no-one knows we celebrate instead.
14:55chouserI know. The initial MEAP just missed Christmas last year. I'm afraid the print version is going to miss Christmas this year. :-/
14:56fliebelWhat day is christmas again? It's after 5 dec, right? So you're going to miss our celebration anyway.
14:58alpheusToo bad the tracer fn in clojure.contrib.trace gets a string describing the function's args instead of getting the actual args.
14:58amalloyRaynes: flight delayed an hour, wish I had a laptop to poke at sexpbot
14:58ohpauleezalpheus: you could wrap a macro around those pieces, if you wanted to
14:58Raynesamalloy: I'm poking at it as we speak. Going through your embedded stuff.
14:59alpheusohpauleez: I'm looking at Robert Hooke as an alternative
14:59ohpauleezah
15:00amalloy&(= #"" #"")
15:00sexpbot⟹ false
15:00Raynesamalloy: Not sure how I feel about prefixing the results of embedded code with the code itself. I'll have to monitor it in practice for a while. Seems like it could get nasty for sufficiently sized code and result sets.
15:01kumarshantanu,(every? #(contains? [1 2 3] %) [1 2])
15:01clojurebottrue
15:01amalloyOkay. As you can see it's easy to rip out
15:01kumarshantanu,(every? #(contains? [1 2 3] %) [1 2 3])
15:01clojurebotfalse
15:01RaynesOf course, it'll alway truncate. You'll see less results in this case though. However, sexpbot gists truncating results, which eases that pain a bit.
15:02Rayness/truncating/truncated/
15:02sexpbot<Raynes> Of course, it'll alway truncate. You'll see less results in this case though. However, sexpbot gists truncated results, which eases that pain a bit.
15:02fliebelOkay, now that I thought I understood…
15:02fliebel,(= (+ 0.1 0.2) (+ (BigDecimal. 0.1) (BigDecimal. 0.2)))
15:02clojurebottrue
15:02edbondcan't get [org.clojure.contrib/io "1.3.0-alpha2"], what I do wrong?
15:02amalloyYou could truncate the code before the result
15:03fliebel,(+ (BigDecimal. 0.1) (BigDecimal. 0.2))
15:03clojurebot0.3000000000000000166533453693773481063544750213623046875M
15:03amalloyEg only show the first ten chars of the code
15:03fliebel,(+ 0.1 0.2)
15:03clojurebot0.30000000000000004
15:03Raynesamalloy: I was actually thinking about that.
15:03RaynesI think I'm going to do that.
15:03RaynesAnyways, your changes are excellent.
15:04amalloyI agree. It's a good idea and easy, I just didn't think of it yesterday
15:05rata_it's strange that deftype has an anonymous counterpart, namely reify, but defrecord doesn't
15:07amalloyAnonymous deftype? That's the same as a map
15:07fliebelamalloy: I thought struct was.
15:07chouserreify doesn't generate public fields like deftype does
15:07amalloyEr, defrecord
15:08amalloyThe only reason to have a defrecord is so the compiler can access its fields without reflection
15:09amalloyIf it were anonymous what would you gain?
15:09chouserregardless, reify generates a no more dynamic class than deftype or defrecord does. They all need to know their field list at compile time.
15:09fliebelI won't participate in these discussions until after I have my paper copy of Joy in Clojure(I keep forgetting what goes between joy an clojure)
15:09amalloyOf
15:10chouserof course you can have compile time whenever you want using eval, with all that implies.
15:10rata_amalloy, you gain faster access
15:11rata_chouser, what does eval imply?
15:11fliebelSo… with defrecord and deftype, is there still any reason to use defstruct?
15:12amalloyNo you don't. If it's anonymous the compiler can't generate the fast access code
15:12chouserfliebel: not really
15:12chouseramalloy: are you sure?
15:13rata_mmmm... that's a good point... I thought the compiler could generate the fast code anyway
15:13amalloyChouser: not totally sure, no. within the same fn, maybe it can
15:14amalloyBut in that case why not just use a let to begin with?
15:14chouserrata_: wait, what does your lookup code look like? if you use 'get' or the map as a fn, you won't get call-site caching anyway, I think.
15:15rata_I use keyword lookup
15:15chousera literal keyword?
15:16amalloyChouser: can't use records as fns, as I recall?
15:16chouseramalloy: er, right.
15:17rata_mmmm... I'm wrong... I use the map as a fn
15:18rata_I could use keyword lookup tough, but it wouldn't be a literal
15:18chouserso, no call-site caching. it's just a matter of the code path in the map
15:18rata_it'd be something like (keyword a-number)
15:19chousersmall maps are usually array maps, which means a tight loop checking equality of the key
15:19Raynesamalloy: I'm going to truncate code at 50.
15:19rata_so I wouldn't gain the fast access of records?
15:20amalloyRaynes: seems like a lot. I would have guessed like 25
15:20Raynesamalloy: In practice, it's not as much as you'd think.
15:21amalloyI was imagining using it not to display all the code, but just a reminder where to look in the user's message
15:21chouserthere are levels of fast. The fastest path using (:literal-keyword record) is based on resolving that particular keyword for that record type and caching the result at the call site
15:22amalloyBut I bet your judgment here is more accurate than mine
15:22Raynesamalloy: /j #(code) for a second
15:25rata_ok, and then non-literal keyword lookup on records is the second-fastest?
15:29amalloyFor non literals I think maps are as fast as records
15:30vibrant<- still reading joy of clojure
15:31chouserIf we say (:lit-keyword record) is ~1 unit of time, (non-lit-keyword record) appears to be ~8, (non-lit-keyword array-map) ~10
15:32chouserso if you've got a non-literal keyword, it hardly seems worth the pain of generating record types on the fly
15:32chouserso if you're using a non-literal keyword for lookup, it hardly seems worth the pain of generating record types on the fly
15:34chouserer, wait. the array-map falls off badly depending on how far along in the array-map you have to look to find your key
15:34chousersigh
15:35rata_in a mini-benchmark in my netbook there seem to be no difference between literal and non-literal keyword lookup, but it's maybe because I'm at the repl
15:36chouser(defn t [] (let [foo (Foo. 1 2), k :a] (time (dotimes [_ 1e8] (k foo))))) ; vs. (:a foo)
15:39rata_I did that and the non-literal keyword lookup is even a little faster than the literal keyword lookup
15:39chouserhuh
15:39chouserwell, there you go. don't optimize prematurely.
15:39rata_yes, it's weird
15:46rata_chouser: you mean the compiler optimizes the literal keyword lookup prematurely and that's what makes it runs a little bit slower?
15:47chouserno, I mean assuming one particular mechansim (defrecord vs. regular map) is enough faster to warrant a lot of extra engineering work on your part before you actually measure their relative speed is premature optimization.
15:50rata_oh ok :) but after looking at this mini-benchmark, I'd like to optimize it... anyway, I'm first finishing it, then optimize :)
15:51bhenrydoes map the verb guarantee order? or does it just happen that i always see it in the same order?
15:56chouserbhenry: it guarantees order
15:57fliebelchouser: What about pmap?
15:57chouserfliebel: pmap also
16:02lancepantzyou guys! gotta see this http://twitter.com/#!/lancepantz/status/29118584268
16:02fliebelchouser: And what about pvmap? (that's the name of the forkjoin thing, right?)
16:04chouserthe concept of "map" as a verb implies keeping order, at least in the Clojure world.
16:08fliebelchouser: My interpretation if bhenry's question is if map is doing things out of order behind the scenes and then gives it back to you in order. If I understood pvmap correctly, it is completely without order, but returns the ordered result.
16:09chouserfliebel: ah, I hadn't considered that interpretation of his question
16:12chouseronly map (not pmap or pvmap) will consistently run the given function in order. That's based on how lazy seqs are designed, and I don't see it changing any time soon.
16:13rata_integers can't have metadata :(
16:13chouserindeed
16:13clojurebotIt's greek to me.
16:15fliebelwe should teach clojurebot greek.
16:19SirNickCan anyone give me any insight on why I get a NullPointerException in session.clj from every route in this? It's probably obvious, but I just don't see the problem: http://paste.pocoo.org/show/80j0yV2kSmvMMFwqUZoC/
16:22SirNickIt seems to only occur when I use Ring's session wrapper, but I must be missing something...
16:29SirNickAnyone have any experience using Ring sessions?
16:31jcromartieSirNick: let me take a look
16:31SirNickjcromartie: Very much appreciated
16:31SirNickjcromartie: The exception is on line 47 of http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session.clj
16:33jcromartieresponse is nil there
16:33jcromartie,(let [n nil] (n :session-cookie-attrs))
16:33clojurebotjava.lang.NullPointerException
16:33jcromartieas an example
16:33jcromartieso back to your code
16:33SirNickjcromartie: Yea I figured. Do you have any guess why? I don't think I'm altering the response anywhere
16:35jcromartiebecause your handler is a string
16:35jcromartie("foo" {})
16:35jcromartie,("foo" {})
16:35clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
16:35SirNickWhich line?
16:35jcromartiehm
16:35jcromartiesorry no
16:35jcromartieI'm dumb
16:36jcromartieyou are passing your routes to wrap-session
16:36SirNickam I not supposed to?
16:37jcromartieno that's fine
16:39jcromartiesorry :( I don't think I have any insight to offer
16:40SirNickjcromartie: Alright well thank you for trying anyway
16:40jcromartieI mean it looks like (in wrap-session) the response ends up being nil
16:41SirNickYea I've been trying to figure out what's wrong off and on for a while. I just don't see what's causing the problem
16:42mfexSirNick: you are probably having the same problem as mentioned here http://groups.google.com/group/compojure/browse_thread/thread/8447ebdd57544669 because you only wrap session around the dynamic routes which may return nil as a matcher
16:43SirNickmfex: Thank you, I'll take a look
16:47jcromartieso SirNick, looks like you need to pass at the end of your dynamic routes
16:47jcromartieright?
16:47SirNickjcromartie: Sorry, what do you mean pass?
16:48jcromartieor am I thinking of Sinatra
16:53jcromartiereading compojure is great
16:53jcromartieI love compile-route
16:53jcromartieshows how simple compilation can be in Lisp
16:58SirNickjcromartie: mfex: It was indeed the fact that there was no catch-all dynamic routes. Rearranging things seems to work: http://paste.pocoo.org/show/EA1dhcWvE6QLAdp7tley/ Thank you both for your help
16:58jcromartie this reminds me I need to check out the new ring/compojure
16:58jcromartieI'm behind
17:00jcromartiering/compojure/clout... I was amazed to see compojure made up of 3 small files
17:04lrennjcromartie: it wasn't always. ring and compojure were doing the same things, so they joined forces.
17:25ohpauleezdnolen: ping
17:26dnolenohpauleez: pong
17:26ohpauleezdnolen: Were you ever involved with DreamIt?
17:27ohpauleezOr do you know Laris Kreslin
17:27dnolenohpauleez: yeah I did a very small amount of consulting with the Kidzillions team
17:27dnolenohpauleez: and I do know Laris :) he's old pals w/ one of my good friends.
17:27ohpauleezdnolen: Cool, I'm Paul the CEO of OurShelf.
17:28dnolenohpauleez: haha, sweet, I remember.
17:28ohpauleezI saw a picture of you from conj, totally rad you're involved with Clojure
17:28dnolenohpauleez: the same! The Conj was funtimes.
17:29Zeroflag_http://pastebin.com/65gJtHa4 <- can anyone tell me why is it so slow?
17:29Zeroflag_it took about 8 minutes to calculate the result
17:30Zeroflag_same thing in python did it in 1.5min
17:30gfrlogthat doesn't sound like too much of a difference
17:30gfrlogdo you have the python code too?
17:31Zeroflag_yeah
17:31Zeroflag_http://pastebin.com/U5GXWFAB
17:32Chousuke#(zero? %) is equivalent to zero?
17:32Zeroflag_yes probably
17:33Chousukelaziness probably adds some overhead compared to the python version
17:33jcromartiethat's not a question :)
17:33Chousukebut it's just horribly slow code being even slower :)
17:34jcromartiebut I'd imagine a straight translation of the python code might run faster
17:34gfrlogit's the same algorithm
17:34jcromartieclose enough
17:35gfrlogZeroflag_:with a slight bit of extra effort you can get a more efficient algorithm for what you're doing
17:35Zeroflag_how?
17:35clojurebotwith style and grace
17:35Zeroflag_i thought this lazy stuff is idiomatic thats why i used it
17:35gfrlogyou can still do lazy
17:36gfrlogbut you don't have to check all the divisors up to sqrt(n)
17:36gfrlogyou only have to check the primes
17:36ChousukeIt is, but the laziness overhead adds up if you do very cheap operations lazily.
17:36Zeroflag_ok but i don't want to change the algorithm just do some optimalization
17:37gfrlogokay
17:37gfrlogdeja vu
17:38gfrlogdid you change the zero? anonymous function like Chousuke suggested?
17:38Chousukethat probably won't affect it too much
17:38Zeroflag_yes but its still running :)
17:39ChousukeYou could try removing the map and see how much it changes things. ie. (not-any? #(zero? (rem n %)) (range 2 (inc q)))
17:39Chousukebut I think it might just be slow boxed arithmetic that's the culprit
17:40gfrlogtime for 1.3!
17:40Chousukepython's probably faster with that.
17:40Zeroflag_ok, and does it make any difference if i run it from the repl or try to compile it?
17:40Chousukenah
17:40jcromartieZeroflag_: well you can't just time the execution of java
17:41jcromartietry defn'ing a prob10 and then (time (prob10))
17:41dnolen_Zeroflag_:running it at the REPL does compile it
17:41Zeroflag_ok
17:41dnolen_Zeroflag_: have you tried comparing your solution to this one, http://clj-me.cgrand.net/2008/06/07/primes/ ?
17:41Zeroflag_not yet
17:42gfrlogif you do, replace (lazy-cons a b) with (cons a (lazy-seq b))
17:43gfrlogI don't think lazy-cons exists anymore
17:43gfrlogfun challenge -- create an infinite seq of primes without using division
17:43ymasorywhat's the difference between a reader macro and a forM?
17:43Chousukehm?
17:44jcromartie(def *primes* (iterate #(BigInteger/nextProbablePrime %) (bigint 1)))
17:44ChousukeforM being?
17:44gfrlogspecial forms are even specialer than macros
17:44ymasoryform
17:44Chousukeah
17:44Chousukea form is a data structure
17:44gfrlogjcromartie: I'm gonna guess that uses division
17:44ymasoryso i was conceptualizing forms as chunks of program text that match a textual pattern
17:44Chousukea reader macro is something that happens before the text ever even becomes code :)
17:45ymasoryp.26 of programming clojure lists the forms it covers, and then p.35 lists reader macros like anonymous functions
17:45ymasoryoh
17:45ymasoryso reader macros are applied before chunks of text are broken into forms?
17:45jcromartieoops that's an instance method
17:45ymasory(come to think of i think he says exactly that)
17:45Chousukewell kind of
17:45Chousukeor hm, I suppose
17:46ymasoryso once all reader macros are applied, the program text would be left with just the fundamental forms
17:46gfrlog,(take 20 (iterate #(.nextProbablePrime %) (bigint 2)))
17:46clojurebot(2 3 5 7 11 13 17 19 23 29 ...)
17:46Chousukewell the reader doesn't actually produce any intermediate text.
17:46Chousukeit just produces forms specially depending on the reader macro
17:47Chousukeeg #(foo) becomes (fn [] (foo)), but never as text.
17:47ChousukeThe reader outputs it as a data structure
17:47jcromartiegfrlog: and that's how you cheat at Project Euler :P
17:47Chousuke,'#(foo) ; quoting is useful
17:47clojurebot(fn* [] (foo))
17:48gfrlogjcromartie: I'm not interested in cheating, I'm interested in interesting stuff
17:48gfrlog,(doc fn*)
17:48clojurebotCool story bro.
17:48jcromartieI'm just saying
17:48Chousukefn* is an implementation detail :(
17:48Chousuke:) even
17:48jcromartie:) I use that approach
17:48ymasoryChousuke: thanks
17:48Chousukejust think fn when you see fn*
17:48Chousukeand same for let*
17:49gfrlogI just use (iterate #(.nextEulerAnswer %) ...)
17:49Zeroflag_:D
17:49Chousukeyou could create an euler DSL in clojure
17:50gfrlogit gets weird after the 307th
17:50Chousukelike, (macroexpand '(euler-answer 20)) gives you the answer
17:50jcromartieChousuke: nice idea
17:50jcromartiethat would definitely be handy
17:50Chousukejcromartie: completely useless, but fun :D
17:50gfrlogwhy the heck would you need macros for that?
17:50Chousukegfrlog: you would not, but it would be fun
17:50gfrlogyou've forgotten the first two rules of macro club
17:51Chousukeall you need is a database of euler answers, pre-read into clojure code
17:51Chousukethen a macro that looks up and outputs the code.
17:51gfrlogrich is holding his head in his hands somewhere
17:51jcromartiemacro club
17:51jcromartiehah
17:51Chousukeyou could even make it extensible! just host the answers in a database somewhere. and the macro connects to the database.
17:52Chousukethe terrifying thing about this is that it's possible. :/
17:52duncanmanyone know how i can configure the histogram in incanter?
17:52gfrlogyou could single handedly destroy project euler just like napster destroyed music
17:53ChousukeBy... not destroying it? :/
17:54gfrlogTRILLIONS OF DOLLARS OF LOST INCOME EVERY FIVE MINUTES
17:54rata_hahahahaha
17:54Chousukethe imaginary income from the executives' fantasies :)
17:55duncanmanyone incanter users here?
17:55Zeroflag_well, removing the map saved more than 1 minute
17:55gfrlogit's easy to show. Economics just comes down to a system of two linear equations with two unknowns
17:55gfrlogZeroflag_: now remove the clojure code and write it in C
17:55Zeroflag_or assembly
17:56gfrlogor erlang
17:56Chousuke(gcc "int main(...") :P
17:56gfrlogexcellent
17:56ChousukeI think someone actually did that
17:56Chousukebut I don't remember where the code is
17:57gfrlogif you can make shell calls it can't be too hard
17:57gfrlogif you have to implement gcc in clojure, it can be too hard
17:57Chousukewell of course you can make shell calls
17:58Chousukemacros can do everything
17:58gfrlogdammit you don't need macros for shell calls
17:58ChousukeI wonder if there actually exists a macro in some production code that uses a network connection somehow
17:58Chousukegfrlog: I know, it's just fun.
17:59Rayneshttp://blog.acidrayne.net/?p=18 A brief and incomplete recount of my trip to the Conj
17:59gfrlogit's not a joke! I caught my coworker writing unnecessary macros once. People get hurt!
18:02gfrlog(defmacro plus [a b] `(+ ~a ~b))
18:03jcromartieone of my favorite hobbies is writing awful macros
18:04jcromartielike, do-backwards
18:04jcromartieor do-sometimes
18:04jcromartieor dont
18:04RaynesWhat would dont do?
18:04jcromartienothing :)
18:04jcromartiejust like comment
18:05RaynesI was about to make that association.
18:05Raynes:p
18:05gfrlogI once tried to figure out how to write a (with-dyslexia) macro that would let you write the forms backwards or forwards and figure out which was right
18:05gfrlogthen I decided it was impossible
18:06jcromartiehah, why?
18:06jcromartieit should be possible
18:06gfrlogmaybe just cause some things are valid both ways
18:06jcromartieI see
18:06gfrlogor maybe cause of special forms
18:06gfrlogI don't remember
18:06jcromartiewalk would help
18:06gfrloganyhow, the strategy was to wrap every form in a try catch
18:07gfrlogI was a macro noob at that point now
18:07gfrlogthough*
18:07jcromartieI see
18:07RaynesLike &|(identity nil?)|& and &|(nil? identity)|&
18:07sexpbot(identity nil?) ⟹ #<core$nil_QMARK_ clojure.core$nil_QMARK_@8703e0>
18:07sexpbot(nil? identity) ⟹ false
18:07jcromartiehow about a macro that shuffles the order of the forms
18:08gfrlogcertainly could
18:09Raynes&(shuffle '((println "blah") (range 10) (+ 3 3)))
18:09sexpbot⟹ [(range 10) (println "blah") (+ 3 3)]
18:09jcromartiewhat's with &?
18:09RaynesThat's (one of) sexpbot's evaluation prefixes.
18:09jcromartieis that a rogue clojurebot?
18:10jarpiainZeroflag_: you could try something like this: http://gist.github.com/654521
18:10Raynessexpbot isn't a clojurebot
18:10Raynes$whatis sexpbot
18:10sexpbotsexpbot = http://github.com/Raynes/sexpbot
18:10jcromartieah I see, more than clojurebot
18:10Raynessexpbot is an entirely different and completely unrelated bot. I made him so I'd have somebody to talk to at night.
18:13gfrlog,(shuffle (iterate inc 7))
18:13clojurebotExecution Timed Out
18:15jcromartiedon't waste clojurebot's time :)
18:16Raynes&(shuffle (take 1000 (iterate inc 7)))
18:16sexpbot⟹ [140 267 569 625 63 776 941 243 80 565 671 837 195 379 805 449 46 1001 77 321 421 993 457 646 1003 700 215 30 430 529 978 531 575 441 670 373 75 664 934 724 731 980 425 853 200 222 672 981 405 121 273 154 743 380 150 875 641 330 950 179 119 447 557 964 74 10 996 477 27 786 191 997 281 29 951 192 248... http://gist.github.com/654552
18:16gfrlog,(shuffle [4])
18:16clojurebot[4]
18:16Zeroflag_jarpiain: much faster
18:16gfrlog&(#(% %) #(% %))
18:16sexpbotjava.lang.StackOverflowError
18:16Zeroflag_a bit faster then the python version
18:17jcromartiegfrlog: is that ASCII art?
18:17gfrlogZeroflag_ what was it you changed?
18:17gfrlogjcromartie: should it be?
18:17Zeroflag_what jcromartie suggested
18:17jcromartienot me
18:17jcromartiejarpiain:
18:17gfrlogyou generated primes faster by using a macro that shuffles the order of forms?
18:18Zeroflag_yeah jarpiain
18:18gfrlogI smell some papers in number theory journals
18:19gfrlog,(doc unchecked-remainder)
18:19clojurebot"([x y]); Returns the remainder of division of x by y, both int or long. Note - uses a primitive operator subject to truncation."
18:22gfrlogso is it faster just cause of the unchecked remainder? or cause it doesn't use the seq of divisors?
18:23jarpiainunchecked-remainder is inlined to a method call that uses primitives
18:23gfrlogand (rem) uses big ints?
18:24jarpiainrem is not inlined and can't therefore use primitives in 1.2
18:24gfrlogwhat does inlining have to do with primitives?
18:26jarpiainthe IFn.invoke() methods that normal fn calls use only take Object arguments
18:26gfrlogah ha
18:33gfrlogchallenge: what's the most interesting thing you can do with palindromic code?
18:34Derandernew goal: palindromic quine
18:35gfrloga palindromic function that prints its own source code iff its one argument is a palindrome
18:40gfrlog,(partial partial)
18:40clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial
18:40gfrlog,(partial partial partial)
18:40clojurebot#<core$partial$fn__3678 clojure.core$partial$fn__3678@f11de2>
18:42jcromartieouch
18:44angermanlol
18:46jarpiain,(let [tel 1 let 2] (print (quote whatever)) '' ((revetahw etouq) tnirp) [2 tel 1 let] tel)
18:46clojurebotwhatever
18:46clojurebot1
18:46gfrlogholy crap
18:47ymasoryPC says parameters aren't vars but are lexically scoped. but what are they called? "non-vars"?
18:50angermanhmm... this is scary. Mac Office 2011 is actually not _that_ bad ...
18:51gfrlog,''(x)
18:51clojurebot(quote (x))
18:52tonyl.'''(x)
18:52tonyl,'''(x)
18:52clojurebot(quote (quote (x)))
18:52gfrlogymasory: can they be called "parameters"?
18:53sdeobaldIf I'm generating a jar with lein (using :main), is there a way to capture the main class from the outside world without gen-and-save? Say... because someone demands this app run under java service wrapper.
18:53ymasorygfrlog: so if i'm getting this correctly, under the umbrella of "bindings in clojure" we have (1) name -> var, (2) name -> param's value
18:53tonylymasory: just function bindings, they are only available in the function scope
18:53ymasory(among others?)
18:53tonyli am not sure they are lexical though
18:54gfrlogI shouldn't talk about vars and things
18:54gfrlogthey are my weak point
18:58gfrlog,(var var)
18:58clojurebotjava.lang.Exception: Unable to resolve var: var in this context
18:58tonyl,#'var
18:58clojurebotjava.lang.Exception: Unable to resolve var: var in this context
18:58tonyl->#'var
18:58sexpbotjava.lang.Exception: Unable to resolve var: var in this context
18:59gfrlogI guess clojure is broken
18:59tonylhaha
19:00rickmode,(doc var)
19:00clojurebotCool story bro.
19:00tonylit is in the special_forms page
19:01tonylhas anybody ported clojure to the parrot vm?
19:01gfrlog,(let [var +] (var 3 4))
19:01clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Symbol
19:02tonyl,(binding [var +] (var 3 4))
19:02clojurebotjava.lang.Exception: Unable to resolve var: var in this context
19:03duncanm,(into {} '([719 7363.897 1787.879] 0 [489 6939.064 2491.794] 1))
19:03clojurebotjava.lang.IllegalArgumentException: Vector arg to map conj must be a pair
19:03duncanmwhy does that fail?
19:03tonylthose special forms are very special
19:03Raynes&(doc var)
19:03sexpbot⟹ "Special Form: Please see http://clojure.org/special_forms#var&quot;
19:03duncanmi want that triplet to be the key, and the single number to be the val
19:04jarpiain,(into {} '([:key1 :val1] [:key2 :val2]))
19:04clojurebot{:key1 :val1, :key2 :val2}
19:04gfrlogit's not a list of pairs
19:04duncanm,(into {} (partition 2 '([:a :b :c] 0 [:d :e :f] 1)))
19:04clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
19:04tonylpairs of keys and values
19:04tonyl,(into {} '([:key1 4] [:key2 9]))
19:04clojurebot{:key1 4, :key2 9}
19:05duncanm,((partition 2 '([:a :b :c] 0 [:d :e :f] 1))
19:05clojurebotEOF while reading
19:05gfrlog,(into {} [[[1 2 3] 4] [[5 6 7] 8]]])
19:05clojurebotUnmatched delimiter: ]
19:05tonyl,(into {} '([0 [719 7363.897 1787.879]] [1 [489 6939.064 2491.794] ]))
19:05duncanm,((partition 2 '([:a :b :c] 0 [:d :e :f] 1)))
19:05clojurebot{0 [719 7363.897 1787.879], 1 [489 6939.064 2491.794]}
19:05clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
19:05jarpiain,(into {} (map vec (partition 2 '([:a :b :c] 0 [:d :e :f] 1))))
19:05clojurebot{[:a :b :c] 0, [:d :e :f] 1}
19:05duncanmsigh
19:05tonyl,(into {} '([0 [719 7363.897 1787.879]] [1 [489 6939.064 2491.794] ]))
19:05gfrlogeverybody try it!
19:05clojurebot{0 [719 7363.897 1787.879], 1 [489 6939.064 2491.794]}
19:05duncanmjarpiain: that's a mouthful
19:06tonylwhat do you want the result to be
19:06sdeobaldHrm. It really looks like the class containing the main method in my jar should be the same name as the 'app.core' namespace. Anyone know what I'm missing?
19:06gfrlog17
19:06duncanm,(into {} (map vec (partition 2 '([:a :b :c] 0 [:d :e :f] 1))))
19:06clojurebot{[:a :b :c] 0, [:d :e :f] 1}
19:06duncanmthat'll do
19:06tonylalright
19:36mabesIs there any way to have a java class bound to a var and use it in `new` without resorting to a macro?
19:36mabesi.e. this is not possible:
19:36mabes,(let [t java.util.Date] (new t))
19:36clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: t
19:37mabesI can get around it by using a macro, but would like to avoid that if possible
19:47mabesI suppose I'll have to use a macro.. it just seems kludgy
19:50Chousuke(.newInstance t)?
19:53bhenryi have only written one macro and only for a course exercise about macros.
20:28Rayneshttp://www.flickr.com/photos/ghoseb/5120169490/in/set-72157625254615916/ Yay! I'm in a conj picture! :>
20:48konris there any way to prevent lein from deleting from /lib libs not listed on project.clj?
20:48konrwith lein deps
20:49iveywhy aren't they in project.clj?
20:50konrnot available on MVN repos
20:50konr* they are java libs not available on MVN repos
20:50mabesChousuke: I knew there was something like that! My lack of java background is showing I suppose. Thanks!
20:51mabeskonr: No, but you can put them in another location where lein will look
20:52Rayneskonr: You can install them in your local maven repo.
20:52Rayneskonr: Add the jar to project.clj and it'll give you instructions on how to install it IIRC.
20:52mabeskonr: technomancy mentioned a dir that is suppose to be used just for that use case in his presentation an the conj... I can't remember what it was ATM.. you could try putting them in a resource dir though http://github.com/technomancy/leiningen/blob/master/sample.project.clj#L82
20:53iveywhat raynes said
21:01konrThanks, guys!
22:37Upper, (10 0) map(* % %)
22:37clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
22:45Upper, (loop [i 0 11] (print i))
22:45clojurebotjava.lang.IllegalArgumentException: loop requires an even number of forms in binding vector
22:45Upperhow can i do?
22:49Upper, (dotimes [i 30] (print i))
22:49clojurebot01234567891011121314151617181920212223242526272829
22:58_seanc_Is there a lightweight cache often used with Clojure?
22:59itistodayi'm trying to learn how to setup a project with cake and swank-clojure + emacs
22:59itistodayi'd like to get this running:
22:59itistodayhttp://nakkaya.com/2010/10/24/more-physics-with-clojure-jbullet-and-processing/
23:00itistodayhere's my project.clj: http://paste.pocoo.org/show/283374/
23:01itistodayi've copied the code from the nakkaya link into src/jbullet_test/core.clj
23:01itistodayso how should I run it?
23:02Upperi'm in queue waiting to be helped too
23:03itistodaythere's a queue?
23:06lrennitistoday: can you join cake.clj?
23:06itistodaylrenn: is that an irc channel?
23:06lrennitistoday: yes, sorry #cake.clj
23:06itistodaylrenn: k, will do
23:14Upper, (time (dotimes [i 1e7] (= i i)))
23:15clojurebot"Elapsed time: 2838.53 msecs"
23:15Upper, (time (dotimes [i 1e7] (== i i)))
23:15clojurebot"Elapsed time: 103.495 msecs"
23:18lrennitistoday: take the swank-clojure out of your dev-dependencies in your project.
23:22lrenn->(loop [i (range 11)] (print i))
23:22sexpbot⟹ (0 1 2 3 4 5 6 7 8 9 10)nil
23:24lrennUpper: did that answer your question?
23:24Upperyes, tk
23:27Upperlrenn: do you know if is possible break a loop without use throw ?
23:39Upper, (rest (1 10))
23:39clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
23:46lrenn,(rest '(1 10))
23:46clojurebot(10)