#clojure log - Oct 29 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:22 notsonerdysunny: is there a way to get sources of all the methods that implement a multimethod?

0:23 I am looking along the lines of the repl macro "source"

0:25 somnium: notsonerdysunny: you can use (.getMethodTable <multimethod>) to get a mapping of dispatch values to function objects

0:26 notsonerdysunny: thanks somnium

0:27 which is the print command that creates a new line when it encounters one instead of just printing it is just "\n" ...

0:27 *it as just "\n"

0:29 println does that .. just thought of sharing .. unfortunately that was the last one I tried .. among pr, prn, pr-str and others

0:32 pmooser: Does 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 ?

0:34 amalloy: pmooser: put it in ~/.m2 somewhere, i think

0:34 pmooser: That's sufficient? I wasn't sure if that got periodically cleared out or something. Thank you!

0:34 somnium: pmooser: You can also create a project to hold the jar, and then `lein install' it.

0:35 amalloy: pmooser: ~/.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

0:36 technomancy: pmooser: just add it as a dependency and run lein deps; the resulting failure message will show you how to install it in ~/.m2

0:37 pmooser: OK. Thanks technomancy.

0:37 I did that earlier but obviously didn't pay enough attention to the error.

0:37 technomancy: it's kind of verbose

0:43 notsonerdysunny: somnium: I get the map yes .. but how can I acess their sources via something like a source command?

0:44 replaca: notsonerdysunny: print... prints human-friendly stuff and pr... prints clojure-readable stuff (more or less)

0:45 so the pr funcs will quote all strings and escape special chars

0:47 itistoday: what are some of the recommended ways of getting the latest clojure-contrib stuff?

0:47 is that still one big jar or has that changed?

0:49 amalloy: &(pr #"1\|2")

0:49 sexpbot: ⟹ #"1\|2"nil

1:03 notsonerdysunny: thanks replaca

1:11 replaca: notsonerdysunny: np!

1:14 notsonerdysunny: what is the lein dependency for clojure 1.3 alpha 2

1:19 replaca: notsonerdysunny: I think it's [org.clojure/clojure "1.3.0-alpha2"], but I haven't tried it so I'm not positive

4:00 raek: good morning

4:01 angerman: how would I use multimethods with keyword arguments?

4:01 or variadic with kw arguments.

4:03 raek: angerman: 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?

4:03 angerman: Assume f: a b -> y and f: a -> y. I would write a handler for f: a that calls f: a b

4:04 raek: basically I want to push the kw arg though to f: a b &{:keys ...}

4:04 but I want to be able to specify them on f: a as well

4:05 or dispatch on the class of a &{:keys ...}

4:05 e.g. (defmulti f class &{:keys ... }) but I hardly think that's valid

4:05 raek: well, first of all the dispatch fn must be variadic (it can ignore the extra arguments, bust must accept being called with them)

4:06 angerman: yes

4:06 raek: say you want to dispatch on the type of the first args: (fn [x & _] (class x))

4:06 angerman: so the default would be &rest with (apply (comp fn ... ) rest?

4:07 raek: the default?

4:07 as long as your fispatch fn is variadic, the method implementation can be variadic too

4:08 angerman: well yes. How would one "usually" handle the passing of additional arguments to a function

4:09 raek: one way is (defn foo ([x] (foo x 0)) ([x y] ...))

4:09 that one is useful when having fixed arities

4:10 for any number of arguments (defn foo [x & opts] ...) is common

4:10 & {:keys [x], :or {x 0}} being a special case

4:10 sexpbot: java.lang.Exception: Unable to resolve symbol: x in this context

4:10 angerman: yes. but say I have a dispatch on class plus 1 fixed arity (different class) and a a set of kw-args

4:11 now the first dispatch method just converts the first argument to a different class and calls itself (resulting in a different dispatch)

4:11 raek: ok. so you would call it like (foo a b :x 1, :y 2) ?

4:11 angerman: yes

4:12 raek: if they share the same dispatch value, you have to implement them in the same defmethod

4:12 angerman: lets say (foo a:T1 :x 1 :y 2)

4:12 and (foo a:T2 :x 1 :y 2)

4:13 now (defmethod foo T1 [a & rest] (apply (comp foo (t1-to-t2 a)) rest)) ?

4:14 raek: that should work, I think

4:14 angerman: and (defmoethod foo T2 [a & {:keys [x y] :or {x 0 y 0}}] (list a x y))

4:15 raek: looks good

4:17 you'd do it in the same way as if you would have two separate ordinary functions (defn foo-T1 ...) (defn foo-T2 ...)

4:17 angerman: so (apply (comp ... is the standard way of passing it down

4:18 raek: ah, didn't see the comp

4:18 (apply fii (t1-to-t2 a) rest) should be sufficient

4:18 *foo

4:18 (apply f x args) is the same as (apply f (cons x args))

4:19 so except for the comp part, yes. that would be the standard way

4:19 angerman: hmm... & _ doesn't work with {:keys?!}

4:20 raek: in what way?

4:20 angerman: well I'm trying to hunt this down.

4:21 (defmulti foo (fn [x & _] (class x)))

4:21 tells me somthing about 3 args being passed to class.

4:21 Hmm let's try (comp class first)

4:22 raek: the dispatch fn will get all the arguments passed to the multimethods as separate arguments

4:23 angerman: hmm. maybe reevaluating multimethods using the repl is just not such a great plan

4:23 raek: oh, yeah. forgot to mention a thing...

4:23 angerman: btw: are there any tools to make the REPL a little bit more "friendly"?

4:24 raek: defmethod has defonce semantics

4:24 so you have to remove the var if you want to replace it

4:24 (ns-unmap 'your-ns 'foo)

4:24 simply reavaluating it does not replace it

4:26 this is to avoid the situation that used to happen when you reloaded the ns with the defmulti (all method implementations were cleared)

4:26 angerman: I myself use Emacs with slime. that makes the repl very freindly IMHO.

4:27 angerman: yes that's what I do as well. but the tracebacks are often not helpful

4:27 raek: if you compile the ns file with C-c C-k you will get line numbers for your definitions

4:28 that makes it much easier to debug

4:29 also, pressing v in the exception buffer on a stack trace line with line number info will hilight the code at that location

4:30 angerman: another thing that iritates me is that pressing 0 on the backtrace buffer takes some time to close it

4:31 raek: hrm, in my Emacs, it happens instantaneously

4:32 angerman: here it takes 1 to 2 seconds or so

4:32 maybe it's caused by AutoComplete mode or so

4:33 btw: is there an issue with using the latest SLIME with the SWANK-clojure form April?

4:33 it just tells me each time I connect to the swank server that the versions missmatch

4:34 notsonerdysunny: angerman: I face similar problems with emacs ...

4:35 and backtrace

4:36 angerman: strange stuff

4:52 TobiasRaeder: morning everybody

5:01 angerman: Hmmm (javax.swing.JComponent.)

5:01 causes an instantiation error, does anyone have an idea what that means?

5:03 Tordmor: angerman: means JComponent is an abstract class and not meant to be instantiated

5:03 angerman: ...

5:03 * angerman shoots himself in the foot

5:10 LauJensen: Good morning all

5:11 sthubner: good morning, LauJensen

5:11 LauJensen: had a safe trip back?

5:11 LauJensen: sthubner: I was just about to ask you the same, but yes thanks, the trip home went great, touched down @ 2300

5:11 angerman: wow. gui programming just got easier.

5:12 sthuebner: LauJensen: I met some friends after arival in Berlin. Got home around 01:30

5:12 angerman: (display (scrollable (vstack (map #(hstack (map jcomp (analyze-char %))) (range 1 217))))) -- quite readable, no?

5:13 LauJensen: angerman: try again with ->> and it might make more sense

5:13 sthuebner: okay, sounds tough

5:15 sthuebner: I 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

5:16 LauJensen: Great

5:16 hoeck: angerman: totally, I love gui programming in clojure :)

5:16 angerman: faster than drawing on paper :)

5:17 angerman: either i draw too fast or write too slow then

5:18 * hoeck is bad at drawing pictures

5:48 bobo_: this php and java stuff at work is no fun at all after 3 days of clojure :-(

5:49 sthuebner: bobo_: I can feel, what you're saying ;-)

5:51 bobo_: would almost be worth it to do half price for consulting on clojure for a while

5:52 sthuebner: at least it would be more fun, I'd guess

7:26 dpro: hi

7:26 any overtone users in here ?

7:27 AWizzArd: dpro: don't forget there is also a german Clojure channel :)

7:28 dpro: AWizzArd: hmmm more german speaking overtone users you reckon ? ;)

7:28 cemerick: dpro: this is the music library?

7:28 dpro: cemerick: yes clojure -> supercollider bridge

7:29 AWizzArd: http://github.com/samaaron/overtone

7:29 dpro: it's fun so far, but I'm quite new to clojure and I haven't figured out how to set a running synth

7:29 's parameter

7:29 cemerick: dpro: no idea what supercollider is :-) Is this similar to e.g. Archaeopteryx?

7:30 dpro: cemerick: no idea what Archaeopteryx is

7:30 cemerick: http://supercollider.sf.net

7:33 cemerick: interesting

7:34 Archaeopteryx is e.g. http://gilesbowkett.blogspot.com/2008/02/archaeopteryx-ruby-midi-generator.html

7:35 There 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.

7:35 Certainly seems like a field ripe for Clojure domination. ;-)

7:42 dpro: hmmm ... is there a way to see all the things defined in a certain namespace ?

7:44 AWizzArd: You could try ns-map.

7:48 dpro: found it in the sources ...

7:50 angerman: does anyone have experience with ANN?

7:51 dpro: hmmm some noob question:

7:52 bar ;; is a synth node -> 6 , (ctl 6 :f 100) ;; (re)sets the frequency , (ctl bar :f 200) ;; error ???

7:55 AWizzArd: angerman: there is Encog

7:55 http://www.heatonresearch.com/encog

7:55 Ist ziemlich umfangreich.

7:56 angerman: Hmm mal schauen. Ich muss es danach zwar eh in ObjC neu schreiben aber für den Prototyp wird's reichen.

7:57 AWizzArd: Well, when you have to rewrite it, then this lib won't help much.

7:58 angerman: for experimentation they will

7:58 AWizzArd: It is available for Java and .NET and should work with Clojure for both plattforms.

7:58 Very sophisticated stuff in there.

7:58 It also implements the Boltzmann machine.

7:59 What kind of patters would you like to recognize? Breaking google captchas? ;)

7:59 angerman: nah.

7:59 take the money from your pocket and try to recognize the serial number :D

8:00 I'm basically done till the point where I need to figure out what the shape in my 20x60 box is.

8:00 so pretty simple and stupid OCR for ~20 different characters

8:00 on my way there I implemented a somewhat half-assed image processing lib in clojure

8:01 workbench? core?

8:01 AWizzArd: We had very nice text recognition results in the past with our CL implementation of the Boltzmann machine.

8:03 angerman: AWizzArd: any upfront suggestions you could offer? I'm basically completely new to this.

8:03 I do have a degree in math though. But machine learning and stochastic calculus have not been my main research area

8:04 AWizzArd: Then you can be simply a user of the lib and not try to program the lib itself :)

8:04 angerman: So I went ahead and looked at some research paper to see what they did... ANN (often Backprop) seemd to be a common choice.

8:05 AWizzArd: 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.

8:05 AWizzArd: Well, you can't implement non-trivial NNs within 2 days. But with Encog you should be able to get started within a few days.

8:05 angerman: AWizzArd: 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)

8:06 after that I figured I need to prototype it first ... :)

8:07 AWizzArd: The workbench will help you to visualize the nets.

8:07 angerman: so I take there's not clojure wrapping lib for it yet, no?

8:09 AWizzArd: not that I know of

8:10 angerman: interesting the workbench.sh fails ..

8:16 TobiasRaeder: Whats workbench?

8:16 angerman: there's a encog workbench

8:16 TobiasRaeder: ah, okay

8:17 angerman: and for some reason the workbench.sh file that's supplied fails to call java with the classpath correctly

8:17 I've no ide why though.

8:18 AWizzArd: what dataformat would you use for the images as input into ?

8:26 this is some of my preprocessed data to be fed into the NN (right side) http://skitch.com/angerman/d75gj/untitled

9:11 chouser: would 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.

9:11 ?

9:11 clojurebot: #<ClassCastException java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;>

9:11 chouser: you know, for tests?

9:12 rhickey: chouser: yes, is there not already a ticket for that? It's what tests/mocks will need given non-dynamic default

9:12 hiredman: we(sonian) have one

9:12 chouser: hiredman: will you be putting it in clojure or contrib?

9:15 hiredman: I suppose I'd have to ask tim, but I don't see why it couldn't

9:18 chouser: I have one too, developed on my own time for the book and/or clojure itself

9:19 rhickey: chouser: stick it as a patch to core.clj on a ticket

9:19 please

9:19 chouser: rhickey: ok, looking for an existing ticket now

9:19 rhickey: with-var-roots?

9:20 we have with-local vars, maybe with-root-vars?

9:20 chouser: I used singular, thinking 'binding' was too

9:20 but now I realize that might be a plural verb

9:21 rhickey: binding doesn't say binding what, as with-blah does

9:21 chouser: right

9:22 mine's built on alter-var-root with constantly :-/

9:22 if we're touching core, would it make more sense to add a set-var-root fn?

9:23 rhickey: set-var-root is a recipe for a total mess

9:24 I'd rather have you call .bindRoot

9:24 maybe that's a better name - binding-roots

9:24 root-binding

9:24 drewr: inc

9:26 * angerman leaks memory

9:26 chouser: I 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

9:26 hiredman: well thats changing too

9:26 chouser: yes, but still implies something different that replacing the root value

9:27 rhickey: hiredman: no, binding is the same, but there was always a root binding, just no function with the word binding in it that manipulated it

9:27 tonyl: morning

9:27 chouser: I guess having "root" in the name may be sufficient

9:27 hiredman: rhickey: I mean the part about binding being thread local

9:27 rhickey: hiredman: I guess more broadly thread local

9:27 thread-of-control

9:27 thread of work

9:27 hrm

9:28 hiredman: thread of process :)

9:28 rhickey: with- is good because it generally implies the dynamic scope

9:28 with-bindings would have been a better name for binding maybe

9:29 if there ever is a bifurcation of types we might not want 'var' in the name

9:30 chouser: "root" is key

9:30 with-roots :-)

9:30 rhickey: chouser: maybe, but if you never have dynamic bindings, you only have a root, and root of what?

9:31 the user experience is - they created with def, this gives temporary defs

9:31 chouser: hm, this might not have to be a macro

9:31 rhickey: root distinguishes from dynamic

9:32 chouser: bleh, good point -- I'm not thinking the new way yet

9:32 rhickey: with-redefs?

9:32 chouser: you're unlikely to use this for :dynamic vars, so maybe root is completely wrong

9:32 rhickey: chouser: dunno about that

9:33 never part

9:33 unlikely == eventually

9:33 but it is the bit set by def, in any case

9:33 with-temp-defs

9:34 drewr: with-def ("with" already meaning transience, "def" meaning it's a root-level thing)

9:35 rhickey: drewr: but a) plural, and b)will this establish non-pre-existing defs?

9:35 i.e. intern vars?

9:36 drewr: should it? I'm guessing not, but I don't know if you plan on changing that

9:36 hiredman: and de-intern when it leaves scope? I hope not

9:36 rhickey: because it won't clean them up if it does

9:36 so, either temp defs or redefs

9:37 redef implies must already exist

9:37 drewr: y, then I vote for redef

9:37 with-temp-defs has the same problem as with-defs

9:37 rhickey: drewr: yes

9:38 redef also implies the global scope of what you're going

9:38 chouser: http://dev.clojure.org/jira/browse/CLJ-665

9:40 rhickey: with-alt-defs

9:42 drewr: hm, not bad

9:42 rhickey: with-swapped-defs

9:50 chouser: looks like it would work fine as a fn. same semantics, just have to quote the vars and provide a fn instead of a body

9:50 rhickey: with-redefs, with-swapped-defs, with-alternate-defs, other - vote!

9:52 tonyl: rhickey: between those three, I would say with-alt-defs.

9:52 rhickey: chouser: yes, should be a two-part API. I imagine most callers will be other macros?

9:52 tonyl: but i don't see anybody having problems with binding, everybody is already using it by that meaning. maybe with-bindings

9:53 rhickey: tonyl: binding is not on the table ATM

9:53 chouser: with-redefs. with-temp-redefs is more explicit, but temp is already pretty well implied by with-

9:53 tonyl: alright

9:53 chouser: rhickey: 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")

9:54 for testing, anyway, knowledge of the vars to stub and what their behavior should be seem to be pretty local to the test itself

9:54 rhickey: chouser: you're expecting use of #'a-var ?

9:57 chouser: not by users, normally, but a function that does most of the work splits out nicely from the macro

9:58 rhickey: so two names needed then

9:59 chouser: with-reders-fn :-)

9:59 er

9:59 rhickey: with-redefs with-redefs-fn

9:59 chouser: yeah

9:59 rhickey: go for it!

9:59 and thanks!

10:00 chouser: np!

10:00 ugh, docstrings. :-P

10:05 cemerick: rhickey: will Big* numerics eventually be usable with interop forms requiring non-Big numerics (presumably tossing an overflow exception as necessary)?

10:06 rhickey: cemerick: are they not now?

10:07 cemerick: rhickey: I've only started fiddling with 1.3.0, but not AFAICT.

10:07 (Integer. 1N) => IllegalArgumentException

10:07 (that being a silly but convenient interop target)

10:08 rhickey: cemerick: that's an overloading thing

10:10 in general, 42N should satisfy an int-taking method

10:10 cemerick: rhickey: 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:10 ah

10:11 rhickey: then how is (Integer. 1N) failing an overloading issue?

10:11 rhickey: this case is reflective, and the reflection matching would have to be augmented to do that match

10:11 cemerick: The only other option is a String

10:11 Oh, I see.

10:11 rhickey: cemerick: because 1N is neither an int nor a String

10:11 cemerick: So nonreflective calls work as I'd expect, reflective calls need further enhancement to get up to par.

10:12 I probably should have thought of that on my own.

10:12 rhickey: you need to patch c.l.Reflector.paramArgTypeMatch

10:15 cemerick: rhickey: should I bother opening a ticket, or is this something that's on your path already?

10:15 rhickey: not on my path, so yes, ticket please

10:16 djpowell: on 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 rhickey: djpowell: you should probably talk it through with Tom to see what he was thinking about

10:23 chouser: replaca <- Tom

10:23 * rhickey hates nicks

10:24 chouser: heh, nice! clojure won't build because I left off the :added metadata

10:27 abedra: rhickey: 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 rhickey: abedra: could you ask the original poster if they agree?

10:28 abedra: i'll email Remco

10:30 ymasory: hi 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:31 mrBliss: Should I use alter-var-root when I want to rebind private functions used in pmaps and futures for testing?

10:32 chouser: mrBliss: yes, or the with-redefs macro for which a patch will exist in a few minutes

10:33 ymasory: 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:34 mrBliss: chouser: thanks, I'm looking forward to the patch :-)

10:34 ymasory: chouser: so clojure *does* have reassignable variables. "programming clojure" brags about that not being the case

10:35 chouser: ymasory: 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:36 ymasory: but def is a purely clojure construct. i could reassign with def without ever touching java

10:40 chouser: You're frustrated that the book seems to have misled you? What part of the book are you referring to?

10:43 rhickey: ymasory: 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:51 chouser: 1.2 had direct binding of some core vars, didn't it?

10:52 ymasory: chouser, rhickey: thank you

10:52 angerman: if anyone has some past experience with ocr, how bad would you judge my "worst" samples: http://skitch.com/angerman/d757m/untitled ?

10:54 cemerick: angerman: this is your input?

10:54 angerman: yes

10:54 well it's the result of quite a bit of preprocessing

10:54 chouser: I 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:55 cemerick: angerman: The washout of e.g. the 5 in the third row will cause problems, I suspect. Same for the 2nd-to-last U.

10:56 chouser: deskewing is essentially assumed by all OCR systems AFAIK

10:56 though tesseract is *old*

10:56 chouser: cemerick: is there a better option that is free and runs on linux? :-P

10:56 cemerick: heh

10:56 no

10:56 chouser: hm, actually, maybe free isn't a requirement.

10:57 cemerick: But, deskewing should lead to good results, esp. if the input is clean.

10:57 chouser: I've got 250+ pages, just for this one PDF. I'm not going to manually deskew them all

10:57 angerman: I'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:57 cemerick: Surely not, no. Easily automatable though.

10:58 angerman: are these serials off of bills?

10:58 angerman: yep

10:58 cemerick: should be good to go then

10:58 angerman: I need to figure out how to encode them to feed them into a ANN...

10:59 rhickey: chouser: direct was neutered right before 1.2 release as static was on the horizon, and there were still no knobs for direct

10:59 angerman: cemerick: and well some of the source images were really (!) bad

10:59 cemerick: angerman: That seems overkill given the domain?

11:00 angerman: cemerick: I'm always open for a better idea. I've no experience with Image Processing nor OCR at all.

11:01 cemerick: angerman: if you can get reliable registration, then determining exclusive sampling points should be straightforward.

11:02 angerman: cemerick: 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 rhickey: cemerick: was it your intent to strip an arbitrary number of colons in keyword-from-strings?

11:03 cemerick: goes beyond the scope of (-> :foo str keyword)

11:03 cemerick: in http://dev.clojure.org/jira/browse/CLJ-463

11:05 cais2002: hi, guys, is there a way to iterate thru a transient set/map ? first/rest do not seem to work

11:08 cemerick: rhickey: Yes; was aiming to be liberal in accepted inputs.

11:08 chouser: rhickey: ah, thanks (re: direct)

11:10 cemerick: rhickey: to Stu's comment, (keyword "::foo") *is* nonsensical, but tossing an exception doesn't seem warranted.

11:15 angerman: 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:16 abedra: rhickey: re: #199 Remco said to go ahead and close the issue

11:30 chouser: mrBliss: patch is at http://dev.clojure.org/jira/browse/CLJ-665

11:30 angerman: cemerick: so basically figuring out sets of points that belong only to one class for each class and classifying against those, right?

11:30 cemerick: angerman: Roughly, yes.

11:31 angerman: cemerick: the method is called registration? are there any further keywords that might guide me to relevant material?

11:33 cemerick: angerman: image registration is the term; totally reasonable overview here, it looks like: http://en.wikipedia.org/wiki/Image_registration

11:33 angerman: cemerick: thanks will read up on that

11:34 cemerick: angerman: 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:34 The outcome should be as effective as ANNs, but a lot easier to implement and train.

11:34 (at least for this dataset)

11:34 mrBliss: chouser: perfect, I would most certainly use it

11:35 cemerick: Anyone who actually knows what they're talking about, feel free to interject. ;-)

11:35 angerman: cemerick: ok, so a 5x5 grid of "on/off" pixels . I really need to read up more on this matter

11:36 cemerick: angerman: that'd be my first shot.

11:37 angerman: if that would work that would be great as it would reduce the cost of adaptive thresholding quite a bit :D

11:40 dash: hmm. 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:41 KirinDave: dash: Transients?

11:41 dash: right that's what i thought

11:41 KirinDave: That's my guess

11:41 I don't know for certain

11:41 chouser: yes

11:41 dash: but this is in PersistentHashMap, not TransientHashMap

11:41 KirinDave: I suspect persistent says "No." :)

11:42 err ant

11:42 dash: http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java#L376

11:43 Oh, hmm

11:43 i think i see what you mean

11:44 KirinDave: I can't get over how weird the clojure source is.

11:44 Not that it's bad code

11:44 It's just conceptually a layer cake

11:44 dash: okay right! the node types implement this stuff because they're used for both persistent and transient hash maps. Right.

11:44 KirinDave: It's like taking a complex frosting and using it to make a simpler cake.

11:45 dash: excellent. i can quit confusing myself now :)

11:45 (FWIW, I am reimplementing PersistentHashMap (partly in C) so that it can be used from Python.)

11:46 KirinDave: Sounds fun except for the last word. :)

11:46 chouser: yikes

11:46 dash: KirinDave: if programming is fun, you're doing it wrong.

11:46 ;)

11:46 Anyway

11:46 chouser: dash: you're doing transients too?

11:47 dash: chouser: 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:47 clojure 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:49 chouser: sure!

11:50 though it can be a bit clumsy to use immutable collections in imperative languages.

11:50 tonyl: that is a great idea dash, and it seems fun to try and do it.

11:50 chouser: I forget, does python have reduce?

11:51 arkh: yes it does - core library

11:52 dash: tonyl: if it sounds so fun, you want to finish it for me? ;D

11:52 jwr7: I 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:52 arkh: I think python is a great imperative language - clojure is just better : )

11:53 tonyl: I'll try, need to learn python first :P

11:53 rhickey: abedra: cool, go for it - thanks!

11:56 jwr7: rhickey: 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:57 rata_: how can I make an anonymous record?

11:58 do I have to use reify?

12:01 duncanm: dum de dum

12:01 Bahman: Hi all!

12:04 duncanm: right now, i'm doing some CPU and IO work with a (map (fn [chunk] (future (doseq [c chunk] (work c)))))

12:04 this is great for the CPU work, but not so great for IO

12:06 so 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:06 chouser: sounds like a BlockingQueue

12:06 rhickey: jwr7: no, it's not resolved until it is tested and applied.

12:07 duncanm: chouser: and use promises to send the IO work along?

12:12 jwr7: rhickey: 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:12 ohpauleez: duncanm: Also see this: http://groups.google.com/group/clojure/browse_thread/thread/9b70a51eed8ef1f2

12:12 I may have led you astray last night

12:13 duncanm: ohpauleez: thanks

12:13 lrenn: -> (meta (read-string "(ns ^{:foo \"bar\"} bar)"))

12:14 sexpbot: ⟹ nil

12:14 lrenn: anyone know how I can get that to work? :)

12:14 ohpauleez: duncanm: the futures weren't starting because of maps laziness, so you need to realize the lazy sequence

12:15 you can do that (obv) with doseq

12:15 or any other way, that will realize the seq

12:15 Vinzent: Hello. I need to add metadata to my function. Is there a way to do it?

12:18 tonyl: Vinzent: (defn ^{:meta "this is my meta} myfn [& args] args)

12:18 forgot quote

12:18 Vinzent: (defn ^{:meta "this is my meta"} myfn [& args] args)

12:21 wrong placement too :P (defn myfn {:meta "this is my meta"} [& args] args) this is right

12:22 Vinzent: tonyl, thanks, but I need metadata on function itself.

12:22 For 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:24 tonyl: if they are lambdas (anonymous fns) then just use the reader macro ^

12:24 like this (meta ^{:meta "my meta"} (fn [& args] args))

12:24 ->(meta ^{:meta "my meta"} (fn [& args] args))

12:24 sexpbot: ⟹ nil

12:25 tonyl: mm, that worked in my repl

12:25 ->^{:meta "my meta"} (fn [& args] args)

12:25 sexpbot: ⟹ #<box12631$eval12860$fn__12861 net.licenser.sandbox.box12631$eval12860$fn__12861@df2ee2>

12:25 tonyl: ,(meta ^{:meta "my meta"} (fn [& args] args))

12:25 clojurebot: {:meta "my meta"}

12:26 lrenn: -> (meta (with-meta (fn []) {:foo "bar"}))

12:26 sexpbot: ⟹ {:foo "bar"}

12:27 Vinzent: Yes, I've tried it and got UnsupportedOperationException

12:27 tonyl: you got the exception with the with-meta form?

12:28 Vinzent: Ah! I have clojure 1.1, think that's the problem

12:28 rata_: how can I make an anonymous record? do I have to use reify?

12:28 tonyl: that's still weird, but it might be that.

12:30 Vinzent: Yes, with 1.2 all works fine. Thank you.

13:09 rata_: why (binding ...) requires there to be a root binding (def ...)?

13:10 chouser: rata_: it doesn't. It only requires that the var exist.

13:11 rata_: chouser, and how can I make a var to exist without (def ...)?

13:12 chouser: def is the best way. what are you trying to do?

13:14 rata_: my fault... I've just realized what I'm doing with binding can be done with let

13:14 chouser: excellent!

13:26 duncanm: ohpauleez: what Meikel said is *exactly* what happened to me last night, that's what i figured out also

13:27 ohpauleez: right, I wasn't even thinking about it

13:27 and as soon as I saw it on my newsfeed, I realized what was happening

13:28 totally apologize about that, I was working on a personal project while helping you instead of totally focusing with the issue

13:28 duncanm: ohpauleez: no no, you were very helpful, no worries

13:28 ohpauleez: cool

13:29 rata_: 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:29 duncanm: ohpauleez: 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:29 rata_: why not just use a structmap?

13:29 or hmm, just a map

13:29 rata_: because records have way faster access

13:29 ohpauleez: duncanm: also have a look at aleph

13:30 it's a bunch of technology built on NIO, that uses channels

13:30 kyleburton: I 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:30 ohpauleez: but you can achieve a lot of what you most likely need with queues and promises

13:30 chaslemley: I asked this a few days ago, sent 2 emails and no response: How do I remove jars/groups from clojars.org?

13:30 kyleburton: I'm looking for the same behavior that clojure maps implement

13:31 ohpauleez: kyleburton: if you make it inherit from IFn, most likely

13:31 kyleburton: oh, they act as maps, so that behavior may already be defined: to do what maps do

13:31 ohpauleez: Haven't tried it yet, let me hit the repl and see what I can do

13:31 duncanm: ohpauleez: implements, not extend (inherit) ;-)

13:31 ohpauleez: yes yes ;)

13:31 kyleburton: ok, if I create something derived from IFn I can override the 'call' method

13:31 ohpauleez: thank you

13:32 ohpauleez: np

13:32 kyleburton: that's at least a lead

13:32 chouser: defrecord currently creates a class that does not implement IFn, but you certainly could add that.

13:32 duncanm: sorry, I was gone when you asked about how to use a BlockingQueue

13:32 kyleburton: now that I'm thinking of it, it'd require getting the fields to use 'get'

13:32 duncanm: chouser: it's okay, i saw a post about it too - but if you have any tips, i'd love to know them

13:33 right now, i'm running my in-efficient thing, trying to render 1100+ images

13:33 i wish i'd gone to Clojure-Conj

13:33 i was *this* close

13:33 oh, well, definitely something for next year

13:33 clojurebot: Huh?

13:33 chouser: duncanm: 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:34 ohpauleez: $(supers (class []))

13:34 ,(supers (class []))

13:34 clojurebot: #{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:35 ohpauleez: kyleburton: probably is ILookup

13:35 kyleburton: ohpauleez: 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:35 ohpauleez: cool

13:35 chouser: kyleburton: (defrecord Foo [a b] clojure.lang.IFn (invoke [t k] (get t k)))

13:36 kyleburton: oh, nice, thanks chhouser

13:36 that actually looks pretty simple - and will 'get' still work on the record?

13:36 chouser: (:x a-record) works by default. The above buys you (a-record :x). The former is probably still more efficient

13:36 kyleburton: fantastic, I will try that for what I'm doing

13:37 chouser: I bet rhickey's going to frown at me for that. sigh.

13:37 kyleburton: oh for the record /call override?

13:37 ohpauleez: chouser: That's at least 10 lashings

13:37 kyleburton: hah, ok

13:38 chouser: kyleburton: 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:38 kyleburton: chouser: yeah, which is one reason why I'm backing off

13:38 clojure is moving and evolving quickly, I don't want this code I'm writing for my employer to be stuck on older revs

13:39 chouser: defrecord keys are always keywords, right? so (a-keyword a-record) will work, why not just use that

13:39 ?

13:40 angerman: how 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:40 kyleburton: oh I have more complex structure in my values, was going to override the 'call' behavior to be able to lok into them

13:40 chouser: rata_: you have a good reason not give your record type a name?

13:40 kyleburton: thanks all

13:40 chouser: angerman: looks good to me

13:41 angerman: chouser: (reduce + (map #(n % %2 i j) (for [x (range 2) y (range 2)] [x y])) ?

13:41 chouser: kyleburton: yeah, probably best to define your own function to do that, rather than adding IFn to the record

13:41 rata_: chouser, I want to create different records each time I call a function

13:41 angerman: that "for" list comprehention is quite a bit different from python

13:41 yes I should probably move the map into the for.

13:42 chouser: rata_: a record type is a class, so that would create new bytecode and load it each time you call a function?

13:44 angerman: heh, yeah -- python's list comprehension is often best read right-to-left, like regular clojure code.

13:44 while clojure's 'for' is often best read left-to-right, like regular python.

13:47 angerman: whoa I love macros

13:47 (defmacro sum [intervals expr] `(reduce + (for ~intervals ~expr)))

13:47 e.g. (sum [i (range 10) j (range 10) k (range 10)] (* i j k))

13:48 chouser: fun

13:48 angerman: I think you can hardly get closer to math notation than that, while retaining flexibility

13:50 that's going to be a good example for macros for my talk about clojure at the faculty next week

13:52 is there a way to strip the clojure.core prefix from macroexpand?

13:52 chouser: pprint has some nice tools for printing code

13:53 angerman: I know it makes sense to have it there but for readability ...

13:55 ohpauleez: angerman: you shouldn't need to qualify macroexpand (or anything in core)

13:56 angerman: no, I mean the output of expandmacro-1

13:56 chouser: try: (require '[clojure.pprint :as p]) (binding [p/*print-suppress-namespaces* true] (p/pprint (macroexpand-1 ...)))

13:56 angerman: I see

13:56 chouser: there's probably a better way, but I can never remember

14:00 rata_: chouser: yes, that's what I want, because I access the record much often that call the function is call much fewer times

14:00 chouser: yes, that's what I want, because I access the record much often that call the function

14:02 also I don't know at compile time the fields of the record

14:04 angerman: chouser: the the binding expression i just (def *foo*) ... do I need a default value?

14:04 chouser: rata_: if you're really sure that's what you want, you can use eval

14:04 rata_: can't do it with reify?

14:05 chouser: reify doesn't generate new classes at runtime

14:05 * Raynes pulls out his cross and wooden eval stake.

14:05 apgwoz: is it considered idiomatic to use a dynamic binding to pass state around?

14:06 Raynes: I've done it before, so probably not.

14:06 apgwoz: i.e. in lieu of passing as an argument to every function called within

14:06 Raynes: ha

14:06 * angerman sees binding as an evironmental switch

14:06 chouser: "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:06 Raynes: apgwoz: 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:07 apgwoz: Raynes: 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:07 Raynes: clj-github used to do that, but it got icky when I had to actually implement something using it, so I did the switcharoo.

14:07 duncanm: chouser: do i use promises in this BlockingQueue scenario?

14:08 apgwoz: chouser: in this case, it'd be private to the namespace, and the exported function would do the binding

14:09 but, i think i'll pass it around. it's cleaner

14:09 chouser: duncanm: nope

14:12 itistoday: so how does one go about getting clojure-contrib stuff today?

14:13 ohpauleez: itistoday: are you using lein?

14:13 or you want to pull all the stuff by hand

14:13 itistoday: ohpauleez: sure, that seeems to be the way to go...

14:13 (lein)

14:14 ohpauleez: itistoday: Take a look at http://gist.github.com/654050

14:14 that'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:15 itistoday: ohpauleez: thanks! that seems to be exactly what i want

14:15 ohpauleez: Awesome! glad i could help

14:15 itistoday: btw, how do i say "i want the latest version"?

14:15 Raynes: Check out cake as well.

14:15 $whatis cake

14:15 sexpbot: cake = http://github.com/ninjudd/cake

14:15 ohpauleez: itistoday: You use SNAPSHOT

14:16 but if you're using 1.3, it's best to use the alpha snapshots

14:16 itistoday: ohpauleez: but you've got this commented out: [org.clojure/clojure "1.3.0-master-SNAPSHOT"]

14:17 ohpauleez: right, because I'm using alpha2

14:17 itistoday: ohpauleez: ah, so if i wanted the latest and greatest, i'd uncomment it out and comment the other one?

14:17 ohpauleez: itistoday: You could, but alpha2 is more or less the latest and greatest

14:18 the release cycle for 1.3 is chunked up into alpha drops, which package up rounded off functionality

14:18 itistoday: ohpauleez: i see, so as to avoid bugs i might be better off doing what you're doing?

14:18 ohpauleez: Right

14:19 itistoday: k cool :-)

14:19 duncanm: chouser, ohpauleez: something like this? http://gist.github.com/654059

14:19 ohpauleez: and it also helps development, because bug reports are relevant to a drop, not a daily build

14:19 itistoday: ohpauleez: gotcha

14:20 chouser: duncanm: looks about right.

14:21 ohpauleez: yeah, 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:21 duncanm: ^^

14:21 chouser: duncanm: here's what I just wrote: http://gist.github.com/654062

14:21 duncanm: chouser: and the length of the BlockingQueue determines how many tasks i 'cache'

14:22 chouser: yeah, I'm not sure about pmap+future. Perhaps just pmap?

14:22 ohpauleez: or just future

14:22 :)

14:23 in this case, I would just use pmap

14:24 and perhaps isolate the render call to it's own future (make it return a future)

14:26 fliebel: Would 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:27 amalloy: What about 1/3?

14:28 fliebel: amalloy: You'd run out of space representing and endless series of threes.

14:29 amalloy: Right. So it's an approximation

14:29 chouser: http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Tech/Chapter02/floatingPt.html

14:29 fliebel: amalloy: But how about the (+ 0.2 0.1) that's currently on HN. They seem perfectly representable to me.

14:29 replaca: fliebel: I'd look on wikipedia (http://en.wikipedia.org/wiki/Ieee_floating_point) for details

14:30 amalloy: The base and exp are both in base 2

14:30 jcromartie: is Java IEEE floating point?

14:30 amalloy: Yes

14:30 jcromartie: (+ 0.1 0.2) blows my mind... I don't know how I haven't seen this before

14:30 I mean I know floating point is not exact

14:30 replaca: fliebel: but remember that floats are represented as binary fractions, not decimal and sometime the conversion isn't as even as you'd think

14:30 chouser: from that link, "Java follows the IEEE 754 standard in most cases"

14:30 itistoday: Raynes: 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:31 Raynes: itistoday: That's actually a little confusing to me as well. I'm not sure why.

14:31 ninjudd or lancepantz: ^

14:32 jarpiain: java has only one of the IEEE rounding modes and only one NaN value

14:32 ohpauleez: jcromartie: That happens on most IEEE floating points, like Python too

14:32 itistoday: anyone happen to know why? :-) (ref: 'clojure' vs 'org.clojure/clojure')?

14:33 angerman: yikes... implementing some very array intensive code in a functional way is not that easy

14:33 fliebel: amalloy, 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:33 chouser: angerman: you've looked at amap, areduce?

14:33 Raynes: itistoday: I suspect that it's nothing cake specific. It must be that clojure is also under clojure in one of the repositories.

14:33 ohpauleez: gah, you beat me to it chouser

14:34 Raynes: Either way, it's the same Clojure in any case.

14:34 angerman: chouser: I'm working down my way on a flow chart from May 1968

14:34 chouser: index arrays and fun...

14:34 lrenn: itistoday: cake has special handling for clojure and clojure-contrib. It adds the correct group name.

14:34 itistoday: Raynes: 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:34 lrenn: itistoday: either will work.

14:35 itistoday: lrenn: so it's a cake thing?

14:35 i don't use cake

14:35 (use lein, as it's clojure based...)

14:35 Raynes: cake is pretty Clojure-based.

14:35 itistoday: oh shit

14:35 just noticed that too

14:35 for some reason i thought it was Ruby

14:36 replaca: well, binary exponents are just m*2^e where m is the mantissa and e is the exponent part, both represented as binary

14:36 Raynes: A 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:36 * angerman want's goto [!]

14:36 replaca: fliebel: but .1 is a nasty binary fraction

14:36 fliebel: replaca: I was just playing with bit-shift-left ;)

14:36 chouser: angerman: recur is goto

14:36 lrenn: itistoday: http://github.com/ninjudd/cake/blob/master/src/cake/project.clj

14:37 Raynes: mostly just a bootstrap script. It also communicates with the persistent JVMs, but I digress.

14:37 hiredman: chouser: crippled

14:37 angerman: chouser: do I have multiple jumpmarks?

14:37 lrenn: itistoday: look at the group function...it puts the correct group in for clojure and clojure-contri.

14:37 chouser: hiredman: yes, angerman: no

14:37 replaca: fliebel: you can be more abstract about that

14:37 hiredman: http://en.wikipedia.org/wiki/COMEFROM is what you want

14:38 lrenn: itistoday: and as Raynes said...cake is clojure. It just uses ruby instead of shell scripts (makes cross platform easier).

14:38 replaca: how many halfs, how many quaters, how many eigths, how many 16ths, how many 32nds,...

14:38 0, 0, 0, 1, ...

14:40 fliebel: replaca: Okay, I'm beginning to see. Exponents are just very coarse grained in binary. So what numbers *can* be represented?

14:40 angerman: What's this coding goint to tell me? if (NODE_m = NODE_j_k) then NODE_m = NODE_j_k

14:40 itistoday: lrenn (and Raynes): thanks, gotcha, i don't know why i thought the whole thing was Ruby

14:40 * angerman scratches head: stating the obvious? why an assignment

14:40 replaca: 0, 0, 0, 1, 1, 0, 0, 1,...

14:40 lrenn: itistoday: sure. I assume lein does the same thing for clojure and clojure-contrib.

14:41 replaca: fliebel: it's not that they're coarse grained, per se, it's just a different base

14:41 chouser: (defn binary [x] (apply str (reverse (map #(if (odd? %) \1 \0) (take-while pos? (iterate #(bit-shift-right % 1) x))))))

14:41 (binary (Float/floatToIntBits 0.1))

14:41 "111101110011001100110011001101"

14:41 replaca: fliebel: so some fractions that seem easy in decimal are hard (or long) in binary

14:42 fliebel: replaca: But any binary fraction can be represented in base 10, right?

14:42 itistoday: lrenn: i see, so "clojure" is resolved by cake to "org.clojure/clojure"?

14:42 replaca: chouser: looks like the "0011" repeats ad infinitum

14:42 Raynes: itistoday: I've just been told that leiningen actually does the same thing.

14:42 jarpiain: fliebel: yes because 2 is a factor of 10

14:42 lrenn: itistoday: correct. just got confirmation that lein does the same.

14:42 itistoday: lrenn Raynes: awesome, thanks! :-)

14:43 chouser: I suppose because 1/10 does do any better in binary than 3/10 does in decimal

14:43 ?

14:43 replaca: fliebel: I believe jarpiain, though I haven't thought hard about this stuff in about 20 years

14:43 rata_: chouser, but with eval I must give it a name too

14:43 chouser: ,(float 0.3)

14:43 clojurebot: 0.3

14:44 chouser: rata_: but you can just generate a name

14:44 rata_: ok, I can do a macro also

14:44 fliebel: but wait, if we can't represent 0.1, how comes 0.1 still evals to 0.1?

14:44 chouser: rata_: not if you don't know your field names until runtime

14:45 rata_: the fields vector must be a literal or can it be an identifier?

14:45 fliebel: replaca: ^^

14:46 jarpiain: fliebel: (str (float x)) returns the shortest decimal that uniquely identifies the float

14:46 andyfingerhut: fliebel: 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:47 Because most people don't want to see 0.0999999999999989

14:47 rata_: ,(let [fields [a b]] (defrecord A fields))

14:47 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

14:48 rata_: mmmm... it must be a literal

14:48 fliebel: andyfingerhut: But that'd make clear we're dealing with an approximation.

14:48 andyfingerhut: And 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:48 fliebel: ,(+ 0.01 0.02) ; these guys do have representations

14:48 clojurebot: 0.03

14:49 andyfingerhut: That 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:50 fliebel: andyfingerhut: So how do I get the actual number that is 0.1?

14:51 chouser: fliebel: 1/10

14:51 jarpiain: ,(BigDecimal. 0.1)

14:51 clojurebot: 0.1000000000000000055511151231257827021181583404541015625M

14:51 andyfingerhut: You 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:51 chouser: ,(= 3/10 (+ 2/10 1/10))

14:51 clojurebot: true

14:51 chouser: ,(= 0.3 (+ 0.2 0.1))

14:51 clojurebot: false

14:52 chouser: we have a section in the book on this. ;-)

14:52 clojurebot: book is http://www.pragprog.com/titles/shcloj/programming-clojure

14:52 chouser: no, not that book.

14:52 andyfingerhut: clojurebot needs another book in its library :)

14:52 fliebel: chouser: I know fractions are awesome, and I have Joy of Clojure, but I'd rather read it on paper.

14:53 chouser: fliebel: it's coming, it's coming...

14:54 fliebel: chouser: Awesome! Tomorrow? Oh, I'm not at home tomorrow. After the weekend maybe? Can't wait...

14:54 chouser: heh

14:54 maybe before next year :-P

14:55 fliebel: Oh, it'd be good to have for christmas, or the Dutch thing no-one knows we celebrate instead.

14:55 chouser: I know. The initial MEAP just missed Christmas last year. I'm afraid the print version is going to miss Christmas this year. :-/

14:56 fliebel: What day is christmas again? It's after 5 dec, right? So you're going to miss our celebration anyway.

14:58 alpheus: Too bad the tracer fn in clojure.contrib.trace gets a string describing the function's args instead of getting the actual args.

14:58 amalloy: Raynes: flight delayed an hour, wish I had a laptop to poke at sexpbot

14:58 ohpauleez: alpheus: you could wrap a macro around those pieces, if you wanted to

14:58 Raynes: amalloy: I'm poking at it as we speak. Going through your embedded stuff.

14:59 alpheus: ohpauleez: I'm looking at Robert Hooke as an alternative

14:59 ohpauleez: ah

15:00 amalloy: &(= #"" #"")

15:00 sexpbot: ⟹ false

15:00 Raynes: amalloy: 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:01 kumarshantanu: ,(every? #(contains? [1 2 3] %) [1 2])

15:01 clojurebot: true

15:01 amalloy: Okay. As you can see it's easy to rip out

15:01 kumarshantanu: ,(every? #(contains? [1 2 3] %) [1 2 3])

15:01 clojurebot: false

15:01 Raynes: Of 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:02 s/truncating/truncated/

15:02 sexpbot: <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:02 fliebel: Okay, now that I thought I understood…

15:02 ,(= (+ 0.1 0.2) (+ (BigDecimal. 0.1) (BigDecimal. 0.2)))

15:02 clojurebot: true

15:02 edbond: can't get [org.clojure.contrib/io "1.3.0-alpha2"], what I do wrong?

15:02 amalloy: You could truncate the code before the result

15:03 fliebel: ,(+ (BigDecimal. 0.1) (BigDecimal. 0.2))

15:03 clojurebot: 0.3000000000000000166533453693773481063544750213623046875M

15:03 amalloy: Eg only show the first ten chars of the code

15:03 fliebel: ,(+ 0.1 0.2)

15:03 clojurebot: 0.30000000000000004

15:03 Raynes: amalloy: I was actually thinking about that.

15:03 I think I'm going to do that.

15:03 Anyways, your changes are excellent.

15:04 amalloy: I agree. It's a good idea and easy, I just didn't think of it yesterday

15:05 rata_: it's strange that deftype has an anonymous counterpart, namely reify, but defrecord doesn't

15:07 amalloy: Anonymous deftype? That's the same as a map

15:07 fliebel: amalloy: I thought struct was.

15:07 chouser: reify doesn't generate public fields like deftype does

15:07 amalloy: Er, defrecord

15:08 The only reason to have a defrecord is so the compiler can access its fields without reflection

15:09 If it were anonymous what would you gain?

15:09 chouser: regardless, reify generates a no more dynamic class than deftype or defrecord does. They all need to know their field list at compile time.

15:09 fliebel: I 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:09 amalloy: Of

15:10 chouser: of course you can have compile time whenever you want using eval, with all that implies.

15:10 rata_: amalloy, you gain faster access

15:11 chouser, what does eval imply?

15:11 fliebel: So… with defrecord and deftype, is there still any reason to use defstruct?

15:12 amalloy: No you don't. If it's anonymous the compiler can't generate the fast access code

15:12 chouser: fliebel: not really

15:12 amalloy: are you sure?

15:13 rata_: mmmm... that's a good point... I thought the compiler could generate the fast code anyway

15:13 amalloy: Chouser: not totally sure, no. within the same fn, maybe it can

15:14 But in that case why not just use a let to begin with?

15:14 chouser: rata_: 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:15 rata_: I use keyword lookup

15:15 chouser: a literal keyword?

15:16 amalloy: Chouser: can't use records as fns, as I recall?

15:16 chouser: amalloy: er, right.

15:17 rata_: mmmm... I'm wrong... I use the map as a fn

15:18 I could use keyword lookup tough, but it wouldn't be a literal

15:18 chouser: so, no call-site caching. it's just a matter of the code path in the map

15:18 rata_: it'd be something like (keyword a-number)

15:19 chouser: small maps are usually array maps, which means a tight loop checking equality of the key

15:19 Raynes: amalloy: I'm going to truncate code at 50.

15:19 rata_: so I wouldn't gain the fast access of records?

15:20 amalloy: Raynes: seems like a lot. I would have guessed like 25

15:20 Raynes: amalloy: In practice, it's not as much as you'd think.

15:21 amalloy: I was imagining using it not to display all the code, but just a reminder where to look in the user's message

15:21 chouser: there 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:22 amalloy: But I bet your judgment here is more accurate than mine

15:22 Raynes: amalloy: /j #(code) for a second

15:25 rata_: ok, and then non-literal keyword lookup on records is the second-fastest?

15:29 amalloy: For non literals I think maps are as fast as records

15:30 vibrant: <- still reading joy of clojure

15:31 chouser: If 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:32 so if you've got a non-literal keyword, it hardly seems worth the pain of generating record types on the fly

15:32 so if you're using a non-literal keyword for lookup, it hardly seems worth the pain of generating record types on the fly

15:34 er, 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:34 sigh

15:35 rata_: 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:36 chouser: (defn t [] (let [foo (Foo. 1 2), k :a] (time (dotimes [_ 1e8] (k foo))))) ; vs. (:a foo)

15:39 rata_: I did that and the non-literal keyword lookup is even a little faster than the literal keyword lookup

15:39 chouser: huh

15:39 well, there you go. don't optimize prematurely.

15:39 rata_: yes, it's weird

15:46 chouser: you mean the compiler optimizes the literal keyword lookup prematurely and that's what makes it runs a little bit slower?

15:47 chouser: no, 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:50 rata_: oh ok :) but after looking at this mini-benchmark, I'd like to optimize it... anyway, I'm first finishing it, then optimize :)

15:51 bhenry: does map the verb guarantee order? or does it just happen that i always see it in the same order?

15:56 chouser: bhenry: it guarantees order

15:57 fliebel: chouser: What about pmap?

15:57 chouser: fliebel: pmap also

16:02 lancepantz: you guys! gotta see this http://twitter.com/#!/lancepantz/status/29118584268

16:02 fliebel: chouser: And what about pvmap? (that's the name of the forkjoin thing, right?)

16:04 chouser: the concept of "map" as a verb implies keeping order, at least in the Clojure world.

16:08 fliebel: chouser: 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:09 chouser: fliebel: ah, I hadn't considered that interpretation of his question

16:12 only 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:13 rata_: integers can't have metadata :(

16:13 chouser: indeed

16:13 clojurebot: It's greek to me.

16:15 fliebel: we should teach clojurebot greek.

16:19 SirNick: Can 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:22 It seems to only occur when I use Ring's session wrapper, but I must be missing something...

16:29 Anyone have any experience using Ring sessions?

16:31 jcromartie: SirNick: let me take a look

16:31 SirNick: jcromartie: Very much appreciated

16:31 jcromartie: The exception is on line 47 of http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session.clj

16:33 jcromartie: response is nil there

16:33 ,(let [n nil] (n :session-cookie-attrs))

16:33 clojurebot: java.lang.NullPointerException

16:33 jcromartie: as an example

16:33 so back to your code

16:33 SirNick: jcromartie: Yea I figured. Do you have any guess why? I don't think I'm altering the response anywhere

16:35 jcromartie: because your handler is a string

16:35 ("foo" {})

16:35 ,("foo" {})

16:35 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

16:35 SirNick: Which line?

16:35 jcromartie: hm

16:35 sorry no

16:35 I'm dumb

16:36 you are passing your routes to wrap-session

16:36 SirNick: am I not supposed to?

16:37 jcromartie: no that's fine

16:39 sorry :( I don't think I have any insight to offer

16:40 SirNick: jcromartie: Alright well thank you for trying anyway

16:40 jcromartie: I mean it looks like (in wrap-session) the response ends up being nil

16:41 SirNick: Yea 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:42 mfex: SirNick: 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:43 SirNick: mfex: Thank you, I'll take a look

16:47 jcromartie: so SirNick, looks like you need to pass at the end of your dynamic routes

16:47 right?

16:47 SirNick: jcromartie: Sorry, what do you mean pass?

16:48 jcromartie: or am I thinking of Sinatra

16:53 reading compojure is great

16:53 I love compile-route

16:53 shows how simple compilation can be in Lisp

16:58 SirNick: jcromartie: 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:58 jcromartie: this reminds me I need to check out the new ring/compojure

16:58 I'm behind

17:00 ring/compojure/clout... I was amazed to see compojure made up of 3 small files

17:04 lrenn: jcromartie: it wasn't always. ring and compojure were doing the same things, so they joined forces.

17:25 ohpauleez: dnolen: ping

17:26 dnolen: ohpauleez: pong

17:26 ohpauleez: dnolen: Were you ever involved with DreamIt?

17:27 Or do you know Laris Kreslin

17:27 dnolen: ohpauleez: yeah I did a very small amount of consulting with the Kidzillions team

17:27 ohpauleez: and I do know Laris :) he's old pals w/ one of my good friends.

17:27 ohpauleez: dnolen: Cool, I'm Paul the CEO of OurShelf.

17:28 dnolen: ohpauleez: haha, sweet, I remember.

17:28 ohpauleez: I saw a picture of you from conj, totally rad you're involved with Clojure

17:28 dnolen: ohpauleez: the same! The Conj was funtimes.

17:29 Zeroflag_: http://pastebin.com/65gJtHa4 <- can anyone tell me why is it so slow?

17:29 it took about 8 minutes to calculate the result

17:30 same thing in python did it in 1.5min

17:30 gfrlog: that doesn't sound like too much of a difference

17:30 do you have the python code too?

17:31 Zeroflag_: yeah

17:31 http://pastebin.com/U5GXWFAB

17:32 Chousuke: #(zero? %) is equivalent to zero?

17:32 Zeroflag_: yes probably

17:33 Chousuke: laziness probably adds some overhead compared to the python version

17:33 jcromartie: that's not a question :)

17:33 Chousuke: but it's just horribly slow code being even slower :)

17:34 jcromartie: but I'd imagine a straight translation of the python code might run faster

17:34 gfrlog: it's the same algorithm

17:34 jcromartie: close enough

17:35 gfrlog: Zeroflag_:with a slight bit of extra effort you can get a more efficient algorithm for what you're doing

17:35 Zeroflag_: how?

17:35 clojurebot: with style and grace

17:35 Zeroflag_: i thought this lazy stuff is idiomatic thats why i used it

17:35 gfrlog: you can still do lazy

17:36 but you don't have to check all the divisors up to sqrt(n)

17:36 you only have to check the primes

17:36 Chousuke: It is, but the laziness overhead adds up if you do very cheap operations lazily.

17:36 Zeroflag_: ok but i don't want to change the algorithm just do some optimalization

17:37 gfrlog: okay

17:37 deja vu

17:38 did you change the zero? anonymous function like Chousuke suggested?

17:38 Chousuke: that probably won't affect it too much

17:38 Zeroflag_: yes but its still running :)

17:39 Chousuke: You could try removing the map and see how much it changes things. ie. (not-any? #(zero? (rem n %)) (range 2 (inc q)))

17:39 but I think it might just be slow boxed arithmetic that's the culprit

17:40 gfrlog: time for 1.3!

17:40 Chousuke: python's probably faster with that.

17:40 Zeroflag_: ok, and does it make any difference if i run it from the repl or try to compile it?

17:40 Chousuke: nah

17:40 jcromartie: Zeroflag_: well you can't just time the execution of java

17:41 try defn'ing a prob10 and then (time (prob10))

17:41 dnolen_: Zeroflag_:running it at the REPL does compile it

17:41 Zeroflag_: ok

17:41 dnolen_: Zeroflag_: have you tried comparing your solution to this one, http://clj-me.cgrand.net/2008/06/07/primes/ ?

17:41 Zeroflag_: not yet

17:42 gfrlog: if you do, replace (lazy-cons a b) with (cons a (lazy-seq b))

17:43 I don't think lazy-cons exists anymore

17:43 fun challenge -- create an infinite seq of primes without using division

17:43 ymasory: what's the difference between a reader macro and a forM?

17:43 Chousuke: hm?

17:44 jcromartie: (def *primes* (iterate #(BigInteger/nextProbablePrime %) (bigint 1)))

17:44 Chousuke: forM being?

17:44 gfrlog: special forms are even specialer than macros

17:44 ymasory: form

17:44 Chousuke: ah

17:44 a form is a data structure

17:44 gfrlog: jcromartie: I'm gonna guess that uses division

17:44 ymasory: so i was conceptualizing forms as chunks of program text that match a textual pattern

17:44 Chousuke: a reader macro is something that happens before the text ever even becomes code :)

17:45 ymasory: p.26 of programming clojure lists the forms it covers, and then p.35 lists reader macros like anonymous functions

17:45 oh

17:45 so reader macros are applied before chunks of text are broken into forms?

17:45 jcromartie: oops that's an instance method

17:45 ymasory: (come to think of i think he says exactly that)

17:45 Chousuke: well kind of

17:45 or hm, I suppose

17:46 ymasory: so once all reader macros are applied, the program text would be left with just the fundamental forms

17:46 gfrlog: ,(take 20 (iterate #(.nextProbablePrime %) (bigint 2)))

17:46 clojurebot: (2 3 5 7 11 13 17 19 23 29 ...)

17:46 Chousuke: well the reader doesn't actually produce any intermediate text.

17:46 it just produces forms specially depending on the reader macro

17:47 eg #(foo) becomes (fn [] (foo)), but never as text.

17:47 The reader outputs it as a data structure

17:47 jcromartie: gfrlog: and that's how you cheat at Project Euler :P

17:47 Chousuke: ,'#(foo) ; quoting is useful

17:47 clojurebot: (fn* [] (foo))

17:48 gfrlog: jcromartie: I'm not interested in cheating, I'm interested in interesting stuff

17:48 ,(doc fn*)

17:48 clojurebot: Cool story bro.

17:48 jcromartie: I'm just saying

17:48 Chousuke: fn* is an implementation detail :(

17:48 :) even

17:48 jcromartie: :) I use that approach

17:48 ymasory: Chousuke: thanks

17:48 Chousuke: just think fn when you see fn*

17:48 and same for let*

17:49 gfrlog: I just use (iterate #(.nextEulerAnswer %) ...)

17:49 Zeroflag_: :D

17:49 Chousuke: you could create an euler DSL in clojure

17:50 gfrlog: it gets weird after the 307th

17:50 Chousuke: like, (macroexpand '(euler-answer 20)) gives you the answer

17:50 jcromartie: Chousuke: nice idea

17:50 that would definitely be handy

17:50 Chousuke: jcromartie: completely useless, but fun :D

17:50 gfrlog: why the heck would you need macros for that?

17:50 Chousuke: gfrlog: you would not, but it would be fun

17:50 gfrlog: you've forgotten the first two rules of macro club

17:51 Chousuke: all you need is a database of euler answers, pre-read into clojure code

17:51 then a macro that looks up and outputs the code.

17:51 gfrlog: rich is holding his head in his hands somewhere

17:51 jcromartie: macro club

17:51 hah

17:51 Chousuke: you could even make it extensible! just host the answers in a database somewhere. and the macro connects to the database.

17:52 the terrifying thing about this is that it's possible. :/

17:52 duncanm: anyone know how i can configure the histogram in incanter?

17:52 gfrlog: you could single handedly destroy project euler just like napster destroyed music

17:53 Chousuke: By... not destroying it? :/


17:54 rata_: hahahahaha

17:54 Chousuke: the imaginary income from the executives' fantasies :)

17:55 duncanm: anyone incanter users here?

17:55 Zeroflag_: well, removing the map saved more than 1 minute

17:55 gfrlog: it's easy to show. Economics just comes down to a system of two linear equations with two unknowns

17:55 Zeroflag_: now remove the clojure code and write it in C

17:55 Zeroflag_: or assembly

17:56 gfrlog: or erlang

17:56 Chousuke: (gcc "int main(...") :P

17:56 gfrlog: excellent

17:56 Chousuke: I think someone actually did that

17:56 but I don't remember where the code is

17:57 gfrlog: if you can make shell calls it can't be too hard

17:57 if you have to implement gcc in clojure, it can be too hard

17:57 Chousuke: well of course you can make shell calls

17:58 macros can do everything

17:58 gfrlog: dammit you don't need macros for shell calls

17:58 Chousuke: I wonder if there actually exists a macro in some production code that uses a network connection somehow

17:58 gfrlog: I know, it's just fun.

17:59 Raynes: http://blog.acidrayne.net/?p=18 A brief and incomplete recount of my trip to the Conj

17:59 gfrlog: it's not a joke! I caught my coworker writing unnecessary macros once. People get hurt!

18:02 (defmacro plus [a b] `(+ ~a ~b))

18:03 jcromartie: one of my favorite hobbies is writing awful macros

18:04 like, do-backwards

18:04 or do-sometimes

18:04 or dont

18:04 Raynes: What would dont do?

18:04 jcromartie: nothing :)

18:04 just like comment

18:05 Raynes: I was about to make that association.

18:05 :p

18:05 gfrlog: I 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:05 then I decided it was impossible

18:06 jcromartie: hah, why?

18:06 it should be possible

18:06 gfrlog: maybe just cause some things are valid both ways

18:06 jcromartie: I see

18:06 gfrlog: or maybe cause of special forms

18:06 I don't remember

18:06 jcromartie: walk would help

18:06 gfrlog: anyhow, the strategy was to wrap every form in a try catch

18:07 I was a macro noob at that point now

18:07 though*

18:07 jcromartie: I see

18:07 Raynes: Like &|(identity nil?)|& and &|(nil? identity)|&

18:07 sexpbot: (identity nil?) ⟹ #<core$nil_QMARK_ clojure.core$nil_QMARK_@8703e0>

18:07 (nil? identity) ⟹ false

18:07 jcromartie: how about a macro that shuffles the order of the forms

18:08 gfrlog: certainly could

18:09 Raynes: &(shuffle '((println "blah") (range 10) (+ 3 3)))

18:09 sexpbot: ⟹ [(range 10) (println "blah") (+ 3 3)]

18:09 jcromartie: what's with &?

18:09 Raynes: That's (one of) sexpbot's evaluation prefixes.

18:09 jcromartie: is that a rogue clojurebot?

18:10 jarpiain: Zeroflag_: you could try something like this: http://gist.github.com/654521

18:10 Raynes: sexpbot isn't a clojurebot

18:10 $whatis sexpbot

18:10 sexpbot: sexpbot = http://github.com/Raynes/sexpbot

18:10 jcromartie: ah I see, more than clojurebot

18:10 Raynes: sexpbot is an entirely different and completely unrelated bot. I made him so I'd have somebody to talk to at night.

18:13 gfrlog: ,(shuffle (iterate inc 7))

18:13 clojurebot: Execution Timed Out

18:15 jcromartie: don't waste clojurebot's time :)

18:16 Raynes: &(shuffle (take 1000 (iterate inc 7)))

18:16 sexpbot: ⟹ [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:16 gfrlog: ,(shuffle [4])

18:16 clojurebot: [4]

18:16 Zeroflag_: jarpiain: much faster

18:16 gfrlog: &(#(% %) #(% %))

18:16 sexpbot: java.lang.StackOverflowError

18:16 Zeroflag_: a bit faster then the python version

18:17 jcromartie: gfrlog: is that ASCII art?

18:17 gfrlog: Zeroflag_ what was it you changed?

18:17 jcromartie: should it be?

18:17 Zeroflag_: what jcromartie suggested

18:17 jcromartie: not me

18:17 jarpiain:

18:17 gfrlog: you generated primes faster by using a macro that shuffles the order of forms?

18:18 Zeroflag_: yeah jarpiain

18:18 gfrlog: I smell some papers in number theory journals

18:19 ,(doc unchecked-remainder)

18:19 clojurebot: "([x y]); Returns the remainder of division of x by y, both int or long. Note - uses a primitive operator subject to truncation."

18:22 gfrlog: so is it faster just cause of the unchecked remainder? or cause it doesn't use the seq of divisors?

18:23 jarpiain: unchecked-remainder is inlined to a method call that uses primitives

18:23 gfrlog: and (rem) uses big ints?

18:24 jarpiain: rem is not inlined and can't therefore use primitives in 1.2

18:24 gfrlog: what does inlining have to do with primitives?

18:26 jarpiain: the IFn.invoke() methods that normal fn calls use only take Object arguments

18:26 gfrlog: ah ha

18:33 challenge: what's the most interesting thing you can do with palindromic code?

18:34 Derander: new goal: palindromic quine

18:35 gfrlog: a palindromic function that prints its own source code iff its one argument is a palindrome

18:40 ,(partial partial)

18:40 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial

18:40 gfrlog: ,(partial partial partial)

18:40 clojurebot: #<core$partial$fn__3678 clojure.core$partial$fn__3678@f11de2>

18:42 jcromartie: ouch

18:44 angerman: lol

18:46 jarpiain: ,(let [tel 1 let 2] (print (quote whatever)) '' ((revetahw etouq) tnirp) [2 tel 1 let] tel)

18:46 clojurebot: whatever

18:46 1

18:46 gfrlog: holy crap

18:47 ymasory: PC says parameters aren't vars but are lexically scoped. but what are they called? "non-vars"?

18:50 angerman: hmm... this is scary. Mac Office 2011 is actually not _that_ bad ...

18:51 gfrlog: ,''(x)

18:51 clojurebot: (quote (x))

18:52 tonyl: .'''(x)

18:52 ,'''(x)

18:52 clojurebot: (quote (quote (x)))

18:52 gfrlog: ymasory: can they be called "parameters"?

18:53 sdeobald: If 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:53 ymasory: gfrlog: 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:53 tonyl: ymasory: just function bindings, they are only available in the function scope

18:53 ymasory: (among others?)

18:53 tonyl: i am not sure they are lexical though

18:54 gfrlog: I shouldn't talk about vars and things

18:54 they are my weak point

18:58 ,(var var)

18:58 clojurebot: java.lang.Exception: Unable to resolve var: var in this context

18:58 tonyl: ,#'var

18:58 clojurebot: java.lang.Exception: Unable to resolve var: var in this context

18:58 tonyl: ->#'var

18:58 sexpbot: java.lang.Exception: Unable to resolve var: var in this context

18:59 gfrlog: I guess clojure is broken

18:59 tonyl: haha

19:00 rickmode: ,(doc var)

19:00 clojurebot: Cool story bro.

19:00 tonyl: it is in the special_forms page

19:01 has anybody ported clojure to the parrot vm?

19:01 gfrlog: ,(let [var +] (var 3 4))

19:01 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Symbol

19:02 tonyl: ,(binding [var +] (var 3 4))

19:02 clojurebot: java.lang.Exception: Unable to resolve var: var in this context

19:03 duncanm: ,(into {} '([719 7363.897 1787.879] 0 [489 6939.064 2491.794] 1))

19:03 clojurebot: java.lang.IllegalArgumentException: Vector arg to map conj must be a pair

19:03 duncanm: why does that fail?

19:03 tonyl: those special forms are very special

19:03 Raynes: &(doc var)

19:03 sexpbot: ⟹ "Special Form: Please see http://clojure.org/special_forms#var"

19:03 duncanm: i want that triplet to be the key, and the single number to be the val

19:04 jarpiain: ,(into {} '([:key1 :val1] [:key2 :val2]))

19:04 clojurebot: {:key1 :val1, :key2 :val2}

19:04 gfrlog: it's not a list of pairs

19:04 duncanm: ,(into {} (partition 2 '([:a :b :c] 0 [:d :e :f] 1)))

19:04 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry

19:04 tonyl: pairs of keys and values

19:04 ,(into {} '([:key1 4] [:key2 9]))

19:04 clojurebot: {:key1 4, :key2 9}

19:05 duncanm: ,((partition 2 '([:a :b :c] 0 [:d :e :f] 1))

19:05 clojurebot: EOF while reading

19:05 gfrlog: ,(into {} [[[1 2 3] 4] [[5 6 7] 8]]])

19:05 clojurebot: Unmatched delimiter: ]

19:05 tonyl: ,(into {} '([0 [719 7363.897 1787.879]] [1 [489 6939.064 2491.794] ]))

19:05 duncanm: ,((partition 2 '([:a :b :c] 0 [:d :e :f] 1)))

19:05 clojurebot: {0 [719 7363.897 1787.879], 1 [489 6939.064 2491.794]}

19:05 java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

19:05 jarpiain: ,(into {} (map vec (partition 2 '([:a :b :c] 0 [:d :e :f] 1))))

19:05 clojurebot: {[:a :b :c] 0, [:d :e :f] 1}

19:05 duncanm: sigh

19:05 tonyl: ,(into {} '([0 [719 7363.897 1787.879]] [1 [489 6939.064 2491.794] ]))

19:05 gfrlog: everybody try it!

19:05 clojurebot: {0 [719 7363.897 1787.879], 1 [489 6939.064 2491.794]}

19:05 duncanm: jarpiain: that's a mouthful

19:06 tonyl: what do you want the result to be

19:06 sdeobald: Hrm. 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:06 gfrlog: 17

19:06 duncanm: ,(into {} (map vec (partition 2 '([:a :b :c] 0 [:d :e :f] 1))))

19:06 clojurebot: {[:a :b :c] 0, [:d :e :f] 1}

19:06 duncanm: that'll do

19:06 tonyl: alright

19:36 mabes: Is there any way to have a java class bound to a var and use it in `new` without resorting to a macro?

19:36 i.e. this is not possible:

19:36 ,(let [t java.util.Date] (new t))

19:36 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: t

19:37 mabes: I can get around it by using a macro, but would like to avoid that if possible

19:47 I suppose I'll have to use a macro.. it just seems kludgy

19:50 Chousuke: (.newInstance t)?

19:53 bhenry: i have only written one macro and only for a course exercise about macros.

20:28 Raynes: http://www.flickr.com/photos/ghoseb/5120169490/in/set-72157625254615916/ Yay! I'm in a conj picture! :>

20:48 konr: is there any way to prevent lein from deleting from /lib libs not listed on project.clj?

20:48 with lein deps

20:49 ivey: why aren't they in project.clj?

20:50 konr: not available on MVN repos

20:50 * they are java libs not available on MVN repos

20:50 mabes: Chousuke: I knew there was something like that! My lack of java background is showing I suppose. Thanks!

20:51 konr: No, but you can put them in another location where lein will look

20:52 Raynes: konr: You can install them in your local maven repo.

20:52 konr: Add the jar to project.clj and it'll give you instructions on how to install it IIRC.

20:52 mabes: konr: 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:53 ivey: what raynes said

21:01 konr: Thanks, guys!

22:37 Upper: , (10 0) map(* % %)

22:37 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

22:45 Upper: , (loop [i 0 11] (print i))

22:45 clojurebot: java.lang.IllegalArgumentException: loop requires an even number of forms in binding vector

22:45 Upper: how can i do?

22:49 , (dotimes [i 30] (print i))

22:49 clojurebot: 01234567891011121314151617181920212223242526272829

22:58 _seanc_: Is there a lightweight cache often used with Clojure?

22:59 itistoday: i'm trying to learn how to setup a project with cake and swank-clojure + emacs

22:59 i'd like to get this running:

22:59 http://nakkaya.com/2010/10/24/more-physics-with-clojure-jbullet-and-processing/

23:00 here's my project.clj: http://paste.pocoo.org/show/283374/

23:01 i've copied the code from the nakkaya link into src/jbullet_test/core.clj

23:01 so how should I run it?

23:02 Upper: i'm in queue waiting to be helped too

23:03 itistoday: there's a queue?

23:06 lrenn: itistoday: can you join cake.clj?

23:06 itistoday: lrenn: is that an irc channel?

23:06 lrenn: itistoday: yes, sorry #cake.clj

23:06 itistoday: lrenn: k, will do

23:14 Upper: , (time (dotimes [i 1e7] (= i i)))

23:15 clojurebot: "Elapsed time: 2838.53 msecs"

23:15 Upper: , (time (dotimes [i 1e7] (== i i)))

23:15 clojurebot: "Elapsed time: 103.495 msecs"

23:18 lrenn: itistoday: take the swank-clojure out of your dev-dependencies in your project.

23:22 ->(loop [i (range 11)] (print i))

23:22 sexpbot: ⟹ (0 1 2 3 4 5 6 7 8 9 10)nil

23:24 lrenn: Upper: did that answer your question?

23:24 Upper: yes, tk

23:27 lrenn: do you know if is possible break a loop without use throw ?

23:39 , (rest (1 10))

23:39 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

23:46 lrenn: ,(rest '(1 10))

23:46 clojurebot: (10)

Logging service provided by n01se.net