#clojure log - Feb 12 2009

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

0:05 replaca: yeah, destructuring bind is one of the great lispisms

4:12 AWizzArd: clojurebot: max people

4:12 clojurebot: max people is 149

4:25 leafw: anybody can comment on the binding+import problem I just posted to the list

4:26 is this a clojure bug, or am I missing something.

4:34 hiredman: import works in side binding here

4:35 user=> (binding [] (import '(java.io File)))

4:35 nil

4:35 user=> File

4:35 java.io.File

4:37 leafw: that is case 1.

4:37 case 2 fails.

4:38 this fails: (binding [*out* bout] (import '(java.io File)) (println (File. "/home/albert"))

4:38 i.e. the import and the usage of the import all within the same binding block.

6:04 tomsw: Is there an inbuilt function to get the length of a list? I'm trying to write a function to shuffle a list and (afaik) for this i need the length

6:04 ayrnieu: ,(count '(1 2 3))

6:04 clojurebot: 3

6:07 AWizzArd: tomsw: maybe you should shuffle a vector

6:07 Lists are not particularly important in Clojure.

6:18 alinpopa: tomsw: you can use size from java: (.size '(1 2 3))

6:19 I don't know if it's not slower than count .. but if you come from a java world you can use it (eg. you can use length for strings: (.length "abc") => 3)

6:20 .(.size '(1 2 3))

6:20 ,(.size '(1 2 3))

6:20 clojurebot: 3

6:20 alinpopa: ,(.length "abc")

6:20 clojurebot: 3

6:37 leafw: alinpopa: it's the same really. count will call .length or .size, setup on read time, depending upon data type.

6:37 alinpopa: leafw: thanks for explanation

6:38 I noticed that count is more general form (eg. instead of using .length for String and .size for collections, count can be used for both)

6:54 tomsw: ok, I'm used to CL. Here's my attempt to shuffle a collection...

6:54 lisppaste8: tomsw pasted "Shuffle a collection" at http://paste.lisp.org/display/75328

6:54 tomsw: Comments welcome: be cruel to be kind (but not too cruel...)

6:59 Chousuke: tomsw: why the weird destructuring?

7:00 tomsw: looks like you should instead just overload it for one and two arguments

7:01 tomsw: Chousuke: the optional "up-to"?

7:03 lisppaste8: Chousuke annotated #75328 with "overloaded... not guaranteed to have matching parens." at http://paste.lisp.org/display/75328#1

7:03 Chousuke: gah! just a moment after I clicked submit I noticed one missing paren...

7:03 after the (shuffle coll (count coll))

7:05 tomsw: Chousuke: oh I get it. I didn't want to duplicate code, forgot that one overloading can use another.

7:05 Chousuke: otherwise that looks okay I think.

7:06 I think there's an implementation in contrib that copies the coll into a java array and uses java's shuffle, then returns that in a vector

7:06 tomsw: Chousuke: that's just cheating

7:06 Chousuke: yeah, it is :)

7:07 but sort does it too

7:07 it's probably a fair bit faster for larger collections too :/

7:07 tomsw: Chousuke: also, the wheel isn't as new & shiny as it used to be

7:07 ayrnieu: cheating is destructively sorting a linked list via an array of pointers to cons cells.

7:08 going through a java array is just good sense :-)

7:08 Chousuke: I guess the immutable data structures just aren't fit for shuffling very efficiently :)

7:08 not that it matters much

7:10 tomsw: Chousuke: I have been trying to work through "Purely functional data structures" which shows how you can get good performace with immutable data structures. Just haven't got far enough to spot anything that might apply to shuffling. Quite a good way to hurt your brain though

7:11 Chousuke: well, shuffling is something where it's beneficial to be destructive, at least during shuffling

7:11 since you don't care at all about what the structure looks while you're shuffling

7:14 if you do the copy-and-shuffle trick the function remains purely functional to the outside anyway (to the extent that functions producing random results can be called purely functional)

7:15 tomsw: Chousuke: :) not at all, in fact...

7:19 Holcxjo: But, if you do it purely functional you might be able to do parallelise the shuffling?

7:19 ayrnieu: Chousuke - they can't. But you can pass them the RNG's state, or imply this in a state-of-the-universe argument.

7:20 but they can be pure and nondeterministic.

7:34 tomsw: is there a good way to look up the java docs from inside Emacs?

7:37 Holcxjo: tomsw: (use ['clojure.contrib.javadoc])

7:37 Chousuke: Holcxjo: that's easy to do with copying and destructive shuffling as well: just shuffle each half separately and concatenate :)

7:37 Holcxjo: That's the best I know

7:37 then (javadoc String) and a browser should open up

7:39 Chousuke: True :-) Although you might actually get better memory performance if you don't write into an consecutive array from multiple CPUs as the same time.

7:43 tomsw: Chousuke: ? but if you split a sequence in half & shuffle the halves separately, it won't be a fair shuffle

7:43 Holcxjo: tomsw: Nope, you'll need to do more work

7:43 tomsw: He was just commenting on my paralisability comment

7:45 tomsw: and the more I think about it, the less I am convinced one can improve it much with parallel processing

7:45 AWizzArd: cool would be if one could simply do (sort random collection) and it shuffles that stuff

7:56 tomsw: AWizzArd: trouble is that most sort algorithms assume they're sorting an ordered datatype - ie, two given items always have the same order. This won't be the case if your sort predicate is non-deterministic - and the combination won't guarantee a fair shuffle

7:56 * tomsw is very concerned about fairness today

7:58 achim_p: in some situations you could assign random values beforehand

7:58 ,(map val (sort-by key (zipmap (repeatedly rand) (range 10) )))

7:58 clojurebot: (4 7 9 8 3 5 1 6 0 2)

7:58 Holcxjo: shuffle is only O(n) right? Relying on sort (assuming it works as intended) is likely to get you into the O(n log n) teritory.

7:58 achim_p: Holcxjo: right

7:59 Holcxjo: Sounds like a silly tradeoff

7:59 achim_p: but tomsw's shuffle looks quadratic as well

7:59 remove-at is linear, i think

8:00 Holcxjo: Oh, yes that might be.

8:01 One should probably use vectors and swap elements -- that's meant to be (amortised) O(1), right?

8:02 tomsw: so copy the sequence into a vector, swap, copy it out again

8:02 AWizzArd: if the shuffeling is not a task which the computer needs to do for hours and hours, then the efficiency may not matter very much.

8:03 cemerick: Chouser: you did up a 2x2 of the various reference types (atoms, refs, vars, etc) -- where might that be?

8:03 Chouser: cemerick: http://clojure.googlegroups.com/web/clojure-conc.png

8:04 that's missing var and now future

8:04 * cemerick is so behind :-/

8:05 cemerick: or, :-(

8:06 rhickey: Chouser: while future and delay now both support deref, I don't consider them full references as they don't mutate

8:06 Holcxjo: More reliable than sort and still in the silly teritory would be to use be to use clojure.contrib.combinatorics's (permutations coll) -- pick a random numbe between 0 and (factorial (count coll)) and use that as an index into the collection of permutations...

8:07 Put I guess, contrib.lazy-seqs's random-permutation is the real answer...

8:07 cemerick: rhickey: thanks again for your rapid assistance a few days ago. Our entire codebase is now safely "ported" to HEAD.

8:07 rhickey: cemerick: that's great!

8:07 Holcxjo: (which "cheats" and used java.util.Collections/shuffle )

8:08 AWizzArd: Is using random-permutation then also cheating? ;)

8:10 Chouser: future .isDone mutates, but I guess that's not quite the same thing.

8:11 applicable: can someone writ the ycombinator in clojure?

8:12 rhickey: Chouser: isDone is not the cell itself

8:12 Chouser: applicable: like this? http://groups.google.com/group/clojure/browse_frm/thread/3259f09e08be4cfd/21f0e19fdce15ae9

8:13 rhickey: I'm running our of words to distinguish the indirection part from the mutable box part

8:14 Chouser: "isDone is not the reference"?

8:14 eh.

8:18 lisppaste8: AWizzArd pasted "Kent Pitmans implementation of the Y-Combinator, for applicable" at http://paste.lisp.org/display/75330

8:20 AWizzArd: rhickey: maybe short fantasy names can be used? (fub ...) (shunk ...) and so on?

8:20 "Let's shunk-fub this code..."

8:23 Holcxjo: When running out of names, using a different language is always a good choice. Classic Sanskrit is good as there won't be any name clashes with existing code...

8:24 .. readablity suffers a bit though.

8:26 leafw: switch to spanish -- second world language.

8:26 I meant, second language in the world.

8:26 Holcxjo: Right after Chinese?

8:27 leafw: yes.

8:27 Holcxjo: so, why not Chinese?

8:27 leafw: latin script.

8:28 not symbols.

8:30 Holcxjo: Ah yes, Java is still stuck in the 20th century and doesn't cope with Unicode identifiers, right?

8:31 Chouser: no, Clojure can handle unicode identifiers, but they're generally avoided by builtins.

8:32 cemerick: if you're on a mac, a lot of useful mathematical symbols are an easy shortcut away, which helps a lot

8:33 * cemerick can never remember how to enter useful symbols without pulling out the mouse in windows

8:37 Chousuke: heh

8:37 no lambda shortcut on this layout though ;(

8:38 wonder if clojurebot allows defmacros now.

8:38 ,(defmacro ? [& body] `(fn ~@body))

8:38 clojurebot: DENIED

8:38 Chousuke: :(

8:39 cemerick: Chouser: fwiw, it's easy to remap some keybinding to lambda on the mac using DefaultKeyBinding.dict (a simple plist mapping between keystrokes and what you'd like them to emit)

8:39 Chousuke: well, yeah

8:40 * Chousuke guesses cemerick is not using irssi.

8:40 AWizzArd: cemerick: even easier when you use the Neo layout instead of qwertz. There you have several greek letters available. "lambda" could be written as "??????" for example :)

8:41 cemerick: Chousuke: nope, I'm a simpleton :-)

8:44 Chousuke: When doing tabcompletion, irssi prefers people who were last seen speaking

8:44 one of those features you wouldn't think of at first, but make a whole lot of sense when you think about it.

8:49 leafw: Chousuke: irssi has a large club of fans.

8:49 Chousuke: irssi has a large club of fans.

8:49 detachable IRC non-browser bound. Like, reinventing water (and awesome)

9:11 lisppaste8: tomsw annotated #75328 with "untitled" at http://paste.lisp.org/display/75328#2

9:15 rsynnott: Chousuke: that feature can occasionally be terribly confusing

9:36 AWizzArd: ,(doc call-future)

9:36 clojurebot: java.lang.Exception: Unable to resolve var: call-future in this context

9:36 Chousuke: ,(doc future-call)

9:36 clojurebot: "([f]); Takes a function of no args and yields a future object that will invoke the function in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."

9:37 AWizzArd: Can one (await a-future)?

9:38 Chousuke: await is for agents

9:38 all you need to do is @afuture

9:39 AWizzArd: future-call will directly fire off the execution? Or will that future only run when I try to deref it?

9:40 Chousuke: AWizzArd: it'll start instantly.

9:41 it's a computation that will complete sometime in the future.

9:42 so you can start the computation, do other stuff and use the future result when you need it; if it isn't completed yet, it'll just block until it's done.

9:42 "easy" threading :)

9:42 AWizzArd: yes

10:31 Chouser: this stupid graph has me peeved. why can't I find better tools for this?

10:42 cemerick: Chouser: graph of?

10:45 Chouser: the class inheritence

10:45 it's just a directed graph, with the connections created programmatically.

10:45 cemerick: ah, yeah, stuff like that can be very painful

10:45 AWizzArd: strange that there are no Java tools yet, to visualize that

10:45 Chouser: graphviz dot is a fine 80% solution (or maybe 60%)

10:46 cemerick: of course, the real goods are in the last 5%

10:46 AWizzArd: there's lots of options, but none ever really do all that you want

10:46 Chouser: but the latest inheritence change (adding Counted) has pushed it over the edge, and the thing is now unreadable, and I'm simply failing to find a way to fix it.

10:47 cemerick: Chouser: do you have a draft of the new version? Maybe it's not really that bad...

10:47 Chouser: I think what I want is dot (or something like it) to produce an initial layout, and then be able to drag around nodes or groups of nodes manually

10:47 cemerick: http://chouser.n01se.net/misc/tmp.png

10:48 cemerick: if you can tell by looking at that chart what two things IPersistentSet implements, I'll publish this version.

10:49 anyway, that doesn't sound like a tall order, but apparently it is. :-P

10:50 cemerick: IPersistentCollection and Counted, I think :-D

10:50 Chouser: heh. yeah. very nice.

10:50 Chousuke: cemerick: you're good at guessing

10:50 cemerick: honestly, I've seen *much* worse

10:50 Chouser: but it needs to me useful, otherwise what's the point?

10:51 cemerick: Chousuke: :-) well, there are only so many pink lines, and the only other options was PersistentQueue, but that didn't have an arrow

10:51 Chouser: ,(parents clojure.lang.IPersistentSet)

10:51 clojurebot: #{clojure.lang.IPersistentCollection}

10:51 cemerick: don't know what to say to color-blind people, though

10:51 Chousuke: maybe it'd be better to have some kind of "badges" for the most common interfaes

10:52 and just tag other interfaces and classes with those badges.

10:52 Chouser: oo!

10:52 cemerick: Chouser: omnigraffle has *really* good tools for rearranging graphs "gently" -- so you could move stuff around as you like, and it tries to satisfy whatever other constraints you've set while disturbing your manual placements minimally

10:53 not sure what it has under its sleeve for data import, tho

10:53 Chouser: cemerick: yeah, that's usually the kicker.

10:53 there are the nice interactive tools, and then there are the ones with clean data import

10:54 I've been eyeing the idea of using xslt to tweak an inkscape svg file, but ... well... *sigh*

10:54 cemerick: Chouser: omnigraffle pro supports graphviz dot files, apparently: http://paco.to/blog/000040.html

10:55 I have OP, if you want me to give it a shot with the dot file you have

10:55 lisppaste8: Chouser pasted "latest graph.dot for cemerick" at http://paste.lisp.org/display/75338

11:04 Chouser: it looks like they're working on something called smyrna that may do what I want.

11:18 AWizzArd: rhickey: is there a plan for a lazy version of futures? One which only kicks of the execution of the future when the deref is made?

11:19 jbondeson: AWizzArd: but then it would immediately block your thread of execution

11:20 AWizzArd: why?

11:20 jbondeson: deref'ing a future blocks until the calculation is complete

11:20 AWizzArd: right

11:20 it would only block when the deref happens

11:20 jbondeson: so if it waited until a deref request you'd be blocked.

11:21 AWizzArd: but if it never happens then my other threads get more cpu time.

11:21 jbondeson: so it would act exactly like a lazy function evaluation.

11:21 AWizzArd: yes

11:21 ,(doc delay)

11:21 clojurebot: "([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force), and will cache the result and return it on all subsequent force calls"

11:22 jbondeson: i'm confused why you would use futures for that.

11:22 seems like you want a new object that implements deref that evaluates the function when you deref

11:23 Chousuke: that's delay :/

11:23 jbondeson: kinda, it's a thin wrapper over delay that makes it look like a regular reference

11:23 Chousuke: ,(let [a (delay (println "test") 1)] (println "test2") @a)

11:23 clojurebot: 1

11:24 test2 test

11:24 jbondeson: oh hey look at that

11:24 Chousuke: the funky print order is due to how clojurebot handles *out*

11:24 jbondeson: sooo, now i'm really confused why delay doesn't work for you AWizzArd

11:25 AWizzArd: jbondeson: before I write 3 minutes ago ,(doc delay) I did not know about the existance of delay.

11:25 cemerick: Chouser: so, OP will create a decent force-directed graph, but that loses all of the nice alignment of related items

11:26 AWizzArd: wrote

11:26 jbondeson: ah

11:27 Chousuke: hm

11:27 it's not like the lines in the graph need to be continuous, as longs as it's clear where they connect :)

11:28 -s

11:28 I have no idea how to do that with dot though :/

11:29 cemerick: I can post what OP produced, but I don't think it's an improvement...

11:30 Chouser: well, I posted this yesterday too, but it wasn't popular: http://chouser.n01se.net/misc/tmp2.png

11:30 danlarkin: hurts my eyes!

11:30 Chouser: but you can tell where the lines are going, and you can read the text.

11:31 all its missing is a certain aesthetic

11:31 Chousuke: I mean, why do you need lines at all

11:31 AWizzArd: jbondeson: is it new that you can (deref a-delay)?

11:32 Chousuke: I think UML has some notation for a "teleport" kind of thing :P

11:32 AWizzArd: I can not run your example, I have to use (force a)

11:32 Chousuke: AWizzArd: I think it was added with futures.

11:33 jbondeson: AWizzArd: with futures IDeref was added, so yeah, i think that's where it came in

11:34 i didn't even know you could do that, but you learn something new every day.

11:35 * rsynnott finds the continual change aspect of clojure a little disturbing

11:35 * danlarkin finds it encouraging

11:35 gnuvince: Is there an easy way to get the entire content of a file in a string with Clojure? (something (reader "/etc/passwd"))?

11:36 Chouser: slurp

11:36 jbondeson: love that name

11:36 Chouser: I must say I prefer slurp to spit

11:36 jwinter: ,(doc slurp)

11:36 clojurebot: "([f]); Reads the file named by f into a string and returns it."

11:36 rhickey: Chouser: spew?

11:36 gnuvince: Chouser: thanks

11:36 leafw: I find line-seq easier to use than slurp -- or rather, more useful.

11:37 gnuvince: Always forget about it

11:37 Chouser: hurl? expectorate? regurgitate?

11:37 write?

11:37 jwinter: leafw: how do you use line-seq?

11:40 cooldude127: does clojure have a way to extend the reader?

11:40 leafw: jwinter: http://github.com/acardona/xmms2-clj/blob/89ae9d125af9968fefcf7c31505c23000a29c0f4/xmms2.clj#L34

11:41 jwinter: just give a reader to line-seq.

11:41 jwinter: leafw: cool, thx

11:41 Chouser: cooldude127: like adding new reader macros? no.

11:42 cooldude127: Chouser: :( is it planned at some point?

11:43 Chouser: cooldude127: if you can figure out how to allow reader macros from different authors to be used at the same time, perhaps.

11:43 in other words, no.

11:43 shoover: cooldude127: regarding your complaint yesterday about Math functions, have you seen clojure.contrib.import-static?

11:44 fanda: Chouser: concerning creating graph of Clojure classes/interfaces...

11:44 one time I used yEd Graph Editor:

11:44 http://www.yworks.com/en/products_yed_about.html

11:44 all you need is to generate for example .gml file, import it and then use some layout from the menu

11:44 i guess it is more manual than graphviz, but it gives you more power...

11:45 AWizzArd: leafw: why not read-lines?

11:45 in duck-streams

11:45 cooldude127: shoover: no, but really i'm disappointed in clojure's not having it's own math functions, for instance ones that work on ratios too

11:45 like absolute value

11:46 and such

11:46 rsynnott: danlarkin: I'm very used to languages which haven't really changed in the last decade :)

11:46 jbondeson: the only thing you have to be careful about with read-lines is that if you don't consume the entire sequence the file doesn't close

11:47 Chouser: fanda: thanks for yED -- I'll look at it.

11:49 rsynnott: cooldude127: you could always write your own

11:50 p_l: danlarkin: The problem with changing languages is that sometimes you find this very useful piece of code, only to end with it not compiling because while it looks completely okay, someone changed the language since that time... <--- happened few times to me

11:51 danlarkin: p_l: yup, that'll happen

11:51 c'et la vie!

11:52 p_l: danlarkin: When 'if(!var)' stops working, people get angry :-)

11:52 jbondeson: you only really have to worry about that if you're providing other people with code, because you could always include a specific version of clojure in your jar you distribute.

11:52 Chousuke: At least Clojure still has a good excuse to change. :)

11:52 rsynnott: indeed

11:52 oh, I'm not complaining about it

11:53 it's just not at all what I'm used to

11:53 Holcxjo: Chouser: I had some luck with "mclimit=2500.0" in my .dot files -- improved the layout somewhat

11:53 cooldude127: rsynnott: i did, i was just disappointed that i had to

11:53 leafw: AWizzArd: didn't know about read-lines. But line-seq is lazy -- that alone is nice.

11:53 p_l: Also, I guess that with clojure one could use macros to provide "compatibility layer" :-)

11:54 jbondeson: leafw: read-lines is lazy too.

11:56 rsynnott: p_l: to run programs for revision X on revision Y, use THIS macro, for revison Z use THAT macro :)

11:56 could get messy

11:57 leafw: ,(doc read-lines)

11:57 clojurebot: java.lang.Exception: Unable to resolve var: read-lines in this context

11:57 leafw: aha. So read-lines is not in std clojure lib

11:57 didn't know why I hadn't come across it.

11:57 jbondeson: clojure.contrib.duck-streams

11:57 leafw: ,(doc line-seq)

11:57 clojurebot: "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."

11:58 jbondeson: you are responsible for teh reader you provide, read-lines will open the file for you and close it after you consume the sequence.

11:58 p_l: rsynnott: I envisioned something more like loading a jar which would use macros to redefine few things to emulate behaviour from a certain "version" (more like snapshot of language :) )

12:01 afk

12:01 Chousuke: jbondeson: what if you never consume it fully, though? :/

12:03 jbondeson: Chousuke: then it's not closed until the seq gets GCed.

12:03 if you're going to read the whole file it's good.

12:03 if you're not... well, i suppose you want something else.

12:06 it's just really handy when you know you're going to consume the entire file to not have to worry about the file reader object

12:09 technomancy: can someone explain to me why I can't call "read" on something I got from the "reader" function in duck-streams?

12:09 seems like if I have a reader, I should be able to read, no?

12:09 otherwise why call it a reader?

12:11 Chouser: 'read' needs a particular kind of reader, but it's name is based on lisp history.

12:11 cooldude127: read is the R in REPL

12:11 :)

12:12 technomancy: Chouser: couldn't it be made smart enough to turn a regular reader into a pushback reader?

12:13 * Chouser shrugs

12:15 technomancy: a pushbackreader just means that characters can get pushed back onto the stream?

12:15 Chouser: I think so

12:17 technomancy: it's a nit-picky thing, but it really bugs me to have to say (read (java.io.PushbackReader. (reader file)))

12:18 I suspect the problem with that is you'd have to turn read into a multimethod?

12:20 cooldude127: technomancy: you wouldn't have to, but it would be more elegant

12:20 wait is read implemented in clojure?

12:21 how could it be? you need a reader before you can do clojure

12:21 technomancy: cooldude127: it calls clojure.lang.LispReader

12:21 cooldude127: oh

12:22 technomancy: which I guess you could add a read method to that could perform the conversion?

12:22 and you wouldn't have to change any existing code

12:23 rsynnott: how are multimethods implemented for JVM, actually?

12:24 Chouser: rsynnott: clojure multimethods?

12:27 technomancy: I'll bring it up on the mailing list

12:43 scottj_: What's the idiomatic way to do cl's loop collecting?

12:45 rsynnott: Chouser: yep

12:45 Chouser: you need to build a new collection from an old one? only including non-nil things? (sorry don't know C:)

12:46 ayrnieu: scottj - for, filter, a function with a recursive (loop [accumulutor] ...)

12:46 rsynnott: I had the idea, though I may be wrong, that ABCL's poor CLOS performance was due to some problem in implementing clos multimethods in hava

12:46 technomancy: is there a slight performance hit when invoking multimethods vs regular functions?

12:46 Chouser: rsynnott: each defmethod is an object that has a map of dispatch values to fns

12:46 technomancy: yes

12:47 rsynnott: ah

12:48 Chouser: rsynnott: the multifn also keeps a cache mapping the dispatch fn's return value to the appropriate defmethod fn.

12:48 sorry, messed up the earlier statement. each *defmulti* is an object...

12:49 ayrnieu: rsynnott - it may just be a bad implementation. But there's some activity just last month, with someone getting Closette on ABCL http://article.gmane.org/gmane.editors.j.devel/2276 , and with this thread http://article.gmane.org/gmane.editors.j.devel/2258

12:50 Chouser: so the given dispatch fn is called for every call to the method, but the heirarchy computation is cached so will be just an extra map lookup

12:50 and I imagine all that gets in the way of hotspot efficiently inlining it, but I don't know that for sure.

12:51 rsynnott: ah, it has a MOP; cool

12:51 Chouser: http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/MultiFn.java

12:52 rsynnott: what's going on with the invokes, there?

12:52 is it an optimisation, or does java lack functions with arbitrary numbers of parameters?

12:53 oh, nevermind, found it :)

12:55 Chouser: well, I think Chousuke idea of badges was fantastic. So is this implementation decent? http://chouser.n01se.net/misc/tmp3.png

12:56 jbondeson: nice

12:56 gnuvince: Chouser: what's the lib to generate this?

12:57 Chouser: gnuvince: /tree/master

12:57 um

12:57 gnuvince: http://github.com/Chouser/clojure-classes

12:57 jbondeson: I take it Clojure Interface/Class vs. Java Interface/Class is anything in clojure.* and anything not?

12:57 Chouser: jbondeson: right

12:59 This doesn't include any of the nested classes.

12:59 there are many more ISeq types

13:04 jbondeson: aww, you hardcoded some of the mappings ;)

13:05 Chouser: colors, predicates, and one alias

13:05 and badges, now

13:10 lisppaste8: gnuvince pasted "Any way to prettify this?" at http://paste.lisp.org/display/75347

13:13 craigmcd: Anyone have a working example of :exposes-methods from gen-class?

13:16 Chouser: gnuvince: I don't think there's any point in avoiding 'count', is there?

13:16 (defn avg [coll] (/ (reduce + coll) (count coll)))

13:17 ayrnieu: (defn avg [coll] (/ (reduce + coll) (count coll))) ... too slow.

13:17 Chouser: :-)

13:17 brianh: man, just looked at that MultiFn java code. rhickey must've felt like a pirate after typing all of those args....;)

13:17 Chouser: brianh: ha!

13:17 technomancy: hehe

13:18 gnuvince: Oh right, count is O(1) for most data structures now

13:19 rhickey: that brings up a poll I wanted to do - what's the max number of fixed args you have in your Clojure code?

13:19 gnuvince: that O(1) count is not new, I've strived for it everywhere possible

13:20 ayrnieu: I see a (defn bifold [p f1 f2 acc1 acc2 coll] , but the average is probably 1 or 2.

13:20 gnuvince: rhickey: ah, I didn't know that.

13:20 danlarkin: rhickey: 8

13:21 gnuvince: 4 args max here.

13:21 technomancy: bonus points if you write a function to look through your codebase to determine the max arg count. =)

13:21 gnuvince: Maybe it should be mentioned here (http://clojure.org/api#count) that count is O(1).

13:22 rhickey: gnuvince: it's not universally

13:22 Chouser: gnuvince: only classes marked with a 1 here can count in O(1): http://chouser.n01se.net/misc/tmp3.png

13:23 rhickey: gnuvince: the new counted? pred will tell you

13:27 mattrepl: craigmcd: http://gist.github.com/62795

13:27 craigmcd: mattrepl: thanks

13:29 mattrepl: I see what I was doing wrong now: (.superUpdate this ...), not (superUpdate ...).

13:29 StartsWithK: lisppaste8: help

13:29 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

13:29 gnuvince: So any class that implements Counted *must* provide constant time count?

13:30 mattrepl: is that a hint? ;)

13:30 rhickey: gnuvince: yes

13:30 cooldude127: if a namespace is defined, is (ns blah) the same as (in-ns 'blah) ?

13:31 lisppaste8: StartsWithK pasted "Clojure Ant Task (like javac)" at http://paste.lisp.org/display/75350

13:32 * technomancy is writing Java code... never thought this would happen. =)

13:32 StartsWithK: you can use it like <clojurec srcdir='..' destdir='...'/>, it will find all .clj files and compile the, also if there is a error this one stops ant

13:33 technomancy: what's more amazing is that it's actually working on the first try

13:33 gnuvince: technomancy: you're not the only one

13:33 Chouser: cooldude127: no

13:33 cooldude127: Chouser: what's the difference?

13:33 Chouser: it doesn't look like it affects my :use's and stuff

13:34 Chouser: ns always 'refer's clojure.core, unless you modify via :refer-clojure

13:34 lisppaste8: tomsw pasted "Why doesn't the map work?" at http://paste.lisp.org/display/75351

13:34 tomsw: why isn't map doing anything when used inside a awt.Canvas' paint method?

13:35 Chouser: tomsw: map is lazy

13:35 tomsw: Chouser: is there an unlazy version?

13:35 Chouser: or must I use take or something?

13:36 Chouser: tomsw: you can wrap it in 'dorun', but you might find 'dotimes' or 'doseq' to be a better fit in this case.

13:36 cooldude127: Chouser: so if i don't care about what it does with :refer-clojure, they're essentially the same

13:36 Chouser: cooldude127: yes, but the namespace existing doesn't change anything

13:37 tomsw: Chouser: Think I better go and so some more reading. Thanks!

13:37 cooldude127: Chouser: wait so does (in-ns) create a namespace too?

13:38 if it doesn't exist?

13:38 Chouser: tomsw: looking at your code a bit more closely, wrapping dorun around your map may actually be the most convenient.

13:38 cooldude127: correct

13:39 cooldude127: Chouser: ok, got it. i'm using in-ns anyway, i thought that slime wasn't figuring that out right, but it is, so that's fine

13:39 Chouser: tomsw: or maybe (doseq [[img x y] (map vector imgs (range...) (range...))] (.drawImage ...))

13:42 rhickey: thanks for making small literal maps array-maps. that's pleasant.

13:44 rhickey: Chouser: you're welcome, ye, much better now that it's consistent

13:44 yes

13:49 alinpopa: good evening

13:49 have one fast q

13:50 time macro, is returning 10.492 msecs for instance

13:50 what this it means ?

13:50 10 milliseconds ?

13:50 ayrnieu: yes.

13:50 alinpopa: ok, thank you

13:51 the doc doesn't tell what is the unit returned

13:51 Macro

13:51 Evaluates expr and prints the time it took. Returns the value of

13:51 expr.

13:51 ,(doc time)

13:51 clojurebot: "([expr]); Evaluates expr and prints the time it took. Returns the value of expr."

13:52 alinpopa: 492 are ... microseconds ?

13:52 danlarkin: alinpopa: msecs is the unit :)

13:52 rsynnott: alinpopa: yep

13:52 alinpopa: yes danlarkin I noticed :D

13:52 seems to be too fast to be 10 mseconds that's why I asked

13:53 ,(time (count (list 1 2 3 4 5 6 7 8 9 10)))

13:53 clojurebot: 10

13:53 "Elapsed time: 0.165 msecs"

13:53 alinpopa: I got: "Elapsed time: 0.075 msecs"

13:53 so ... this seems it took how much ?

13:53 75 microsecs ?

13:54 ayrnieu: milliseconds.

13:54 You just asked, and I answered.

13:54 And then you *thanked* me.

13:54 alinpopa: :) yes, I did that

13:55 0.075 msecs = ? msecs ? microsecs ?

13:55 do you see my point now ?

13:56 nevermind, I got the idea

13:58 rsynnott: 0.075 milliseconds is 75 microseconds

13:59 lisppaste8: ayrnieu pasted "src/clj/clojure/core.clj:time" at http://paste.lisp.org/display/75353

13:59 tomsw: Chouser: just figured out if I have nested maps I need nested doruns...

13:59 ayrnieu: it seems like that ought to (doall ~expr)

14:00 technomancy: yay, first clojure patch submitted.

14:01 ayrnieu: ... to src/clj/clojure/core.clj:time ? That was fast!

14:01 technomancy: heh; no.

14:01 to clojure.lang.LispReader

14:01 cooldude127: technomancy: what was your patch?

14:02 technomancy: cooldude127: http://code.google.com/p/clojure/issues/detail?id=79&colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary

14:02 you can call read on any reader now, not just a PushbackReader

14:02 cooldude127: nice

14:04 * technomancy stabs synergy

14:05 cooldude127: synergy as in the kvm type thing?

14:05 te: synergy owns.

14:05 truly.

14:05 technomancy: cooldude127: yeah

14:05 cooldude127: fun

14:05 technomancy: I like it, but every now and then it turns my X server into "control is always on" mode

14:06 te: I wish synergy was easier to set up in impromptu situations

14:06 like if im in the library it would be nice to hit a button and have both screens

14:06 technomancy: te: mango lassi supposedly does that with zeroconf

14:07 but I haven't heard anything about that in a long time

14:07 cooldude127: ok i have some problems getting a (load) statement in my code to work

14:07 i'm splitting a namespace up into a couple files, so i'm using load kinda like the clojure.core code uses

14:07 but it can't find the file

14:08 p_l: te: Have you looked at Plan B operating system? :-)

14:08 cooldude127: ok something's wrong with my classpath

14:09 technomancy: do you know how i can add to the classpath while still using clojure-slime-config?

14:09 Raynes: Good day.

14:09 o.o

14:09 cooldude127: i tried a simple add-to-list, and it's not working. slime still loads with the original classpath

14:10 technomancy: cooldude127: add-to-list on swank-clojure-extra-classpaths?

14:10 did you kill your *inferior-lisp* buffer?

14:10 cooldude127: technomancy: yeah

14:10 yeah

14:11 technomancy: cooldude127: hrm; I'm not sure. you could use add-classpath, but that will get you in trouble

14:11 cooldude127: technomancy: i don't want to do that

14:12 there is no reason i shouldn't be able to configure this. let me restart emacs real quick

14:12 technomancy: ok restarting emacs made it change

14:12 the hell if i know why

14:13 p_l: technomancy: What problems are there with add-classpath?

14:13 technomancy: cooldude127: I haven't looked at swank's internals; it could be caching something

14:13 cooldude127: technomancy: it might be

14:13 technomancy: btw, is there any reason that clojure doesn

14:14 't get any pretty lambda/fn love?

14:14 god i hate that ' and RET are right next to each other

14:14 technomancy: p_l: apparently the JVM's classloader makes assumptions about having the full classpath upfront; it's very difficult and unreliable to work around that.

14:14 te: p_l: no I havent' looked at plan b

14:14 what is it?

14:14 technomancy: p_l: theoretically that shouldn't affect using add-classpath on clojure code, but people in here will still yell at you for it. =)

14:15 cooldude127: mostly because fn is already so short. =)

14:15 it would be easy to add though

14:15 te: p_l: this looks like Plan 9

14:15 mixed with Inferno-os

14:15 technomancy: te: plan b is plan 9 + 2

14:15 cooldude127: technomancy: i might just do that. the question is do i want the pretty f from the javascript stuff or a lambda

14:16 technomancy: cooldude127: yes. unicode does raise some difficult questions.

14:16 I'm confident you'll make the right choice.

14:16 p_l: te: It's Plan 9 with some apps to automate various things... Like entering a room and getting additional displays, room's sound system etc. as devices of your laptop :P

14:16 cooldude127: that's cool as shit!

14:16 technomancy: lol

14:17 te: p_l: dude wtf this is my idea

14:17 I really love the idea of physically discrete aspects of my computing environment

14:17 p_l: technomancy: Hmmm. Yell at me you say... Funny that I was just thinking about making something like Haskell's Cabal or RubyGems, which you could use to download/compile/load libraries (and which might need add-classpath)

14:17 te: i find when i have my iphone hooked up to my laptop i am confined to doing just one thing in that space, and i like that

14:18 p_l: te: They're currently working on new, Inferno based system with similar goals

14:18 technomancy: p_l: I think such a thing is an eventual necessity.

14:18 te: i was thinking it might be cool to have 5-10 of those sort of interfaces, small screens, discrete computing environments

14:18 tha tbasically provide a ubiquitous interface

14:18 technomancy: p_l: but I'm not convinced there are currently enough libs to justify it.

14:18 te: p_l: i did the google summer of code for inferno-os

14:18 it's sad that inferno gets no attention whatsoever

14:18 p_l: technomancy: Java's CLASSPATH is annoying me enough :)

14:18 te: Limbo could have been the next Java

14:19 err the /first/ Java

14:19 rsynnott: p_l: java's classpath is very, very annoying

14:19 te: p_l: technomancy: I have class, but I wish I could stay and chat

14:19 technomancy: te: I'll be around. =)

14:20 * rsynnott had a run-in with maven, which I'd never used before, while attempting to use clojure from within Jetty

14:20 te: I love this damned channel -- plenty of brave souls who aren't afraid of new ideas

14:20 rsynnott: maven does things with the classpath, so you have to mess around a bit to get it to work properly

14:20 technomancy: p_l: right now the solution to the packaging problem is just "stick everything in contrib!"

14:20 which is awesome

14:20 te: so many programmers i meet are of the "oh i dont know about that, isnt that just some new fad language" cloth

14:20 technomancy: but can't last forever

14:20 te: p_l: are you working on plan b at all?

14:20 rsynnott: (I'm writing a comet app in clojure; jetty has decent comet server plugin)

14:21 p_l: te: Not now, but I did setup few Plan9 installs in past, for experiments

14:21 I'm also lurking on 9fans

14:21 te: Yeah I'm in there as well

14:21 some of the guys on that list just dominate

14:21 there is such a vast expanse of information and work thats been done its hard to catch up on it

14:22 cooldude127: technomancy: shit i don't think this is good. every defn turned into de?

14:22 te: i had that problem with the google summer of code for inferno

14:22 technomancy: hehe

14:22 te: you basically need to learn the history of computing to code in Limbo

14:22 technomancy: cooldude127: use (fn instead of fn

14:22 rsynnott: it's a shame plan9 didn't work out, really

14:22 p_l: interesting enough, tommorrow is organisational meeting for Computing Society of my Uni. I was wondering of making a set of presentations about various less-known but nice-to-know languages/OSes

14:22 cooldude127: technomancy: lol what if i like this ?

14:22 te: agreed -- although plan9 is kind of a 3rd party candidate, many of its ideas are being filtered intlo Linux

14:22 Chouser: plan9's not open/free, is it? I know it wasn't early on.

14:22 te: It is

14:23 technomancy: cooldude127: I won't question your Alternative Life Choices.

14:23 p_l: Chouser: Now it is

14:23 te: inferno-os was 1million for a license, now its free

14:23 cooldude127: technomancy: i'm gonna fix it, it's too close to a regular def

14:23 te: id like to buy the inferno developer pack from vitanuova

14:23 i hear it comes with some cool tools

14:23 Chouser: if it had been free from the beginning, things might be very different now.

14:23 te: Chouser: there's still time

14:23 technomancy: the plan9 stuff that got rolled into wmii was really intriguing

14:24 te: 15million lines of code to run Gnome isn't exactly what I'd call efficient

14:24 cooldude127: technomancy: ok i broke it. no more font-lock

14:24 p_l: Chouser: If Research Unix was more widespread, we might never had to work with BSD sockets :D

14:24 te: Plan9 is still the future

14:24 rsynnott: though I don't think many of Bell Labs' research projects have ever turned directly into real products

14:24 te: ^^The transistor?

14:24 rsynnott: they pump money into something for a decade or so, then someone else canibalises it, seems to be the way it goes

14:24 te: ;)

14:24 Bell doesn't really do that kind of research anymore

14:24 it used to be /the/ place for cutting edge research

14:24 technomancy: Chouser: you could say that about a lot of things... anything that was a good idea in the 80's basically. =)

14:24 danlarkin: rsynnott: C!?! unix?

14:25 te: now its a relic

14:25 technomancy: CL, smalltalk

14:25 p_l: rsynnott: C, Unix, Plan 9 and Inferno all got commercial use :)

14:25 te: I wrote a distributed synthesizer in Limbo

14:25 technomancy: rsynnott: sounds like Xerox

14:25 rsynnott: te: they still do some interesting work

14:25 cooldude127: technomancy: how can i make this regexp "(?\\(fn\\>\\)" match (fn instead of fn

14:25 te: i had an orchestra of 386 computers

14:25 err 7, 386arch computers

14:26 all passing around their data

14:26 * rsynnott nearly ended up doing a research internship for them working on an optimising compiler for VHDL when I was in college

14:26 Chouser: cooldude127: yikes, is that an emacs regex?

14:26 technomancy: cooldude127: remove the question mark, I guess

14:26 cooldude127: Chouser: yes

14:26 technomancy: Chouser: shield your eyes!

14:26 Chouser: indeed. I think I'll go do something else now...

14:26 rsynnott: I say nearly, because by the time they actually got back to me and offered it to me, I had been working for someone else for a month

14:26 cooldude127: technomancy: perfect

14:26 technomancy: you gotta give them props for making parens literal though; it's great for working with lisp.

14:27 rsynnott: (they're not very efficient. They had to clear all hiring, including internships, in their Dublin facility through their headquarters in New Jersey)

14:28 p_l: rsynnott: management tends to be a PITA...

14:28 rsynnott: then, ridiculously, they got back to me the next year offering me the same position, so I said okay

14:29 and then heard back from them in August, which was three months later than they said, and far too late

14:30 (considering that anyone remotely suitable for their internships will be working during the summer anyway, you have to wonder if they ever manage to fill them at all)

14:40 hiredman: clojurebot: latest?

14:40 clojurebot: latest is 1276

14:40 hiredman: svn rev 1276

14:41 clojurebot: well?

14:41 clojurebot: Huh?

14:58 applicable: i want clojure on its own VM or compilable to binaries

14:59 with its own webserver

14:59 p_l: applicable: GCJ?

14:59 applicable: gcj?

15:00 hiredman: applicable: you don't want the jvm?

15:00 is that what you are saying?

15:02 clojure is closely tied to the jvm and this integration provides a lot of its greatest strengths, clojure minus the jvm would not be clojure

15:02 p_l: applicable: GCJ is a GNU Java Compiler that can produce native executables (or so I heard)

15:07 personally, I'd be wary of it

15:07 applicable: canit it have its own vm like python?

15:08 jbondeson: what's the difference between having it's own vm and using the jvm (other than a whole mess more work)

15:08 applicable: isnt there an easy automatic way to compile all the way to a jar?

15:08 jbondeson: you can go directly to a jar

15:08 all you need to use is ant

15:09 applicable: i hate ant, javas tools are all so verbose and donkish

15:09 jbondeson: if you look at the build.xml file with clojure you can easily adapt it to compile your own jar

15:10 p_l: applicable: Isn't that kind of defeating the purpose of removing JVM? There are though slightly different VMs that run/might run Clojure: Dalvik? (Android's VM), IKVM (.NET) etc.

15:11 technomancy: applicable: ant is pretty silly; you could try lancet.

15:11 clojurebot: lancet?

15:11 clojurebot: lancet is a build system that works with ant written as an example for the Programming Clojure book.

15:11 jbondeson: lancet is just a clojure layer on top of ant...

15:11 i mean, sure it's less xml-y

15:11 technomancy: yeah, but you don't have to greenspun

15:11 walters: it's not really hard to build jars without ant

15:12 jbondeson: my buil.xml is all of 38 lines...

15:12 walters: jar is just a slight variation of zip, you can run "jar" as a subprocess from make easily enough, pass it the files you want in it, done

15:12 technomancy: jbondeson: every time you write a line of executable XML, a little part of you dies inside.

15:13 jbondeson: technomancy: XML is like violence, if it doesn't work use more.

15:13 ;)

15:13 albino: not even a little part, a big huge part

15:13 forest: maven is also very nice tool

15:13 especially for large projects

15:13 jbondeson: i'm sorry, but xml has its uses, and ant's xml is hardly verbose

15:15 heck, i have a build.xml that embeds the contents of other jars into mine and it's still only 58 lines, hardly a problem to write.

15:15 * hiredman chases a classcast exception that just popped up out of nowhere

15:16 gnuvince: Did something change with regards to type hints recently? My project is suddenly giving me reflection warnings and it running nearly 100x slower than it did two days ago

15:16 hiredman: ouch

15:17 jbondeson: gnuvince: main branch?

15:17 gnuvince: Yes.

15:18 jbondeson: latest rev?

15:18 gnuvince: Yes

15:18 jbondeson: monday the warn option was added...

15:19 do you use pmap heavily?

15:20 gnuvince: Not at all.

15:21 technomancy: jbondeson: wouldn't you rather write Real Code though?

15:21 jbondeson: gnuvince: lots of multimethod calls?

15:21 technomancy: yes, but ant is write once, run foreva'

15:22 technomancy: and lancet is just a thing vaneer over the top of ant, so i'd rather just use ant.

15:22 gnuvince: jbondeson: yes.

15:22 jbondeson: gnuvince: rev 1262 was a patch to the multimethod system

15:23 i would try backing to 1261 and see if that is it.

15:23 if that is a huge speed slowdown it may need a patch

15:23 lisppaste8: gnuvince pasted "New slowness" at http://paste.lisp.org/display/75360

15:26 jbondeson: try 1261 vs 1262 if you could...

15:26 gnuvince: jbondeson: nearly identical

15:27 jbondeson: fast?

15:27 gnuvince: faster

15:27 jbondeson: hmmmm

15:27 so it's not that.

15:27 gnuvince: I'm updating one rev at a time

15:27 up to r1265 now

15:27 jbondeson: only other big one is the Counted changes that Chouser made

15:27 1268

15:28 gnuvince: Still fine at 1268

15:29 Oh wait

15:29 I'm ultra stupid

15:29 duh

15:29 I forgot to run ant

15:29 * gnuvince smacks himself in the head

15:29 jbondeson: hahaha

15:29 gnuvince: Let's start this again

15:31 jbondeson: i was wondering how you were pulling-comiling-running those so fast.

15:31 +p

15:31 gnuvince: OK, it's not r1262

15:32 jbondeson: i think 1268 is you next possible suspect

15:33 technomancy: gnuvince: tried git bisect?

15:33 gnuvince: technomancy: svn my friend

15:34 technomancy: gnuvince: you can give git bisect a command to run to validate a revision, and it can automatically binary search to find the commit that caused the breakage. it's badass.

15:34 jbondeson: technomancy: this isn't really a "break" just a slowdown

15:34 though

15:34 technomancy: jbondeson: well, you could return an error code if a certain operation takes too long in your checker script

15:35 jbondeson: true

15:35 technomancy: takes all the guesswork out of finding regressions like this

15:35 I get excited every time I use it.

15:36 gnuvince: I wish I could use it

15:36 but I don't think svn ahs this

15:36 technomancy: gnuvince: it works fine with git-svn

15:36 gnuvince: The time it would take to run git-svn, I'll have found the slow revision by then :)

15:37 ding ding ding!

15:37 1268

15:37 technomancy: true

15:37 jbondeson: beat Chouser

15:37 Chouser: :-(

15:37 what's the code?

15:37 oh, I see it

15:38 gnuvince: Oh wait

15:38 1267 might have the problem too

15:39 jbondeson: 1267 was my patch for proxy, unless you're creating a million proxies...

15:39 gnuvince: No proxies in there.

15:40 Chouser: you get extra reflection as of 1268?

15:40 gnuvince: Chouser: earlier than that it seems

15:40 I'm trying to narrow it down

15:40 r1264 is fine; I get the extra warnings starting at r1265

15:41 p_l: hmmm.... is there any elisp code for integrating JDE and Clojure? NetBeans is a little unwieldy in places (read: Java & XMonad don't go well together), but I don't want to lose completion of Java objects...

15:41 jbondeson: that's odd

15:41 gnuvince: ,r1265

15:41 clojurebot: java.lang.Exception: Unable to resolve symbol: r1265 in this context

15:41 gnuvince: svn r1265

15:41 clojurebot: svn 1265

15:41 clojurebot: svn is http://clojure.googlecode.com/svn/trunk/

15:41 gnuvince: Not super useful

15:41 hiredman: svn rev 1265

15:41 Chouser: clojurebot: rev 1265

15:41 clojurebot: Titim gan �ir� ort.

15:41 hiredman: *sigh*

15:42 gnuvince: r1265 | richhickey | 2009-02-10 12:24:20 -0500 (Tue, 10 Feb 2009) | 1 line

15:42 Changed paths: M /trunk/src/clj/clojure/core.clj

15:42 added inlining on remaining coercions

15:42 jbondeson: it's the inlining

15:42 Chouser: gnuvince: oh, this is that tortured bit of coersion we were messing with before, isn'tit.

15:42 jbondeson: do you use boolean, char, byte or short?

15:43 technomancy: p_l: I haven't heard of anyone using tho two together unfortunately

15:43 gnuvince: jbondeson: byte *and* char

15:43 jbondeson: ah

15:43 gnuvince: jbondeson: I'll give you the link

15:43 http://github.com/gnuvince/clj-starcraft/blob/3d8cd9b36728eb43b32c4c3d5c88d08898e8a916/starcraft/replay/parse.clj#L14

15:43 get-byte and get-short are the ones affected.

15:44 p_l: technomancy: Well, I'll try to set something together. Java's library is a little too big to use without autocomplete (and too verbose)

15:45 gnuvince: Chouser: yes, it is.

15:46 clojurebot: svn rev 1265; added inlining on remaining coercions

15:46 hiredman: clojurebot: fool

15:46 clojurebot: No entiendo

15:46 albino: starcraft replay files, this sounds awesome

15:47 hiredman: weird

15:47 I was getting stackoverflow when derefing a ref

15:47 jbondeson: oh

15:47 gnuvince: So... what can I do?

15:47 File a bug report?

15:48 Or is there a new way to use short and byte?

15:48 jbondeson: the RT cast functions are casting from Object -> Number -> Value

15:48 char does an instanceOf

15:48 char is what's killing you.

15:48 Chouser: no, it's the reflection that kills

15:49 p_l: technomancy: Apparently someone managed to make it possible without JDE, writing some clojure code to use Java Reflection API :)

15:49 gnuvince: I'm enclined to agree with Chouser; last time this program was slow, he helped me get the type hints right and it sped the application significantly.

15:49 Chouser: I mean, I'm sure avoiding an instanceOf would help too, but the reflection always hurts more than almost anything else.

15:50 jbondeson: gnuvince: for now you can just do (. x (byteValue))

15:52 Chouser: does casting in Java use reflection?

15:52 gnuvince: jbondeson: same problem, Clojure complains that byteValue cannot be resolved.

15:52 jbondeson: hmmm.

15:53 technomancy: p_l: if I find myself unable to avoid writing Java in the future I may be interested in helping w/ that

15:53 jbondeson: sorry

15:53 Chouser: jbondeson: by reflection I mean what Clojure is warning about. Specifically it's failing, at compile time, to choose exactly one method to call, so it produces code that checks at runtime.

15:54 so it's at the clojure/java boundary

15:54 jbondeson: interesting.

15:55 gnuvince: How should I proceed? Write up a summary of the problem, post it on the mailing list and wait until Rich says it's okay to add it to the list of issues on the tracker?

15:55 jbondeson: the weird thing is that the byteCast and shortCast only take objects, and everything should be able to be boxed in Java, correct?

15:57 i come from .net land, so my java knowledge is non-existent.

15:57 Chouser: gnuvince: probably. get-short and get-byte each stand alone to produce the warning. post those with the needed import line, and you should get some response

15:58 gnuvince: Chouser: ok

16:12 Chouser: gnuvince: that's a tough nut to crack.

16:12 I can't figure out how to get the byte to hint either as a primitive int or as an Object.

16:13 (defn get-byte

16:13 [#^ByteBuffer buf]

16:13 (let [x (int (.get buf))

16:13 y 0xff]

16:13 sorry

16:13 ...except to use (int ...) which itself requires reflecton.

16:15 gnuvince: Chouser: I'm almost done with my post

16:17 http://groups.google.com/group/clojure/browse_frm/thread/53bcf20ff17b73ed#

16:20 Chouser: well, I just found a way to avoid reflection, but it may still be slower than what you had working before.

16:20 gnuvince: I'll report the problem

16:20 I'd rather we have a real solution than a workaround.

16:20 Chouser: yep

16:20 gnuvince: We're not PHP

16:20 Chouser: :-)

16:21 lisppaste8: Chouser pasted "workaround for gnuvince" at http://paste.lisp.org/display/75363

16:22 Chouser: bouncing the byte/short through Box gets you an Object hint, so that the compiler can pick the and(Object,Object) method.

16:22 gnuvince: OK

16:23 jbondeson: seems like creating a function to do the bit-and that takes a Byte also works

16:24 Chouser: ah, disallowing the inline form. that makes sense.

16:25 yeah, that's better than mine.

16:26 technomancy: gnuvince: I'm curious: what does replaying a starcraft file look like?

16:26 jbondeson: found one more way

16:26 well, really it's the same way, but without a separate function

16:26 technomancy: gnuvince: I mean, are you visualizing anything, or is it just "this SCV went to this position", "This ultralisk attacked a Marine", etc.

16:27 Chouser: (#'bit-and (.get (ByteBuffer/allocate 100)) 0xff)

16:27 gnuvince: technomancy: It's a big binary string packed in a weird format (for which unpacker libs exist in C and Java, fortunately)

16:27 lisppaste8: jbondeson pasted "workaround 2" at http://paste.lisp.org/display/75364

16:27 gnuvince: technomancy: it's just the commands given by the players. I imagine that given the same input, Starcraft does the same thing (including glitches), so they just need to record what the players did.

16:28 technomancy: gotcha

16:28 gnuvince: technomancy: http://github.com/gnuvince/clj-starcraft/blob/3d8cd9b36728eb43b32c4c3d5c88d08898e8a916/starcraft/replay/actions.clj

16:28 technomancy: these are the known actions

16:29 Isn't it possible simply deactivate the inlining form?

16:29 applicable: if i have a .java file and want to use it form clojure, what do i ahve to do? first compile then make a jar out of it?

16:30 technomancy: applicable: yeah

16:30 Chouser: gnuvince: how? #' does it, but how else?

16:30 technomancy: well, you might not need to make a jar out of it, but it's probably better if you do

16:30 gnuvince: Chouser: just wondering

16:32 lisppaste8: Chouser annotated #75363 with "slightly less ugly workaround" at http://paste.lisp.org/display/75363#1

16:32 Chouser: I would expect that to match the speeds you were getting before.

16:33 best would be if there were bit-and methods for byte and short, then you could just hint your constants and you'd get unboxed speed.

16:34 gnuvince: Chouser: yeah, that gives about the same performance as before.

16:35 Well, I need to leave. That math course is not gonna complete itself, unfortunately :(

16:35 Later

16:35 Chouser: ciao

16:40 applicable: can a .zip file be import from clojure? ie is a .zip thr same a s a .jar?

16:42 hmm i tired rto jar -c org (a dir) and it went nuts and started beeping

16:43 technomancy: sweet, mire made the github highscore list

16:45 jbondeson: ok, that trouble shooting was a lot more fun than my real job. quick someone else have problems

16:47 technomancy: wow... there are only two libraries on the first five pages of github clojure projects that are more than three months old.

16:49 Chouser: jbondeson: I relate.

16:49 WizardofWestmarc: jbondeson: dude, vb6. Of COURSE it's more fun :P

16:50 jbondeson: worse, fixing others build errors

16:50 WizardofWestmarc: ah still dealing with the build retardation? Awesome

16:51 danlarkin: technomancy: what's the github highscore list?

16:52 technomancy: danlarkin: http://github.com/languages/Clojure

16:52 "Most Watched This Week"

16:52 danlarkin: sweet

16:53 WizardofWestmarc: Ring hit first in clojure? Huh. Not surprised Programming Clojure's is #2 though

16:55 ...Ring is most forked too? double huh

17:05 applicable: so can a .zip-file be used as a package?

17:05 jwinter: Where are the backtick, ~, and ~@ operators mentioned in the docs?

17:05 applicable: or a .java file can never be accessed form clojure+ it has to be compiled ot .class(i suppose9?

17:05 jwinter: I didn't see them in macros secion.

17:05 ayrnieu: applicable - yes, it has to be compiled.

17:06 Chouser: jwinter: http://clojure.org/reader under Syntax-quote

17:07 jwinter: Chouser: thx

17:11 applicable: me clojure should run on pythons vm instead

17:11 cooldude127: NOOOOO

17:11 applicable: everything java makes me want to kill myself

17:11 p_l: ...

17:12 Chouser: applicable: I had similar reactions the first few moneths trying to get comfortable with clojure.

17:12 p_l: applicable: there's little sense in making something target python vm... unless you mean the other Python, which is a compiler :P

17:13 kotarak: And to improve concurrency we get the global lock back.

17:14 danlarkin: long live the GIL

17:14 applicable: long live haskell!

17:19 scottj_: When I get an error in clojure+slime, it appears that the backtrace is pretty much useless because there's so much swank stuff in there I can't actually see my functions. Am I missing something?

17:20 Chousuke: the python VM is not much compared to the JVM though :/

17:20 technomancy: scottj_: the non-slime backtraces are pretty messy too. =\

17:20 scottj_: I've been meaning to check out the clj-backtrace library; it's supposed to clean things up

17:24 scottj_: technomancy: do you know if it works with slime or just plain repl?

17:26 Chouser: scottj_: I think there's a keystroke to see the next the deeper 'cause'. are you aware of it?

17:30 scottj_: Chouser: nope

17:31 Chouser: I don't use slime, but my understanding is that some kind of menu pops up and there's an option for the next 'cause'. Often the one you want is the second or last, not the first.

17:31 danlarkin: scottj_: In my configuration (which is whatever aquamacs set up for me) I can press "1" to see the cause

17:31 technomancy: Chouser is right

17:33 clojurebot: svn rev 1277; [lazy] only coerce LazySeq to seq in analyze, fixing evaluation of ()

17:37 scottj_: Chouser: danlarkin, thanks, "1"/cause makes the backtrace a more manageable.

17:37 I still long for a clojure debugger that's as easy to understand and use as a smalltalk debugger :)

17:38 technomancy: scottj_: you misspelled Object Browser.

17:38 clojurebot: svn rev 1278; fixed distinct nil handling

17:43 cooldude127: scottj_: i've actually been using smalltalk lately, and that debugger is FANTASTIC

17:43 Chouser: lazy-cons is used quite a lot in contrib.

17:50 rhickey: any plans for allowing code to (temporiarily) work with either trunk or lazy?

17:51 rhickey: Chouser: not sure what you mean by that

17:51 Chouser: I'm trying to fix up some things in contrib, but would like to provide two defn for some functions, based on which branch is trying to run it.

17:52 (if (resolve 'lazy-cons) (defn foo...) (defn foo...))

17:52 rhickey: Chouser: hmmm... what do you need from lazy/trunk to support that?

17:52 Chouser: but that doesn't work. I'm just wondering if it's something you've thought about.

17:53 if you haven't, i'll think about it and get back to you. :-)

17:53 rhickey: ok

17:53 the issue doesn't really come up for core

17:54 Chouser: right

17:54 but will for any lib, at least for a while.

17:58 ok, that was easy. (defmacro only-when [s x] (when (resolve s) x))

17:58 (only-when lazy-cons (defn foo ...))

17:58 (only-when lazy-seq (defn foo ...))

18:11 in trunk, (concat) returns nil, in lazy it returns ()

18:13 rhickey: Chouser: well, that's the key difference between the branches

18:13 concat et al no longer return seq/nil

18:15 Chouser: well, that seems to suggest I should feel silly for bringing it up. give me a sec and I probably will...

18:15 rhickey: also note that the () is just a print representation:

18:15 user=> (class (concat))

18:15 clojure.core$concat__3081$fn__3083

18:15 Chouser: yeah, did exactly that.

18:16 it's still not clicking though

18:16 rhickey: that's what I need feedback on - hpw much code depends on sequence fns returning seq/nil

18:17 * Chouser looks at the lazy-seq macro for the first time.

18:17 * rhickey waits...

18:18 * Chouser is stunned, and goes to look at core_print.clj

18:18 rhickey: :)

18:20 user=> (sequence? (concat))

18:20 true

18:20 that's the only promise made by the sequence fns

18:22 Chouser: I thought I understood all this, but I'm not yet getting how the code describes that behavior.

18:22 gotta go, bbl.

18:53 technomancy: cooldude127: have you thought about a more interesting name for your date library?

18:53 cooldude127: no i have not

18:55 technomancy: how about "chrono"?

19:04 cooldude127: that's a pretty good name

19:07 danlarkin: how about clojure.contrib.date

19:08 technomancy: bland.

19:08 danlarkin: :)

19:08 cooldude127: danlarkin: plus that's what it is right now :)

19:08 danlarkin: oh... well good!

19:08 cooldude127: haha

19:08 technomancy: well... not really; it's not part of contrib yet

19:09 cooldude127: true

19:53 danlarkin: uh oh! circular dependancy... this /is/ annoying

19:55 durka42: circular dependencies are bad...

19:58 danlarkin: represent calls invoke-templattag and invoke-templatetag calls represent :'(

19:59 and that's fine if they live in the same file because I can (declare represent) but it's a problem if I want to separate them

20:01 technomancy: danlarkin: every time I run into that I get annoyed and then start to wonder if I should really be annoyed or if it's just a sign I shouldn't be trying to do that in the first place.

20:02 danlarkin: Hurumph

20:03 technomancy: haven't been convinced either way yet though.

20:03 danlarkin: not sure what I should do differently, they definitely need to call eachother, but they don't really belong in the same file

20:06 durka42: could you trampoline them?

20:06 Chouser: I don't think that would help.

20:07 danlarkin: durka42: already am :)

20:07 cp2: so, i was just given an "emacs vps"

20:07 see http://www.informatimago.com/linux/emacs-on-user-mode-linux.html

20:08 quite humorous :)

20:09 technomancy: cp2: I've done the shell version

20:09 cp2: yeah, this is full blown though

20:09 technomancy: once they get webkit embedded, I'll be all over that. =)

20:17 danlarkin: maybe there could be some sort of cross-namespace declare form

20:18 Chouser: do they belong together in a 3rd file?

20:18 on the other hand, you're sure you need more than one file?

20:38 danlarkin: Chouser: no, they don't /need/ to be in separate files, but they should be -- they're doing different types of things

20:41 trying to figure out maybe a 3rd file solution

20:46 gnuvince_: Anybody good in calculus?

20:46 Or just decent will probably do

20:47 cooldude127: gnuvince_: i'm decent :)

20:47 gnuvince_: college student at ga tech here, what you need?

20:49 gnuvince_: cooldude127: moral support mainly

20:49 And some informations.

20:49 cooldude127: gnuvince_: ok

20:50 gnuvince_: I will preface by saying that I am not good at maths, that I am following a correspondance class (access to the teacher is nigh impossible) and that I am taking the class in French, so I may not know all the terms.

20:50 cooldude127: lol ok

20:50 jbondeson: that's a whole lot of caveats ;)

20:51 gnuvince_: First, here's a very general question: what's the point of a derivative? They suggest in the book that it is used to find the instantenous speed of an object, but why can't we just input the time into the speed function and get the result?

20:51 cooldude127: gnuvince_: what if you don't have a speed function?

20:51 gnuvince_: the derivative will find a speed function

20:51 gnuvince_: cooldude127: In this particular case, I have one; v(t) = -5t^2 + 10t.

20:51 Why couldn't I just put in the time and get the result?

20:52 cooldude127: gnuvince_: that's exactly what you would do

20:52 p_l: Looks like I'm starting to get some rudimentary library organization for Clojure :)

20:52 cooldude127: unless you're interested in acceleration

20:52 gnuvince_: derivative of v(t) will give you acceleration

20:52 jbondeson: derivatives measure the rate of change of a function.

20:52 cooldude127: exactly

20:53 it will give you the slope of a line that is tangent to a point on a curve

20:53 gnuvince_: The first question with this function is "At the beginning of the experiment, what is the speed of the object?"

20:53 cooldude127: gnuvince_: v(0)

20:53 gnuvince_: I figure 0, but I fear I may be way off track here.

20:54 jbondeson: speed or velocity?

20:54 p_l: gnuvince_: first derivative of a function gives you current "angle". Thus you can use it to analyze whether the function at this point is flat (d(f(x)) = 0), rising, or going down... Second derivative can be used to check for how the slope is shaped (i.e. is the rate of change more and more steep or getting flatter or no change) etc.

20:54 jbondeson: cause tecnically speed is the absolute value of velocity

20:55 danlarkin: oh god! make the calculus go away! I thought I left this in my past

20:55 cooldude127: gnuvince_: with your given velocity function, v(0)=0, so yes 0

20:55 * p_l loved derivatives

20:55 * jbondeson beats danlarkin with an integral

20:55 jbondeson: (integrals are easier to hold than derivatives)

20:55 gnuvince_: Oh this is bad...

20:55 * cooldude127 beats jbondeson with a double integral

20:55 gnuvince_: I'm afraid I'm not gonna make it through this class

20:55 p_l: pity that they removed integration from HS math curriculum before I entered my last two years...

20:56 jbondeson: I always assumed that integration is harder :)

20:56 cooldude127: it is

20:56 * p_l needs to pick integration sometime

20:56 cooldude127: but integral signs are more weapon shaped

20:57 gnuvince_: ok

20:57 jbondeson: integration is only tough when you start throwing in non-polynomials, then you just start reaching for the integration tables.

20:57 gnuvince_: Here's an exercise I'm working on, and I can't get to the final solution: http://mathbin.net/5831

20:57 * durka42 wonders whether the terrible calculus pickup lines work in french

20:57 gnuvince_: Could anyone hint me to my next logical step?

20:57 jbondeson: god bless LaTeX

20:58 gnuvince_: durka42: what is it?

20:58 durka42: "baby, i wish i were your derivative so i could lie tangent to all your curves" or something along those lines... i told you it was terrible

20:58 jbondeson: which problem are you working on, there are a lot of functions there

20:58 p_l: since we started mixing math and love... http://xkcd.com/55/

20:59 jbondeson: or is that your work

20:59 durka42: gnuvince_: what are you working towards, just the derivative of f(x)?

20:59 gnuvince_: jbondeson: it's my development. I need to find the derivative of f(x) (at the top) and the next lines are the steps I took so far

20:59 jbondeson: ah

20:59 cooldude127: gnuvince_: i think you've pretty much found it

20:59 durka42: i think you've found it, haven't you

20:59 you could simplify a little if you wanted to

20:59 cooldude127: gnuvince_: maybe could be simplified slightly, but not much

20:59 durka42: damnit!

21:00 gnuvince_: The answer is apparently: 2(6x^2 + 1)^3(54x^2 - 192x + 1)

21:00 But I don't know how to get there.

21:01 jbondeson: you can pull out the (6x^2 + 1)^3 from both terms

21:01 along with the 2

21:01 cooldude127: gnuvince_: what jbondeson said

21:01 jbondeson: also use the & = & to align your equals signs =P

21:02 gnuvince_: jbondeson: thanks for the help and for the tip :)

21:02 I'll try it out

21:02 jbondeson: after you factor out you cna then simplify

21:02 you had all the hard parts done

21:02 cooldude127: i remember the good old days of derivatives and integrals. now i'm stuck with matrices and vectors

21:02 jbondeson: linear algebra?

21:02 cooldude127: jbondeson: yes

21:03 jbondeson: i had a LA test where we were doing LU factorization on non-trivial matricies of 9x9 dimensions, it was murder

21:03 all by hand of course

21:03 no calculators allowed

21:04 cooldude127: jbondeson: that's awful

21:04 jbondeson: i got a B+ because i didn't reduce all my 5-digit fractions

21:04 cooldude127: lol

21:05 gnuvince_: jbondeson: oh thanks so much

21:05 jbondeson: "you can reduce 34325/64230, sorry -5 pts"

21:05 ayrnieu: ,34325/64230

21:05 clojurebot: 6865/12846

21:05 cooldude127: lol

21:06 well they were obviously both multiples of 5

21:06 gnuvince_: Here's another more general question: have you guys ever taken a class by correspondance?

21:06 cooldude127: no

21:06 gnuvince_: I'm finding it to be a lot harder and frustrating than an in-class course would be.

21:06 jbondeson: i wonder if (.hashCode) will work for the priority function of a treap...

21:06 ayrnieu: ,(/ (/ 34325 5) (/ 64230 5))

21:06 clojurebot: 6865/12846

21:06 ayrnieu: well, that's not useful :-)

21:06 cooldude127: jbondeson: what purpose would that serve

21:07 jbondeson: gnuvince_: it is. (this will make me sound very young) my mother actually just finished up her degree via correspondence in accounting and it was horrible for her.

21:07 cooldude127: treaps are randomized BSTs

21:07 you need a fairly random number for priority

21:08 cooldude127: jbondeson: oh yeah, that's right

21:08 gnuvince_: jbondeson: I am taking this class to get my math credits to go to university, but this is not helping me keep my motivation

21:08 jbondeson: i'm just concerned about it being random enough

21:08 cooldude127: jbondeson: i haven't actually learned them, just looked at the wikipedia page one time

21:08 jbondeson: ,(hash '(1))

21:08 clojurebot: 32

21:08 cooldude127: jbondeson: what about actually using a random number?

21:08 jbondeson: ,(hash '(2 3))

21:08 clojurebot: 1026

21:08 jbondeson: cooldude127: i would like to use something deterministic to utilize memoziation

21:08 cooldude127: oh

21:09 jbondeson: using lazy evaluation with memoization will allow for proper amortized costs

21:09 cooldude127: ,(hash 2)

21:09 clojurebot: 2

21:09 cooldude127: ,(hash '(2))

21:09 clojurebot: 33

21:09 jbondeson: yeah, that's the part i'm concerned about

21:09 cooldude127: jbondeson: hash codes for numbers aren't random

21:10 blbrown: is there proxying involved for java.lang objects like string. for example (def a "kljdfklsdjf") looks like type string, but is there a proxy between java.lang.String and the one represented there

21:10 jbondeson: i don't think that should matter too much, because you're not likely to be using contiguous real numbers in a treap

21:10 cooldude127: blbrown: clojure uses java.lang.String

21:10 jbondeson: ,(hash 4.23)

21:10 clojurebot: 1588116073

21:10 cooldude127: jbondeson: oh ok

21:10 blbrown: clojure uses java data types anywhere possible

21:10 jbondeson: blbrown: no, it's a java string

21:11 proxies are only used for dynamic objects that need to implement certain interfaces.

21:11 there are very few in core clojure.

21:11 blbrown: cooldude127, that is interesting, because I can call (first "klsjflksd" )

21:11 cooldude127: blbrown: clojure implements first on strings

21:11 jbondeson: futures use them , but when they get stable the proxy will likely be removed.

21:12 cooldude127: blbrown: any of the seq functions work on strings

21:12 blbrown: jbondeson, it is just interesting how clojure treats types

21:12 jbondeson: rich was just really smart ;_

21:12 ;) even

21:12 cooldude127: blbrown: clojure isn't object-oriented, so functions can operate on anything they want

21:12 blbrown: simple yet powerful

21:12 cooldude127: i agree, rich is very smart

21:13 jbondeson: blbrown: it's amazing how much you can do with a hash map. cooldude127 can show you his avl tree that only uses linked hash maps and no "data types" as it were

21:13 blbrown: OK here is an example, I am pretty sure with ABCL/Common Lisp, you don't have this kind of interoperability. Clojure handles different types seamlessly

21:14 jbondeson: i hate to admit it, but being on the jvm allows you to do some very handy things

21:14 cooldude127: blbrown: the difference is clojure was built from the ground up on the jvm

21:14 abcl had to lug around CL compatibility

21:15 jbondeson: how can acm not have anything on treaps in their digital library? what am i paying $200 a year for >=/

21:15 blbrown: hehe

21:15 cooldude127: blbrown: if you're interested in what jbondeson mentioned about the avl trees: http://github.com/cooldude127/clojure-code/blob/6401c6eb0b9a1fc087d17cd1999f49658d312375/structures/avl_tree.clj

21:15 damnit github

21:15 long-ass urls

21:16 jbondeson: watch out, or clojurebot will start tinyurl'ing everything again

21:16 blbrown: cooldude127, are you talking to the wrong person

21:16 cooldude127: lol

21:16 jbondeson: hiredman is just waiting for the day!

21:16 cooldude127: blbrown: no. jbondeson mentioned this to you

21:16 jbondeson: that was an example of how the "type" system in clojure works

21:17 cooldude127 just did a very clean implementation that gets the point across nicely

21:17 cooldude127: well, clojure does have a kind of type system, but often it's unnecessary

21:17 jbondeson: well, yeah

21:17 cooldude127: jbondeson: the only reason i wrote this was to learn how to write an avl tree. then i had to do it in java

21:17 awful

21:17 jbondeson: but you don't use it much unless you want to leverage multimethods.

21:17 cooldude127: yeah

21:18 jbondeson: cooldude127: come now, all the persistent data structures were implemented in Java by rich.

21:18 think of THAT pain

21:18 blbrown: cooldude127, yea, I would have written it in clojure and then code generated the java

21:18 cooldude127: yeah i applaud and admire him

21:18 blbrown: the idioms are different

21:19 the clojure version is purely functional

21:19 jbondeson: i've been tempted to do some persistent data structure programming in C# and then i think of the pain it will cause me...

21:19 cooldude127: yeah screw that

21:20 jbondeson: one day people at my office will come in and half the codebase will be in clojure and it will be glorious.

21:20 cooldude127: lol

21:20 i have a computer programming project for calculus 3, so i'm writing all kinds of linear algebra stuff in clojure

21:21 jbondeson: i love programming projects for non-programming classes.

21:22 cooldude127: jbondeson: me too

21:22 it's really fun to be in class writing the code to do the stuff we are currently going over in class

21:22 also a good way to actually learn it

21:23 jbondeson: forces you to think about the nitty-gritty

21:23 cooldude127: btw has anybody given a go at symbolic math in lisp?

21:23 jbondeson: plenty

21:23 cooldude127: jbondeson: yeah, apparently row-reduction is way more difficult for a computer than a person

21:23 p_l: cooldude127: many had given a go, including textbooks (PAIP comes to mind)

21:24 cooldude127: p_l: what's paip?

21:24 i just found cl-symbolic-math on github lol

21:24 jbondeson: mathematical functions are so regular that symbolic math parsers are actually very similar to lisp readers.

21:24 p_l: cooldude127: "Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp"

21:24 cooldude127: oh god

21:24 jbondeson: AI Bible

21:25 Made by god.

21:25 ayrnieu: coolude - http://maxima.sourceforge.net/

21:25 jbondeson: i.e. Norvig

21:25 p_l: and a kind of advanced CL textbook :)

21:25 cooldude127: oh wow

21:25 i opened up a can of worms i wasn't ready for

21:26 jbondeson: you want a can of worms you aren't ready for just go look up "A New Kinda of Science" by Wolfram

21:26 THE Wolfram that is.

21:26 p_l: AFAIK one of the first apps to tackle symbolic math was "Student"? ca. 1960s?

21:26 cooldude127: oh no

21:26 ozy`: ,`('foo unquote 'bar)

21:26 clojurebot: ((quote sandbox/foo) clojure.core/unquote (quote sandbox/bar))

21:27 ozy`: oh cool

21:27 jbondeson: symbolic math and lisp are like kissing cousins.

21:27 ozy`: ,'`(foo ~bar ~@baz)

21:27 clojurebot: (clojure.core/concat (clojure.core/list (quote sandbox/foo)) (clojure.core/list bar) baz)

21:27 cooldude127: jbondeson: what exactly do you mean by that?

21:28 p_l: BTW, people here interested in making clojure equivalent of clbuild?

21:28 ozy`: ,'`foo

21:28 clojurebot: (quote sandbox/foo)

21:28 ozy`: weird

21:29 cooldude127: p_l: as in a package manager?

21:29 jbondeson: cooldude127: i wouldn't be at all surprised if one of the first applications McCarthy came up with for Lisp was symbolic math

21:29 cooldude127: like a version of asdf that is not crappy as hell

21:29 jbondeson: it seems like a natural with symbols being there and all

21:30 jbondeson: asdf... ewwww

21:30 asdf is about pain

21:30 p_l: cooldude127: ASDF is a build system. clbuild was for actually downloading the stuff in the first place

21:30 ozy`: jbondeson: isn't that why he made it?

21:30 jbondeson: i belive so

21:30 cooldude127: p_l: ok like a less crappy asdf-install

21:30 ayrnieu: what's painful about ASDF, jbondeson?

21:30 cooldude127: ayrnieu: EVERYTHING

21:31 jbondeson: yes, i do believe that the question to be asked is "What is NOT painful about ASDF"

21:31 p_l: AFAIK Lisp was conceived as a nice theoretical tool. Then a certain student had gone to McCarthy after a lecture, and said "Hey, if I implement (eval ...), I'll get the whole language!"

21:32 ozy`: yeah

21:32 p_l: as for now, I've got a simple script that will build CLASSPATH so that all jars that are lying in certain directory are included

21:32 (this script is a wrapper for clojure)

21:33 jbondeson: .emacs will do that for you in 1 elisp line =P

21:33 ayrnieu: cooldude - OK, so everything except for 'defining systems, compiling them, loading them, putting them where ASDF can find them'. Well, you can get a little bit of code to do that last part, or you can use asdf-install which does that too. It's *so* painful, it says "hey, do you want me to install this locally or system-wide? Oh, OK." And then it sort of whines about GPG.

21:33 p_l: jbondeson: Yeah, and I'll load up Emacs to do it for me on every invocation on cmdline? /bin/sh is still smaller :P

21:33 stimuli: hi

21:34 jbondeson: p_l: wait, emacs is an operating system... what is a shell?

21:34 p_l: jbondeson: Part of that Exokernel that runs Emacs

21:34 stimuli: an easy way to copy files inside of emacs ?

21:34 ayrnieu: stimuli - dired.

21:34 stimuli: M-x shell

21:34 jbondeson: so confused

21:35 stimuli: wrote my first is-test code ... It is pretty good

21:35 I like that it isn't hideously complicated

21:35 ayrnieu: p_l - by simple script, do you mean: for x in some/dir/*.jar; do CLASSPATH=$CLASSPATH:$x; done ?

21:35 jbondeson: emacs loves you... why would you ever abandon it?

21:35 stimuli: there are things besides emacs ???

21:35 p_l: ayrnieu: something like that (I've got some additional things loaded, like switching debugging options on and off etc.)

21:35 stimuli: don't even say that

21:36 cooldude127: alright well great, i started reading code for symbolic math and now i've ruined my life ;)

21:37 durka42: there's vim :)

21:37 hiredman: mmmm vim

21:37 p_l: ayrnieu: Now I'm writing something to actually download/upgrade/compile clojure libs and then symlink them to said dir :)

21:38 at the moment it's going to be pure shell script, because I pretty well know that it's not rare for me to fuckup my install :)

21:39 gnuvince_: ,seen rhickey

21:39 clojurebot: java.lang.Exception: Unable to resolve symbol: seen in this context

21:39 Chouser: ~seen rhickey

21:39 clojurebot: rhickey was last seen in #clojure, 199 minutes ago saying: that's the only promise made by the sequence fns

21:40 jbondeson: Chouser to the rescue.

21:40 gnuvince_: Thanks

21:41 cooldude127: this might also work

21:41 gnuvince_: I was wondering if he'd seen the report on byte, short et al.

21:41 cooldude127: clojurebot: seen rhickey?

21:41 clojurebot: rhickey was last seen in #clojure, 200 minutes ago saying: that's the only promise made by the sequence fns

21:41 Chouser: no future in lazy

21:41 jbondeson: damn do i love academia: "On Using Condiditonal Rotations and Randomized Heuristics for Self-Organizing Ternary Search Tries"

21:42 cooldude127: jbondeson: oh my god

21:42 stimuli: I'd call it "Tries that ROCK!" .. my professors be damned

21:42 cooldude127: lol

21:43 stimuli: I've been pouring through like 3490239423094 journal articles on Datalog

21:43 they're sometimes ... dense

21:44 jbondeson: i bet if i read this paper this guy took a 30 year old algorithm and said "What if we don't rotate all the time?" and wrote a 7 page paper on the topic

21:45 stimuli: hmmm

21:46 well ... there are more students than ideas I suppose

21:46 jbondeson: not everyone can be Okasaki

21:46 stimuli: no

21:46 p_l: stimuli: and big amount of students are not really that keen on making new stuff

21:47 stimuli: I suppose I shouldn't criticize ... I can't fill up a twitter post

21:53 Chouser: This appears to be a infinite loop in lazy branch: (take-while #(>= % 0) (repeatedly #(.read stream)))

21:55 notyouravgjoel: I need to create the powerset of a set, and my current implementation (based off of the contents of SICP) is killing my application with memory use. Any suggestions for a speedy powerset implementation?

21:56 jbondeson: i think there's a powerset in contrib... or at least someone submitted on to the group

21:56 ayrnieu: if you paste your current implementation, maybe someone can help you with memory use.

21:56 notyouravgjoel: thanks

21:57 Chouser: Is that the same as clojure.contrib.combinatorics/subsets ?

21:58 jbondeson: Chouser: yes, just found the clojure.contrib issue

21:58 stimuli: has anyone put together a graph library ?

21:58 notyouravgjoel: where do i find clojure.contrib references?

21:58 ayrnieu: notyour - there's a link on clojure.org

21:59 jbondeson: http://clojure-contrib.googlecode.com/svn/trunk/

21:59 cooldude127: stimuli: which kind of graph? the data structure? or the chart kind?

22:00 stimuli: data structure

22:00 traversals .. strongly connected components and that stuff

22:00 cooldude127: stimuli: then no, but i might do it. i'm in a data structures class right now and we're about to learn graphs

22:00 stimuli: I'd love a lazy post-order stream ... I've written a non-lazy one

22:00 but it is non-obvious how to make it lazy

22:01 cooldude127: stimuli: obviously, or you would have done it ;)

22:01 jbondeson: stimuli: add cheetos

22:01 stimuli: :P

22:01 yeah

22:01 lisppaste8: notyouravgjoel pasted "powerset" at http://paste.lisp.org/display/75390

22:01 stimuli: is powerset the same as all subsets ?

22:01 notyouravgjoel: my current implementation, btw

22:01 yes

22:02 stimuli: there is one in the combinatorics library in contrib

22:02 jbondeson: which is vastly more comple

22:02 +x

22:03 stimuli: contrib has some cool stuff in it

22:03 I'm prolly going to use monads soon

22:03 jbondeson: honestly your best bet is to pull down contrib and use clojure.contrib.combinatorics/subsets

22:04 stimuli: yeah

22:04 to "seriously" use clojure .. you pretty much need contrib

22:04 its kinda becoming a standard library

22:04 cooldude127: yeah for reals

22:05 Chouser: this is broken in lazy: (take-while #(>= % 0) (range 9 -9 -1))

22:05 stimuli: hmmm

22:05 jbondeson: cool kids reimplement all of contrib ... in an hour B)

22:05 stimuli: chouser : do you think lazy will become official ?

22:05 <-- not a cool kid, evidently :)

22:05 * jbondeson isn'

22:05 jbondeson: damn you enter key

22:05 Chouser: My guess? yes. But that's just a guess.

22:06 stimuli: I guess I'll have to learn it then :)

22:07 Chouser: range is broken

22:08 oh. range uses take-while.

22:09 stimuli: I just hope we don't end up with stream ... destructive streams are evil

22:10 cooldude127: stimuli: i don't think rich really likes streams

22:10 because of the whole state thing

22:10 stimuli: good

22:10 yeah

22:10 ocaml had stream

22:10 they were a PITA

22:10 jbondeson: ahhhhh ML

22:10 cooldude127: ocaml state doesn't it?

22:10 jbondeson: ML, O'Caml, F# god bless them

22:10 cooldude127: s/ocaml/ocaml has/

22:11 stimuli: yeah .. it's ml with object .. more or less

22:11 cooldude127: i personally just hated the syntax of ocaml

22:11 stimuli: or maybe sml with objects ... I'm not sure

22:11 cooldude127: ;; <- wtf?

22:11 jbondeson: hah

22:11 stimuli: or the dots :)

22:11 remember the dots ?

22:11 cooldude127: oh god

22:11 jbondeson: sorry but ':=' is still the worst

22:11 stimuli: *. ... or was it .*

22:11 gnuvince_: *.

22:12 cooldude127: jbondeson: i don't mind :=

22:12 jbondeson: screw pascal

22:12 stimuli: R uses <-

22:12 which is kind of cool if you like typing

22:12 jbondeson: i loath the shift key

22:12 cooldude127: jbondeson: smalltalk also uses :=

22:12 jbondeson: cooldude127: wait is that a plus? ;)

22:12 cooldude127: jbondeson: smalltalk is win

22:13 if i have to do oo, it better be in smalltalk

22:13 stimuli: yeah ... smalltalk is lovely and wonderful

22:13 jbondeson: so sad

22:13 great ideas, horrid implementation

22:13 cooldude127: jbondeson: i get screwed cuz i try to use Emacs keybindings in visualworks

22:14 and i end up deleting all the code i just wrote

22:14 gnuvince_: Smalltalk environments are bad.

22:14 They should do like Factor and open an external editor to edit code.

22:14 cooldude127: yeah it's the main reason i don't use it more

22:14 Chouser: rhickey: I've got a tiny patch to fix a paren typo in take-while. You want the whole group/issue process?

22:14 jbondeson: cooldude127: then you tried to do C-x _?

22:14 Chouser: this is in the lazy branch.

22:15 cooldude127: jbondeson: yeah i tried C-x C-s and the C-x killed everything

22:15 jbondeson: hahaha

22:15 cooldude127: jbondeson: save often ;)

22:15 jbondeson: this is exactly why you should never leave emacs

22:15 cooldude127: jbondeson: i could probably do that with gnu smalltalk

22:15 it has an emacs mode

22:17 anyway, what language is this channel about again?

22:17 gnuvince_: heh

22:17 jbondeson: haskell?

22:17 i forget...

22:17 stimuli: the smalltalk environments were both cool and sucky at the same time

22:17 BCPL ?

22:17 cooldude127: jbondeson: that's pretty close

22:17 gnuvince_: Ah, Haskell :)

22:17 cooldude127: jbondeson: at least you picked a functional language

22:17 jbondeson: still miss patern matching

22:17 cooldude127: jbondeson: me too

22:17 * jbondeson pours out a 40

22:17 gnuvince_: If it wasn't for Clojure, I'd be into Haskell full time

22:18 cooldude127: i couldn't make haskell be useful

22:18 cuz i still don't fully understand monads

22:18 jbondeson: monads are a whole lot of philosophy and not much science...

22:18 stimuli: I kinda do understand monads .. er .. most of the time ... well ... kinda

22:18 gnuvince_: cooldude127: the problem with monads is that they're simple and can be used to do crazy things

22:19 cooldude127: gnuvince_: yeah i could never figure out just how

22:19 i tried

22:19 then i found better ways to spend my time

22:19 gnuvince_: One problem with monads is that the same syntax can have vastly different effects depending on the type being worked with

22:19 cooldude127: true true

22:19 stimuli: yeah .. I remember on of walder's early articles where he changed the eval order of a program (completely reversing it) just by changing the monad

22:20 cooldude127: oh god

22:20 stimuli: I mean .. it's cool

22:20 jbondeson: you know what the only problem with persistent datastructures is? having to think about all the bloody copying.

22:20 stimuli: yeah

22:20 notyouravgjoel: sorry for being so... bad at this, but how exactly do I used contrib? I checked out the svn and created clojure-contrib.jar by running ant

22:20 ayrnieu: jbondeson - think about all the safely shared data.

22:20 stimuli: we spend like 3290409230984 hours today tracking down a bug that just *couldn't* happen in FP

22:21 ayrnieu: notyour - add the .jar to CLASSPATH

22:21 notyouravgjoel: ah k

22:21 gnuvince_: stimuli: what kind of days do you have on your planet?

22:21 jbondeson: notyouravgjoel: are you using emacs?

22:21 stimuli: gnu : long ones

22:21 :)

22:21 notyouravgjoel: yes

22:21 emacs

22:22 gnuvince_: Well I'm going to bed

22:22 Hopefully Rich will see my issue tomorrow

22:22 stimuli: not : in your .emacs there is prolly some place where you set the classpath for whatever slime/mode/otherwise you are using

22:22 notyouravgjoel: ah, not using slime; never bothered to get it working

22:22 jbondeson: add it to your swank-clojure-extra-classpaths

22:22 stimuli: not : does M-x run-lisp or run-clojure work for you ?

22:23 notyouravgjoel: no

22:23 stimuli: so how do you run code ?

22:23 from shell ?

22:23 notyouravgjoel: yep

22:23 stimuli: oh

22:23 cooldude127: notyouravgjoel: maybe try technomancy's clojure-mode clojure-install function?

22:23 stimuli: there are some not-quite-slime major modes out there

22:23 that let you run your code in emacs

22:23 more or less slime like but easier to setup

22:24 notyouravgjoel: I'm fine with this, for now

22:24 lisppaste8: jbondeson pasted "add classpath" at http://paste.lisp.org/display/75392

22:24 jbondeson: that reeeaaaaly helps

22:24 stimuli: your productivity will go up a lot ..... when you have some free time it is worth pursuing

22:24 notyouravgjoel: just because I have a deadline with this thing, tomorrow at midnight

22:24 stimuli: ah

22:24 jbondeson: add that to .emacs and you can M-x clojure-add-classpath anything

22:25 danlarkin: Chouser: I pulled represent and invoke-templatetag into a separate (3rd) file. Ugly, but working, solution

22:25 stimuli: not : do you use Java ? know how classpaths work ?

22:25 lisppaste8: jbondeson annotated #75392 with "more emacs goodness" at http://paste.lisp.org/display/75392#1

22:25 notyouravgjoel: ehh, I believe I do. Its simply where java searches for classes, if not in current directory, right?

22:25 stimuli: yeah

22:25 jbondeson: those two together will allow you to not have to restart emacs when you want to screw with your classpaths

22:25 stimuli: so you do java -classpath clojure.jar:clojure-contrib.jar:whateverelse.jar ....

22:26 ayrnieu: notyour - it's a list of .jars and directories that java searches for classes in, yes.

22:26 stimuli: you might have to use a ; instead of a :

22:26 notyouravgjoel: ahh

22:26 stimuli: you can put them in an environment var CLASSPATH

22:26 and then Java will find them

22:26 which helps when you have a zillion jars

22:27 cooldude127: jbondeson: your code there now reveals why my classpath addition didn't work until i restarted emacs

22:27 notyouravgjoel: ah, added it

22:27 but still no good

22:27 jbondeson: cooldude127: can't take credit, i sooo lifted that off the internet

22:28 cooldude127: jbondeson: either way, i now know why it didn't work :)

22:28 stimuli: not : java -help :)

22:29 notyouravgjoel: well anywya, I'm currently specifying it via -cp

22:29 ie, im running

22:29 stimuli: not : awesome!

22:29 notyouravgjoel: java -agentlib:yjpagent -Xms128m -Xmx256m -cp jline-0.9.94.jar:clojure.jar:clojure-contrib.jar jline.ConsoleRunner clojure.lang.Repl

22:29 and.. nothing, still

22:29 stimuli: oh

22:30 are all the jars in your local directory ?

22:30 notyouravgjoel: yep

22:30 stimuli: is there an error message ?

22:30 notyouravgjoel: wow, jar -t clojure-contrib.jar hangs

22:30 for quite a while

22:30 stimuli: try jar -tf

22:30 :)

22:31 notyouravgjoel: ah

22:31 stimuli: it was waiting on stdin

22:31 notyouravgjoel: makes sense, ahha

22:31 Chouser: danlarkin: hm, ok.

22:31 notyouravgjoel: wait.. these are all .clj files

22:31 stimuli: that is ok

22:31 lisppaste8: p_l pasted "Ugly clojure startup script" at http://paste.lisp.org/display/75393

22:31 stimuli: to get *.class files in clojure-contrib.jar you have to tell ant where clojure.jar is

22:32 when you build contrib

22:32 but it should still work w/ just the .clj files .. just loads slower

22:32 notyouravgjoel: mm, okay

22:32 I'll check it out

22:32 stimuli: yeah .. play around w/ it

22:34 well .. I'm turning in .. goodnight (or afternoon or whatever) everyone

22:34 notyouravgjoel: thanks for the help

22:34 ah

22:36 p_l: Question: When I attempt to autocomplete symbols in SLIME, I get "funcall: Synchronous Lisp Evaluation aborted"

22:36 cooldude127: p_l: perhaps your slime or swank-clojure is old

22:36 p_l: i had that and then updated

22:36 notyouravgjoel: how do I set the clojure.jar path with ant?

22:40 jbondeson: notyouravgjoel: notyouravgjoel: for clojure.contrib "-Dclojure.jar=/path/to/clojure.jar"

22:40 whops

22:40 notyouravgjoel: ah thanks

22:41 oh god

22:41 it still wont work

22:41 jbondeson: ?

22:42 notyouravgjoel: actually, I think classpath isn't working properly in any case

22:42 take it back

22:43 it is, itself, but clojure-contrib.jar isn't working one pit

22:44 so, I ran "ant -Dclojure.jar=clojure.jar"

22:45 (i copied clojure.jar into clojure-contrib-read-only)

22:45 then, copied clojure-contrib into my main clojure directory

22:46 when running, I use

22:46 java -agentlib:yjpagent -Xms128m -Xmx256m -cp jline-0.9.94.jar:clojure.jar:clojure-contrib.jar jline.ConsoleRunner clojure.lang.Repl

22:46 java -agentlib:yjpagent -Xms128m -Xmx256m -cp jline-0.9.94.jar:clojure.jar:clojure-contrib.jar jline.ConsoleRunner clojure.lang.Repl

22:46 ugh

22:46 p_l: Yeah! I've got Java symbol completion partially working!

22:47 notyouravgjoel: once the REPL starts, "(clojure.contrib.combinatorics/subsets '(1 2 3 4))" returns "java.lang.ClassNotFoundException: clojure.contrib.combinatorics (NO_SOURCE_FILE:1)"

22:47 any ideas?

22:47 ayrnieu: notyour - (use 'clojure.contrib.combinatorics)

22:48 notyouravgjoel: ah, should have figured

22:49 mm, are lambdas still not garbage collected?

22:50 cooldude127: p_l: did the update fix it?

22:52 p_l: cooldude127: not only update - Java object completion was added outside it. Clojure objects _were_ fixed by it

22:52 ayrnieu: notyour - they are.

22:53 notyouravgjoel: k

22:53 cooldude127: p_l: cool

22:55 p_l: cooldude127: Now I need to experiment a little more so that I'll get completion a'la NetBeans :P

22:55 danlarkin: Chouser: uh oh! now I have a love triangle of (require ) forms. I feel like this is something I shouldn't have to deal with

22:55 cooldude127: danlarkin: sounds like you've got something wrong

22:55 danlarkin: cooldude127: won't be the last time :)

22:56 cooldude127: lol

22:59 notyouravgjoel: haha, my own powerset implementation is significantly faster than the contrib version

22:59 cooldude127: notyouravgjoel: WOOHOO! screw standard libraries

23:00 notyouravgjoel: pff, at least when the textbook version is 3x as fast as the std lib version

23:01 cooldude127: lol

23:03 notyouravgjoel: Soo, back to my original question : any idea how to optimize this: http://paste.lisp.org/display/75390

23:06 I actually do only use a small portion of the entire powerset, but I don't know an effective way of pruning the execution tree

23:06 I realize that creating a particularly large powerset is very hard

23:07 (has n^2 elements for a set of length n)

23:10 Chouser: notyouravgjoel: with a quick glance, that appears to be pretty lazy

23:10 it should only compute what you use.

23:11 (seq set) is more correct than (nil? set)

23:11 or just (if set ...)

23:11 notyouravgjoel: I don't understand lazyness entirely

23:12 or well, I get the gist

23:12 but, how do I apply it to this problem?

23:12 Chouser: 'set' is the name of a builtin function, though, so you might choose a different name for that arg

23:12 notyouravgjoel: can I creat the powerset, and then use some filter to only ahve what I want?

23:12 Chouser: well, you said you only need a "small portion". which portion?

23:13 notyouravgjoel: I filter the problem to make it smaller, not using any sets that have greater than half the original set's amount of sets

23:14 (thanks for your help by the way)

23:15 Chouser: hm, sounds like laziness might not help you much then

23:16 notyouravgjoel: yeah. It would be great, though

23:16 I'll have to ponder the powerset function, I suppose

23:16 maybe prune it a bit

23:16 Chouser: if you were to do (take 5 (powerset...)) it would only compute the first 5

23:16 notyouravgjoel: is it possible to do something like

23:16 Chouser: (assuming it's as lazy as I'm guessing by just looking at it)

23:16 notyouravgjoel: take a random 5?

23:17 Chouser: the 'rest' of a seq is lazy

23:18 the only way to get to item n in a seq is to walk past and realize all of the items up to n

23:19 so counting a lazy seq realizes the whole thing

23:20 that means to get a fair random selection, laziness won't help. Though you could "flip a coin" on each item until you have as many as you want, leaving the rest unrealized.

23:20 notyouravgjoel: makes sense

23:20 the problem is that this implementation goes...

23:21 (powerset (range 1 4))

23:21 ([] (3) (2) (2 3) (1) (1 3) (1 2) (1 2 3))

23:21 ah well

23:21 so 1's only start getting added after the others

23:22 ah well

23:22 Thanks man =)

23:22 Chouser: It seems like you might be able to build your "less than half the length" constraint right into the function.

23:22 notyouravgjoel: I'll go think about it

23:22 Chouser: good enough.

23:22 notyouravgjoel: well see

23:23 a powerset of a set of n elements is length 2^n

23:23 cutting it in half == a new length of 2^(n-1)

23:23 which only yields me an extra 1

23:23 ie, i can now calculate the powerset of a set with 22 elements, whereas now I'm stuck at 21

23:24 but yeah, that IS a good net improvement

23:25 Ohhh wait, you gave me an idea!

Logging service provided by n01se.net