#clojure log - Oct 18 2009

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

0:01 durka42: the side-effects part?

0:04 jlilly: partial is effectively a curry, right?

0:04 hiredman: yeah

0:04 durka42: yeah

0:05 (defn iter [fn init] (lazy-seq (cons init (let [v (fn init)] (cons v (iter fn v))))))

0:05 more like what I was hoping for

0:06 but it is less lazy then iterate, but I imagine that could be fixed

0:07 hmm

0:45 jlilly: I need to do a multi-line thing in a function. Is there something similar to elisp's progn?

0:45 the multi-line thing is: print line, read line.

0:46 fanatico: M-x slime works, but swank-clojure-project fails to connect a slime instance, then nerfs my swank-clojure-classpath variable. What have I done to offend it?

0:46 tomoj: fanatico: do you have clojure.jar in lib/?

0:47 fanatico: Isn't that available via swank-clojure-jar-path?

0:47 tomoj: no

0:47 swank-clojure-project wants you to put _everything_ in the project dir

0:48 hiredman: jlilly: do?

0:48 tomoj: afaik. you could hack it to look for clojure elsewhere

0:48 jlilly: ,(doc do)

0:48 clojurebot: Pardon?

0:48 tomoj: jlilly: functions are implicit progns

0:48 jlilly: that's a functioN?

0:48 fanatico: tomoj: thanks.

0:48 tomoj: (defn foo [] (bar) (baz))

0:48 jlilly: defn?

0:48 hmm. I'll try that.

0:49 tomoj: if you didn't know defn... what the heck where you doing before? :)

0:49 hiredman: fns have an implicit do

0:49 ,(do 'this 'that)

0:49 clojurebot: that

0:49 jlilly: I forgot to do the [] :)

0:50 hiredman: ,(do (pr :a) (pr :b))

0:50 clojurebot: :a:b

0:50 tomoj: fanatico: I guess maybe it's so we can use different clojure versions in different projects easily? dunno

0:53 fanatico: tomoj: that makes sense. Still seems wrong to not restore the classpath vars.

0:53 tomoj: yeah

0:54 I guess if you have special vars you should write a wrapper around the slime clojure startup that sets them

1:04 technomancy: fanatico: swank-clojure-project expects projects to be entirely self-contained

1:04 I suppose it'd be convenient if it didn't have to affect the default settings though

1:06 if you feel strongly about it, feel free to open an issue on the github project or discuss it on the mailing list

1:08 fanatico: technomancy: Looking at the code now. I always forget how easy this is with emacs. I'll write a quick patch and post an issue later tonight.

1:09 technomancy: great

1:18 jlilly: so, in the slime repl, I run (read-line). how can I exit it?

1:19 I've been killing the repl, but I can't actually test anything with (read-line) in it.

1:25 tomoj: jlilly: one possibility is to switch over to *inferior-lisp* to test those functions

1:26 bryteise: do you need to restart the *inferior-lisp* then?

1:27 tomoj: I don't think so? not sure what you mean

1:28 technomancy: that's a known bug; the IO streams aren't hooked up properly

1:28 tomoj: is slime supposed to be able to handle this? (testing with sbcl now)

1:28 bryteise: hrm im probably confused and thinking of something else

1:28 technomancy: well; *in* isn't at least... waiting for someone who actually uses *in* to fix it. =)

1:29 tomoj: fyi: yes, it works fine with sbcl

1:39 bryteise: is there a nice solution for working with maven packages with slime? i hadnt seen much since dysinger's method which was using an old repo of clojure i wasnt sure how to update (and wanted to use the emacs-starter-kit version anyway)

1:40 technomancy: bryteise: swank-clojure-project will pick up deps in target/dependency automatically

1:41 bryteise: ah okay, awesome.

1:42 technomancy: stuart's working on getting swank packaged as a maven artifact so you can add it as a dep and then connect remotely to your app to debug in production etc, but that's still a work in progress.

1:43 personally I like making my projects descend from clojure-pom; seems like the cleanest way to handle dependencies so far

1:43 but since there's not post-1.0 build of clojure in the centralized repos, it's messy all around

1:44 I'm thinking soon we'll have a clojure-community-run repo so we don't have to rely on the slow submission process of the central maven one; should help a lot.

1:44 * technomancy heads off

2:35 vy: Why does (serial-enqueue "foo" "bar" "baz") complains that "Wrong number of args passed to: user$serial-enqueue--2294$fn" for (defn serial-enqueue [& args] (swap! serial-stream #(do args))) function?

2:35 jlilly: how do I "run" a clojure file?

2:35 vy: jlilly: java -cp clojure.jar clojure.main /path/to/myscript.clj

2:36 jlilly: See http://clojure.org/repl_and_main

2:39 jlilly: thx

3:01 http://dpaste.de/bWQs/ having some issues with my classpath. Anyone able to take a look?

3:04 arbscht: clojurebot: classpath

3:04 clojurebot: classpath is (System/getProperty "java.class.path")

3:05 arbscht: http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html

3:06 hiredman: jlilly: -cp and -jar are mutually exclusive

3:07 jlilly: I see.

3:59 jamesswift: hey folks. would like some advice on the proper clojure way to do the following http://paste.lisp.org/+1WJ9

3:59 i.e. find the neighbours of a location in an array

4:10 * jamesswift isn't running iTunes currently.

4:11 hiredman: well thats good to know...

4:11 jamesswift: *cough* er yeah

4:12 hiredman: I'd user for to remove all that duplicate code

4:15 jamesswift: well i thought so but was just curious how different it would be and wanted the example code to be clear in what i wanted to do. also it doesn't take into account the edges etc

4:33 i've annotated a 'for' version but i'm still sure there is much nicer way to express this http://paste.lisp.org/display/88821#1

4:41 hiredman: I am pretty sure you can collapse both those for's and get rid of the ifs

4:44 although, I guess that would end up making a flat list

4:52 jamesswift: yeah i would like to keep the structure, so far i have this http://clojure.pastebin.com/m768e9c50 (the lisp paste is down atm)

6:09 spuz: I'm trying to use the clojure contrib profile api (http://richhickey.github.com/clojure-contrib/profile-api.html) so I downloaded the latest clojure contrib from git hub, compiled it, but my program cannot appear to find the profile library

6:09 I do (:require clojure.contrib.profile) but I get java.lang.ClassNotFoundException: clojure.contrib.profile

6:09 when I look in the clojure-contrib.jar, I see many .clj files but not many corresponding .class files. Is that normal?

6:11 serp_: spuz: did you perform any further work on the mandelbrot visualizer?

6:12 spuz: serp_: I'm trying to optimise it at the moment :)

6:12 serp_: you should probably consider adding multiple samples per pixel

6:12 it'll make it look a lot better

6:12 spuz: visual vm is not playing very nice though so I'm trying to use the contrib profile library...

6:13 serp_: that's not a bad idea. I might do that for my java version. I think performance needs to improve for the clojure version first

6:22 Chousuke: spuz: you cloned it with git or downloaded some other way?

6:22 spuz: Chousuke: cloned it

6:25 Chousuke: hmmh

6:26 maybe the profile namespace requires AOT-compilation (which with contrib is only done if you supply the path to clojure.jar)

6:29 spuz: Chousuke: I did ant -Dclojure.jar=../clojure/clojure.jar

6:32 Chousuke: what I'm wondering, is should all the .clj files be compiled into .class files as part of that build?

6:33 Chousuke: most, anyway

6:33 but it shouldn't really matter whether they're compiled or not

6:33 except for the few namespaces that use gen-class

6:38 spuz: hmm ok

6:42 * yason just realized libjava-java-gnome with Clojure is power!

7:07 spuz: Chousuke: Would you expect this to work?

7:07 java -cp "clojure/clojure.jar;clojure-contrib/clojure-contrib.jar" clojure.contrib.repl_ln

7:07 Chousuke: hmmh

7:08 spuz: This is how the CCW plugin starts the repl, when I run it with my newly build clojure and clojure-contrib jars it gives: Exception in thread "main" java.lang.NoClassDefFoundError: clojure/contrib/repl_ln

7:08 Chousuke: I'm not sure if the -cp switch supports relative paths

7:08 spuz: but when I swap them out for the jars included with the CCW plugin, it works fine

7:08 Chousuke: yes, it does

7:08 Chousuke: ah, and the clojure-contrib jar needs to be AOT-compiled

7:09 so if you don't have the class files in the jar it won't work.

7:09 spuz: ah ok

7:09 I guess there's a special way of doing that... :)

7:09 Chousuke: well ant -Dclojure.jar=/path/to/clojure.jar should work

7:10 maybe a relative path doesn't owrk

7:10 work

7:10 spuz: Chousuke: I'll try the full path

7:13 Chousuke: full or relative path has the same effect

7:14 if I specify the path incorrectly then it complains

7:14 so it must be finding clojure.jar

7:14 it seems that AOT compilation is only done for a small set of clj libraries

8:19 ambient: *SLIME compilation* telling me on which line the error happened would be a huge help

8:19 "argument type mismatch"

8:21 it's always "foosouce.clj:0"

8:22 LauJensen: ambient, for what its worth, that usually means it's something in your main ns declaration, or one of the dependencies it's pulling in

8:22 ambient: i got just this one source file so yes, that might be the case :p

8:23 but debuggers are a crutch anyway, eh? ;)

8:26 LauJensen: Well... :) Clojure backtraces have been the source of many tears

8:27 licoresse: I loathe them backtraces

8:27 ambient: i've got my analog modelling synth basics now in place: http://paste.pocoo.org/show/145620/

8:27 but it's a bit slower than i want it to be :/

8:27 LauJensen: What can I do with it ?

8:27 ambient: my paste? at the moment just run it

8:28 later i wlil add sliders and midi input to modify state

8:41 mccraig: i load a file with (load "foo") and call a function defined therein... i get an Exception, which says NO_SOURCE_FILE and gives me no line number information... any ideas what i'm doing wrong ?

8:42 somnium: mccraig: what's the exception?

8:43 mccraig: NPE

8:44 somnium: mccraig: afaik NO_SOURCE_FILE means its calling something defined in the repl

8:45 mccraig: right, but i'm putting the def in a file and either (load "foo") or (require 'foo) it

8:45 both ways i'm not getting line number info

8:45 somnium: mccraig: if you compile a file with a namespace it can give you more info

8:45 are you using slime?

8:47 mccraig: there is a namespace in the file. it's not helping

8:47 i'm not using slime

8:47 using a raw repl

8:47 somnium: mccraig: maybe it will be easier to help if you paste the file and part of the exception

8:50 mccraig: http://gist.github.com/212667

8:51 is a simplest case reduction

8:51 (use 'foo) (oops)

8:51 gives me a RuntimeException with NO_SOURCE_FILE

8:54 java.lang.RuntimeException: boo (NO_SOURCE_FILE:0)

8:54 somnium: thats what it should do

8:54 it throws the exception, prints your message, and there's no source because its all defined in the repl

8:58 mccraig: no, the namespace is in file "foo.clj", which i load with (use 'foo)... it's not defined in the repl

9:00 lisppaste8: spuz pasted "Type hinted function" at http://paste.lisp.org/display/88831

9:01 spuz: Hey, I'm having a problem type hinting the above function, even with the #^WritableRaster hint, I still get a reflection warning for the setPixel method.

9:03 any idea how I can find out why the type hint is not doing anything?

9:03 Chousuke: spuz: maybe there is an overload of the setpixel and it can't figure out the correct one?

9:04 +method :P

9:05 spuz: Apparently, this is the actual implementing class: http://www.docjar.com/docs/api/sun/awt/image/IntegerInterleavedRaster.html

9:05 However, setPixel only appears to be defined as part of the WritableRaster interface

9:06 or class even...

9:06 Chousuke: the typehint should be okay for the wr

9:06 variable

9:07 but I think you need to typehint the parameters

9:07 try (int x) (int y) #^ints (int-array ..)

9:12 somnium: mccraig: when you type (foo) at the repl there is no source file for that (foo) you just typed

9:12 mccraig: try putting (foo) under the definition of foo and executing it, you'll get a line number

9:16 spuz: Chousuke: that seems to help, the setPixel reflection warning has gone now too :)

9:16 improves the speed by a few seconds

10:00 cypher23: Is there another way to "flatten" a list than (apply concat '((1 2 3) (4 5 6)))?

10:13 rottcodd: cypher23: there is also clojure.contrib.seq-utils/flatten

10:14 cypher23: rottcodd, exactly what I was looking for, thanks

10:18 ambient: http://paste.pocoo.org/show/145638/ anyone got some performance tips for me? using a lot of atoms and maps

10:18 should i just do every data structure with a vector instead?

10:18 i mean array

10:22 are there any programs/examples done with clojure where there is a lot of dealing with mutable state with high-performance?

10:26 spuz: ambient: have a look at LauJensen's Transient Brain: http://blog.bestinclass.dk/index.php/2009/10/brians-transient-brain/

10:26 ambient: it's not exactly very high performance, afaict :p

10:27 oh yes, transients, i have to look at those

11:18 LauJensen: New blog post - Python vs Clojure: Reloaded - http://blog.bestinclass.dk/index.php/2009/10/python-vs-clojure-reloaded/

11:18 I took the advice of a few Python users and worked on Rosetta a bit :)

11:18 * ambient cheers

11:19 somnium: LauJensen: where'd you get the cool cobra?

11:19 LauJensen: It's still there

11:20 somnium: er, I guess its a hooded-python?

11:20 LauJensen: ambient, since you're on about performance, you can learn how I take a Python program that runs almost 2 hours and implement a 12 minute solution in Clojure :)

11:21 I'm off again, good evening

11:21 ambient: well i could probably do it with numpy a lot faster, but I don't want to insult anyone's sense of aesthetics

11:21 evening

11:21 licoresse: I don't get this line-counting-thing

11:28 rhickey: us vs them doesn't help us at all

11:30 Chousuke: LauJensen: I think the function used in reduce would be more readable if you didn't use #() so much

11:31 LauJensen: rhickey, I liked the one you did in that programming magazine though, where you slapped Scala, Erlang and a third I don't remember :)

11:31 I couldn't help feeling a little inferior for taking 1 language at a time

11:31 Chousuke, isn't that usually the case ? :)

11:31 Chousuke: LauJensen: also the icky sort call is equivalent to (sort-by :salary < data) if I'm not mistaken

11:31 rhickey: LauJensen: where?

11:32 LauJensen: rhickey, you were interviewed by some journal, their first edition I believe. I had a PDF somewhere...

11:33 Chousuke, really? That would be fantastic

11:33 rhickey: an us vs them blog a) never convinces 'them', and b) just makes 'us' seem insecure. Better to just write about using Clojure effectively and let other people draw their own contrasts

11:34 LauJensen: rhickey, I really thought about it and I ended up concluding, that I wish I had be helped more along in my early years, so I didn't end up wasting so much time in mainstream C/C# etc.

11:35 licoresse: LauJensen: But I need to find out this by myself

11:35 rhickey: LauJensen: you are of course free to write whatever you wish, but it doesn't help Clojure IMO to do us vs them

11:36 ambient: personally, i find well done comparisons between languages interesting, but understand that they can generate epic flame wars

11:36 LauJensen: rhickey, alright - your oppinion counts, I'll take it into consideration

11:36 sproingie: not sure why the python code in "Top-rank per group" isn't using dicts

11:37 also the lambda for the key arg for sorted belies a lack of knowledge of operator.itemgetter

11:37 rhickey: unless one is an expert in both, you will inevitably shortchange 'them'

11:37 somnium: LauJensen: are there limits on what libraries you can use to produce the shortest code?

11:37 rhickey: and that will just make 'them' angry and unreceptive

11:38 LauJensen: rhickey, in a sense that's true but that's why I try to come back to 'immutability' and 'concurrency', and then the implementation details aren't important, the language level support is

11:38 somnium, I don't know - Didn't read the fine print :)

11:39 sproingie: the python code using minidom is also an odd choice, python typically prefers etree instead

11:40 somnium: ruby + nokogiri shouldn't be 35 lines, not sure if limited to std library

11:40 but it was interesting, I learned something about python and clojure

11:40 sproingie: tho it's unlikely etree would have made it any shorter

11:43 LauJensen: somnium, yea I think Python also came across pretty well

11:43 sproingie: somnium: the libraries that ship with the standard language distribution i imagine

11:44 Chousuke: LauJensen: http://gist.github.com/212716

11:44 sproingie: except perhaps for languages where not using a library would be unthinkable, e.g. doing proper xml in C++

11:45 somnium: sproingie: that gives me a shiver

11:45 LauJensen: Chousuke, aah that's cool

11:45 You should drop a link in a comment

11:46 Chousuke: actually

11:46 sproingie: C++ for example uses boost for some of its stuff, the solution just mentions that it's using boost

11:47 LauJensen: Did you guys all know about Rosetta before this post? I never heard of it..

11:47 Chousuke: (doc group-by)

11:47 clojurebot: "clojure.contrib.seq-utils/group-by;[[f coll]]; Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."

11:47 Chousuke: too bad that's not in core :P

11:47 your entire departments thing would become (group-by :department (sort-by :salary data))

11:48 sproingie: haskell's got a groupBy in prelude but it relies on the data being sorted first

12:17 mccraig: ah, got it. (.printStackTrace *e) gives me all the line numbers i want

13:36 ambient: don't know why but classpaths stopped working after updating clojure-mode :/

13:36 the trick of "(setq swank-clojure-extra-classpaths (list "foobar"))" doesn't work anymore

13:38 Chousuke: it's not extra-classpaths anymore

13:38 it's just swank-clojure-classpath

13:38 ambient: thanks :)

13:38 Chousuke: and the swank-clojure-jar variable went away too

13:38 ambient: you probably just saved me hours

13:52 seems there's no real practical difference between using arrays and atoms

13:53 at least according to my benchmarks. except arrays are more difficult to manage

13:53 LauJensen: ambient, did you see cgrands last post on arrays ? (multi-dim)

13:53 ambient: nope

13:53 LauJensen: http://clj-me.cgrand.net

13:53 He's writte a couple of times on how to get big performance wins

13:54 maacl: LauJensen: har du en ide om hvorfor (use 'clojure.test) lige pludselig fejler?

13:54 ambient: cool. ty

13:54 LauJensen: maacl, desværre, har aldrig brugt det

13:54 maacl: LauJensen: ok

13:54 LauJensen: Du går måske ikke ind for tests :-)

13:55 ambient: LauJensen i was storing actual variables in an array. i have (def foo (atom {:var1 0.0 :var2 0.5})) etc.. instead i used arrays and direct indexing. made no difference

13:55 LauJensen: maacl, it's best to stick with english in an english speaking chan :) And yes, I do approve of tests, under the right circumstances

13:55 ambient: one would think that concurrent constructs would introduce significant overhead

13:55 maacl: LauJensen: ok

13:56 djpowell: I just posted my live-repl thing on github btw if anyone's interested <http://github.com/djpowell/liverepl>. Lets you hack a clojure repl into any running java or clojure process.

13:56 hiredman: :( this paper on jvm tail calls lists Clojure under common lisp implementations

13:57 LauJensen: djpowell, nice, will check it out

13:58 ambient: here's the code for both: http://paste.pocoo.org/show/145687/

14:00 LauJensen: djpowell, that's really great man, nice work

14:01 Chousuke: ambient: type hint the arrays

14:02 ambient: when using arrays there can be reflection that clojure won't warn about, even with *warn-on-reflection* set :/

14:03 I wonder if that can be fixed

14:03 ambient: well *warn-on-reflection* doesn't at least say anything

14:03 Chousuke: it won't help with arrays :)

14:03 ambient: aha

14:05 wonder how fast java does this, but currently it's rendering 88k in 0.170 seconds. which is something like 500k ops per second

14:05 Chousuke: the only way to tell if your array accesses are reflected is to use a profiler :P

14:06 ambient: there would be some clojure.lang.reflection.foo popping up in the list?

14:06 Chousuke: something like that anyway

14:06 ambient: nah, nothing that i can see

14:12 Chousuke: might be java.lang.reflect something too

14:12 ambient: simple (time (doseq [i (range 88000)] i)) already takes 60 msec so i doubt there's much reflection

14:15 Chousuke: might be boxing too

14:15 remember that function arguments are always boxed

14:17 ambient: ah, forgot dotimes. it is 3 msec

14:23 oh yes. 170 > 30 msec. im happy

14:23 just did (double foo) inside let

14:23 for all variables

14:24 for future reference, i had an actual reflection error with an array and instead of 30 msec it gave me 5000 msec ;)

14:27 licoresse: Is there a way to automatically load code when starting up clojure?

14:28 like putting something in a . folder...?

14:28 LauJensen: licoresse, user.clj on the classpath will automatically load

14:28 ambient, link to the code you just optimized?

14:28 Chousuke, could you explain boxing ?

14:28 licoresse: ah, thanks

14:28 dandersen: Chousuke: You do Clojure nowadays?

14:29 ambient: LauJensen something just happened to my emacs, will take a sec

14:29 LauJensen: k

14:29 ambient: like it permanently colored a portion of my code :/

14:29 http://paste.pocoo.org/show/145692/

14:30 LauJensen: ambient, funny I tried that yesterday

14:30 opqdonut: that's irritating

14:30 Chousuke: dandersen: it's fun :P

14:30 opqdonut: there was some function to re-syntaxcolor the buffer

14:30 dandersen: Chousuke: I'm thinking about using it for real development. I was asked to join a Java-based project, and I refuse to write Java.

14:31 LauJensen: ambient, thanks

14:32 Chousuke: LauJensen: boxing is what we call wrapping a primitive value in one of the corresponding classes :P

14:32 dandersen: heh, well, I suppose you'll have to convert everyone to clojure ;P

14:33 for me it's just a hobby for now :/

14:33 dandersen: Chousuke: I heard about something called "AOT", and being able to use Clojure code from Java.

14:34 Chousuke: As you know, I use CL most of the time. I only started actually looking into Clojure yesterday. =P

14:35 Chousuke: AOT means ahead-of-time compilation. basically compiling your clojure files to class files :P

14:36 djpowell: alternatively you can use the RT class to dynamically call clojure from java

14:36 Chousuke: the java devs will complain :D

14:52 dandersen: Chousuke: I'm not sure I understand just how it works in reality, but I guess I'll just have to learn Clojure. =]

15:14 licoresse: I've added user.clj to the /src directory (which is in my classpath), but clojure don't pick it up when at startup

15:14 What am I doing wrong?

15:15 ambient: (dolist (d (list "path/to/your/stuff")) (add-to-list 'swank-clojure-classpath d)) to your ~/.emacs

15:15 licoresse: nevermind, found it...

15:15 ambient: ah, nvm. i should read first

15:15 licoresse: it was called userS.clj

15:15 ambient: thanks anyway

15:35 LauJensen: Is there some help/tut/doc out there on how to use reductions?

15:41 ambient: does clojure yet have any supporting swing libs? like swingbuilder for groovy http://groovy.codehaus.org/Swing+Builder

15:42 ,(reductions + (range 10))

15:42 clojurebot: java.lang.Exception: Unable to resolve symbol: reductions in this context

15:42 ambient: :(

15:42 reductions is irreplaceable, honestly

15:44 LauJensen: ambient, there are a few things, did you check out my blog MacSwing meets Enlive? That's one approach, another is something like Miglayout

15:46 arohner: given a class name, is it possible to figure out whether it is an interface or a real class?

15:46 I want supers, but I want to filter out the real classes

15:46 ambient: LauJensen yeah, that looks nice but it's Mac :) won't fit into my environment where everything is gray, bland and edged

15:47 rhickey_: ,(.isInterface Callable)

15:47 clojurebot: true

15:47 rhickey_: (.isInterface Object)

15:47 ,(.isInterface Object)

15:47 clojurebot: false

15:47 arohner: rhickey_: thanks

15:47 LauJensen: ambient, oh I didn't mean the styling, I meant the Cellconstraint approach, where you split your window up in cells and assign components to them

15:48 ambient: ok, i have to grok that then

15:50 LauJensen: I sent you the code in a priv

16:14 technomancy: ambient: that's odd; swank-clojure-extra-classpaths still exists as an alias to swank-clojure-classpath

16:14 if you modify one it modifies the other.

16:15 ambient: *shrug* it just simply didn't work for me

16:15 * technomancy feels dirty talking about modifying lists in this channel

16:15 technomancy: ambient: emacs 22?

16:15 ambient: i did (setq swank-clojure-extra-classpaths (list "foo" "bar"))

16:15 yes, on win32

16:16 technomancy: works on 23... didn't realize that was a new feature. =\

16:16 ambient: gnu emacs (i386-mingw-nt6.0.6002) of 2009-06-30

16:16 technomancy: and the value of swank-clojure-classpath isn't affected?

16:17 ambient: i dont really know much about elisp, just the bare necessities to get something set up

16:18 technomancy here's my .emacs http://paste.pocoo.org/show/145721/

16:21 * technomancy chalks it up to platform-specific quirks. =\

16:22 technomancy: unfortunately I don't have the resources to test exhaustively

16:49 tomoj: something Very Bad just happened :(

16:49 http://img190.yfrog.com/img190/5002/sshotx.png

16:51 the function that calls sort-by returns, then I try to count the result and that happens, except everythings flickering like it's entering the debugger over and over, and I'm locked in and have to forcefully kill emacs

16:55 does any of that look vaguely familiar to anyone? :(

16:58 looks like slime is trying to dump my huge seq to the screen.. I wonder why it would do that when I told clojure to count the seq?

16:59 ambient: do you have *print-length* set?

17:00 a simple (range 1000000) will kill my emacs if it's not set to some sensible value

17:00 hiredman: but he is not printing the seq

17:00 he is counting it

17:02 tomoj: have you tried to manually count it? (loop [s some-seq count 0] (if (seq s) (recur (rest s) (inc count)) count))

17:03 tomoj: maybe an error is thrown, and part of the output is all of my data? is that possible, I wonder?

17:04 hiredman: hmmmm

17:05 technomancy: bleh; clojure is still called clojure-lang in the pom?

17:05 I thought that had been fixed?

17:06 tomoj: manually counting causes the same freakout

17:07 hiredman: time to start wrapping stuff in (try (catch Exception e (.printStacktrace e)))

17:09 tomoj: wow

17:09 setting *print-length* to 3 made the count call return immediately

17:09 (with no errors)

17:10 WTF?

17:11 I set! *print-length* to 3, counted, worked fine. same for 30, 300, 3000, 30000, and 300000.

17:11 hiredman: interesting

17:11 tomoj: then I set! *print-length* to nil, and that call never returned, emacs blew up as before

17:11 not on the subsequent count I was going to do, but on set!ing *print-length* to nil

17:12 ambient: i get different amount of freezing depending on which type of functions i try to print

17:12 tomoj: (set! *print-length* nil) shouldn't be printing anything, should it?

17:12 ambient: sometimes it freezes just the repl, sometimes the whole emacs comes unresponsive

17:12 tomoj: besides, maybe, "nil"

17:12 something seems seriously fucked up

17:12 ambient: i'd thing print-length of nil meant if was infinite

17:13 tomoj: OOH

17:13 I think I know what's happening

17:13 I bet it's the stupid trick where when you point at a variable, it prints the value in the minibuffer

17:14 ambient: heh

17:14 tomoj: and my value is hundreds of thousands of lines long

17:14 Chousuke: heh

17:14 that would be dangerous with infinite seqs :P

17:15 tomoj: huh, I wonder why that's never bitten me before

17:15 ambient: on a related note, anyone know how to automatically set *print-length* on emacs start?

17:15 or M-x slime

17:16 somnium: ambient: put it in user.clj?

17:16 technomancy: ambient: you can use slime-connected-hook

17:17 tomoj: hahaha, yeah. (def *bar* (iterate inc 1)) RET *bar* <wait a few seconds> "Java heap space...OutOfMemoryError"

17:17 except to store all this data I made my heap really big, and apparently slime blew up before java :(

17:18 Chousuke: probably swank should bind *print-length* internally :/

17:18 at least for the minibuffer thing

17:19 ambient: trying from user.clj gives error: "unable to establish root binding of: *print-length* with set..."

17:19 Chousuke: try using alter-var-root :)

17:21 somnium: technomancy: how do you execute clojure code through elisp with slime-connected-ook?

17:22 technomancy: somnium: rusty off the top of my head; there's an example in clojure-test-mode

17:22 possibly one in clojure-mode too

17:23 tomoj: maybe this is something slime is doing without swank-clojure explicitly knowing about it?

17:24 technomancy: tomoj: sorry, I don't know much about the actual swank->slime protocol. =\

17:24 tomoj: seems to only happen for vars like *foo*

17:25 I'll poke around sometime and see if I can figure out where this is happening

17:25 technomancy: tomoj: you know about the mailing list?

17:27 tomoj: the clojure one? or swank-clojure, or swank, or slime?...

17:28 technomancy: http://groups.google.com/group/swank-clojure

17:28 tomoj: ah, thanks

17:28 technomancy: just started it a couple days ago

17:43 solussd: why isn't clojure.core automatically available in any namespace?

17:45 technomancy: solussd: are you using in-ns?

17:45 solussd: yes

17:45 technomancy: you should use the ns macro

17:45 it Just Works

17:45 danlarkin:

17:45 technomancy: in-ns is low-level

17:45 solussd: Ok- I just thought it was weird that java.lang is available, but not clojure.core

17:47 ambient: oo, more clojure books on the horizon http://www.apress.com/book/view/1430272317

18:16 rlb: Is there anything like take-while, but that is lazy, and will return up-to and including the stop-value, i.e. (take-up-to-and-including pred coll)?

18:17 ambient: take-while seems to be lazy

18:17 ,(doc take-while)

18:17 clojurebot: "([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."

18:18 hamza: hey guys, i am trying to use velocity from clojure+compojure but i am getting ServletLogChute can not be initialized. it used to work until i added compojure jars in to classpath can anyone tell me what may cause this?

18:18 rlb: ambient: right - the key bit I was interested in is "up-to-and-including"

18:19 ambient: ,(take-while #(<= % 5) (range 10))

18:19 clojurebot: (0 1 2 3 4 5)

18:21 ambient: ,(conj (take-while #(< % 5) (range 10)) 5)

18:21 clojurebot: (5 0 1 2 3 4)

18:22 rlb: right, but that won't work if you want everything up to and including the first occurrence of 42 in a lazy sequence of random integers.

18:22 Of course I can write what I want -- just wondered if there was already soemething there.

18:22 ambient: just add the 42 to the end manually

18:23 rlb: ambient: say you're matching for all lines up to and including the first one that starts with "OK"

18:23 (and you're reading from a socket, for example)

18:24 Anyway, take-up-to-and-including is easy, though I need a better name...

18:24 ambient: yeah, that is a bit more tricky then

18:25 technomancy: it's lame, but you could swap an atom in your predicate function that would get checked on the next call

18:25 ambient: technomancy i dont think that's lame. it's how reductions is done

18:26 technomancy: ambient: I mean it's lame if it clutters your predicate

18:26 it's not lame as a strategy if you abstract it away

18:26 ambient: ok :)

18:39 technomancy: so... metadata on deftests... good idea?

18:40 danlarkin: I like it

18:40 but I would

19:14 danlei: there is a reader macro for getting the read-time value of a form, no? (like cl's #.)

19:16 I'm pretty sure there was something like this, but I forgot about it ...

19:17 Chousuke: #=?

19:18 danlei: I guess, yes

19:19 but how to use it, like in CL, I'd do: #.*standard-output*, but #=*out* wont work

19:20 Chousuke: hm, right. it actually only accepts a list form IIRC

19:20 danlei: ok, thanks

19:30 slyrus_: ok, i didn't do my homework (the euler exercies), but I did manage to get rid of the refs (easy) and atoms (a little harder) for my bfs

19:30 lisppaste8: slyrus pasted "bfs without atoms" at http://paste.lisp.org/display/88865

19:33 danlei: ok, I give up :) simple question: how to print something from another thread in my repl thread? I tried things like this: (binding [*out* #=(identity *out*)] ...)

19:37 there must be an easy way to do it, but I just don't have an idea :)

19:37 *any

19:53 Chousuke: danlei: something like (let [repl-out *out*] (run-in-thread (binding [*out* repl-out] (code))))?

19:54 danlei: Chousuke: yes

19:57 Chousuke: the outer let is necessary, that's what I was missing. thanks

20:07 timothypratley: Is there any way to 'switch on arity': If f is inc then call (f a) if f is + call (f a b)? like (take-args f a b) if f is inc it will ignore b?

20:08 aldebrn: I'm having some trouble figuring out how to get arbitrary precision floats, e.g., exp(-1000) ?

20:13 Or, e.g., (exp (bigdec -1000)) , is still 0 instead of something more useful. Any hints, much appreciated

20:14 hiredman: what is exp?

20:14 ,(doc exp)

20:14 clojurebot: "clojure.contrib.generic.math-functions/exp;[[x]]; Return the exp of x."

20:14 hiredman: that exp?

20:14 ~def exp

20:15 aldebrn: Yeah that exp, exponentiation base e

20:15 Ah it looks like it's just using Java's exp, which probably doesn't know about BigDecimal...?

20:15 Or ... I may be mistaken

20:17 timothypratley: user=> 1e-1000M

20:17 1E-1000M

20:17 (+ 1 1e-1000M) -

20:17 -> spam

20:18 does that help?

20:19 hiredman: it looks like generic math provides extendable versions of the java math methods, but doesn't extend them

20:23 you can do something like (defmethod exp [java.lang.BigDecimal] [n] math here)

20:23 aldebrn: I'm just coming to Clojure from Matlab/Python because I love Lisp, would extending exp to handle BigDecimal be a Clojure core contribution or would it be handled in something else like Incanter, e.g.?

20:23 hiredman: aldebrn: well the generic math stuff isn't even in the core

20:23 that is in contrib

20:24 have you looked at the javadoc for BigDecimal?

20:26 aldebrn: hiredman, tell me how? (doc bigdec) seems terse

20:26 Ohh the Java documentation, ok.

20:28 hiredman: ,(use 'clojure.contrib.generic.math-functions)

20:28 clojurebot: nil

20:28 hiredman: ,(exp e 1)

20:28 clojurebot: java.lang.Exception: Unable to resolve symbol: e in this context

20:28 hiredman: bah

20:28 timothypratley: user=> (.scaleByPowerOfTen 1M -1000)

20:28 1E-1000M

20:28 hiredman: ,(exp 1)

20:28 clojurebot: 2.7182818284590455

20:30 aldebrn: I don't know much about how one implements this kind of thing, looking at mpmath's implementation of arbitrary-precision exp (http://tinyurl.com/yk3yxq5), whew, that's intense

20:31 hiredman: so it looks like the main stumbling block is BigDecimal's horrible .pow method

20:32 ,(java.math.BigDecimal. (exp 1))

20:32 clojurebot: 2.71828182845904553488480814849026501178741455078125M

20:32 aldebrn: Noob question: difference between "java.math.BigDecimal." and "bigdec"?

20:33 hiredman: ,(doc bigdec)

20:33 clojurebot: "([x]); Coerce to BigDecimal"

20:33 hiredman: ,(bigdec (exp 1))

20:33 clojurebot: 2.7182818284590455M

20:33 hiredman: interesting

20:34 well the out put of (exp 1) is a Double, I think

20:34 ~def bigdec

20:36 ,(class (exp 1))

20:36 clojurebot: java.lang.Double

20:37 hiredman: ,(bigdec (float (exp 1)))

20:37 clojurebot: 2.7182817459106445M

20:37 hiredman: ,(bigdec (long (exp 1)))

20:37 clojurebot: 2M

20:37 hiredman: nice

20:37 anyway, bigdec seems to lose percision for somereason

20:43 aldebrn: Right :-/ I will use java.math.BigDecimal. in the meantime

20:43 Hopefully my complete ignorance of Java will not be too big a problem.

20:44 hiredman: what you really need is an implementation of pow for [BigDecimal BigDecimal]

20:45 aldebrn: So exp needs a good pow and a good way to approximate e, are you saying the latter is already in place and just needs the former?

20:47 I think I have all the pieces to implement a bit of numerical code related to my research except BigDecimal exp :)

20:48 I've seen this with-precision function in relation to Clojure, but that doesn't seem to change anything

20:49 ,(with-precision 5 (/ 1 3))

20:49 clojurebot: 1/3

20:49 aldebrn: ,(with-precision 5 (/ 1 3.))

20:49 clojurebot: 0.3333333333333333

20:49 aldebrn: ,(with-precision 50 (/ 1 3.))

20:49 clojurebot: 0.3333333333333333

20:49 aldebrn: heh cool

20:50 hiredman: you aren't doing bigdecimal math there

20:50 ,(with-precision 5 (/ 1M 3.))

20:50 clojurebot: 0.3333333333333333

20:50 hiredman: hmmm

20:51 ,(with-precision 2 (/ 1M 3))

20:51 clojurebot: 0.33M

20:51 solussd: ,(with-scale 50 (/ 1 3.))

20:51 clojurebot: java.lang.Exception: Unable to resolve symbol: with-scale in this context

20:52 aldebrn: Gotcha. Maybe I can implement a quick Taylor series expansion for exp for now

21:12 ~def pow

21:13 What's the story with these defmathfn-1 and defmathfn-2 (besides the 1 or 2 gives the arity of the function)

21:14 * aldebrn shoots self in head---I see the macros defined right there

21:15 hiredman: I'm not sure I like generic math

21:16 aldebrn: by tht you mean java.lang.Math?

21:16 hiredman: no, I mean clojure.contrib.generic.math-functions

21:18 aldebrn: Could ou explain your potential dislike?

21:19 hiredman: well, for one thing, as implemented it is just a wrapper over Math.*

21:19 mrpika: is anyone else have troubling view parts of the api page on clojure.org?

21:20 hiredman: but you can go in and flesh it out, but then what happens when some other library you use also fleshes it out, and it not exactly the same way

21:20 aldebrn: For a language as young Clojure, I'm incredibly impressed at how solid its math capabilities are. But I see what you mean

21:21 hiredman: I wonder if anyone is using generic.math-functions

21:22 aldebrn: Luckily there are a number of opensource math libraries that have accumulated plenty of eyeballs to rely on? (As a refugee from Python, I can only cite Numpy, mpmath, Sage)

21:22 (I am about to :-/ but not for extending the library/language)

21:23 hiredman: I've never done any math heavy stuff, so I dunno

21:25 ambient: clojure has incanter, java has colt. those that i've come across

21:27 aldebrn: Incanter looks fabulous, I will risk making an ass of myself by posting there, asking about math functions that support BigDecimal

21:27 hiredman: I've haven't used incanter, but the logo is so slick, it has my vote

21:28 liebke: aldebrn: Incanter doesn't support BigDecimal at the moment, although I think Parallel Colt does, so there is potential to add support in the future

21:28 hiredman: thanks for the logo endorsement :)

21:30 aldebrn: liebke, thanks for the info. Incanter has almost every piece of the puzzle I need for some research code I'm writing (Weiss-Weinstein bounds on estimator mean squared error), I just need BigDecimal exp and will look at Parallel Colt

21:31 hiredman: :)

21:35 aldebrn: liebke, what are your future plans for Incanter?

21:36 liebke: aldebrn: Here's the roadmap as it stood a month ago: http://incanter.wordpress.com/2009/09/03/incanter-roadmap/

21:37 aldebrn: I might have to take back what I said about Parallel Colt supporting BigDecimal :(

21:37 aldebrn: :( on its frontpage I only see single/double

21:37 hiredman: liebke: what font is that, in the logo, btw?

21:38 aldebrn: Am I justified in being very impressed at how complete Incanter is, given that it's only less than 2 years old?

21:39 liebke: hiredman: I'll look it up, I always forget -- I really like it

21:39 aldebrn: thanks, Incanter is less than a year old, but I was able to leverage Parallel Colt and JFreeChart

21:43 hiredman: the font is Garamond

21:43 hiredman: ah, thanks!

21:44 aldebrn: liebke, I take it R is your goal for Incanter. Unreasonable question: do you have any experience with Numpy/Matplotlib's capabilities or Matlab's capabilities? (I suspect I will be asking a number of questions of the Incanter community in coming days, just wondering how to frame them)

21:45 liebke: aldebrn: I've never used Numpy or Matplotlib, but I've heard great things about both

21:55 slyrus_: liebke: is this the R-alike in clojure I've heard vague rumors of?

21:55 liebke: slyrus_: yep

21:59 slyrus_: the suggested google search "incanter's absorption elitist jerks" is clearly not the one i'm looking for

21:59 liebke: :)

22:00 the website is http://incanter.org

22:01 slyrus_: cool. for a while i very much wanted to do something like that in CL and went so far as to build an R<->SBCL bridge, but I've pretty much abandoned the effort.

22:01 doing something R-like with clojure sounds like a great idea.

22:02 liebke: slyrus_: have you seen common-lisp-stat? http://github.com/blindglobe/common-lisp-stat

22:02 slyrus_: no, I haven't seen it lately, but I remember tony was embarking on that

22:15 aldebrn: So any hints on where I would add code to make pow or exp handle BigDecimals? In Incanter, Clojure itself, or Java?

22:16 Meaningless question I know..

22:17 hiredman: I'm not sure how to implement pow

22:17 chouser: BigDecimal has a pow method

22:18 (.pow 5M 10)

22:18 ,(.pow 5M 10)

22:18 clojurebot: 9765625M

22:18 hiredman: chouser: but it takes a double or an int or something

22:18 chouser: yeah, an int

22:19 aldebrn: Is the Java implementation of BigDecimal opensource and hackable? do people regularly fix things like this "upstream" in Javaland, or handle it within Clojure or a library?

22:19 hiredman: to implement exp of a bigdecimal, I think you need something like (.pow e bigdecimal)

22:19 chouser: aldebrn: every time I suggest submitting a patch to the JVM I get laughed at, so that's probably not the way forward.

22:19 hiredman: :P

22:20 aldebrn: (pow (compute-e prec) bigdecimal) does indeed work for some combinations of bigdecimal and prec, but there seems to be faster ways to do it

22:20 in other cases

22:20 chouser: there's a clojure.contrib.math that would probably welcome such things.

22:20 aldebrn: chouser, thanks for the info.

22:20 liebke: aldebrn: hmm, Incanter uses Math/exp for scalar values and Parallel Colt's version of exp for vectors and matrices. So, you could add exp support for BigDecimal scalar values to Incanter, if you're interested

22:21 aldebrn: I'll be very interested in vectorized exp for matrixes down the road liebke

22:21 hiredman: (defmethod pow [java.lang.Number java.lang.BigDecimal] [base exp] some math here)

22:21 aldebrn: But I suspect it'll be challenging enough to do the scalar case, thanks for the suggestion

22:22 liebke: aldebrn: me too :) but that's going to be hard until Parallel Colt does

22:24 chouser: rhickey: any chance function params will ever support :as ?

22:25 aldebrn: liebke, I'll try to port Mpmath's real-valued exp to Clojure and bug this channel/Incanter group: http://tinyurl.com/yk3yxq5

22:25 liebke: aldebrn: that sounds great!

22:27 hiredman: chouser: what do you mean by that?

22:35 slyrus_: liebke: the core of incanter reminds of me of what I was trying to do with my CLEM matrix package for CL, but using colt probably helps greatly with a lot of the heavy lifting

22:36 liebke: have you (or others) tried to get clojure talking directly to an embedded R?

22:36 liebke: slyrus_: yeah, Colt does most of the heavy lifting

22:38 slyrus_: a proper lispy language, java gui stuff, and bioconductor all under one roof would be pretty neat

22:38 liebke: slyrus_: I haven't heard of any attempts to do so

22:38 Could be cool :)

22:41 slyrus_: there must be some R/Java interoperability somewhere

22:41 liebke: slyrus_: I do think there are already bridges between R and Java

22:42 slyrus_: i suppose that would be the place to start

22:42 liebke: RServe has a Java API too

22:44 slyrus_: liebke: hmm... I would think that JNI to R would be the way to go, but, then again, I haven't looked at RServe

22:56 technomancy: liebke: it's good to see you moving away from jars in the git repo

22:56 liebke: technomancy: haha, I thought you would like that :)

22:56 * technomancy had to deal with a 83-MB git repo that only contained three months of history just because they checked _every_ dep into git

22:56 technomancy: took me 40 minutes to push my fork out; it was absurd

22:58 once I get swank mavenized I want to focus my efforts on making it easy for clojure hackers to package their libraries up the right way

22:58 liebke: yes, I saw you tweet about that, I think that's what finally got me to remove the jars from the repository, I didn't want you coming after me next :)

22:58 technomancy: you can be forgiven for checking jars into git right now just because the alternatives are so bad.

22:58 hah!

23:26 lisppaste8: slyrus annotated #88865 "another bfs/dfs iteration" at http://paste.lisp.org/display/88865#1

23:49 solussd: How do I import everything from a java package? e.g., I want to do something like this: (import '(java.swing *))

23:49 *java -> javax

23:50 technomancy: solussd: clojure doesn't work like that

23:50 import what you use

Logging service provided by n01se.net