#clojure logs

2009-10-18

00:01durka42the side-effects part?
00:04jlillypartial is effectively a curry, right?
00:04hiredmanyeah
00:04hiredmandurka42: yeah
00:05hiredman(defn iter [fn init] (lazy-seq (cons init (let [v (fn init)] (cons v (iter fn v))))))
00:05hiredmanmore like what I was hoping for
00:06hiredmanbut it is less lazy then iterate, but I imagine that could be fixed
00:07hiredmanhmm
00:45jlillyI need to do a multi-line thing in a function. Is there something similar to elisp's progn?
00:45jlillythe multi-line thing is: print line, read line.
00:46fanaticoM-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?
00:46tomojfanatico: do you have clojure.jar in lib/?
00:47fanaticoIsn't that available via swank-clojure-jar-path?
00:47tomojno
00:47tomojswank-clojure-project wants you to put _everything_ in the project dir
00:48hiredmanjlilly: do?
00:48tomojafaik. you could hack it to look for clojure elsewhere
00:48jlilly,(doc do)
00:48clojurebotPardon?
00:48tomojjlilly: functions are implicit progns
00:48jlillythat's a functioN?
00:48fanaticotomoj: thanks.
00:48tomoj(defn foo [] (bar) (baz))
00:48jlillydefn?
00:48jlillyhmm. I'll try that.
00:49tomojif you didn't know defn... what the heck where you doing before? :)
00:49hiredmanfns have an implicit do
00:49hiredman,(do 'this 'that)
00:49clojurebotthat
00:49jlillyI forgot to do the [] :)
00:50hiredman,(do (pr :a) (pr :b))
00:50clojurebot:a:b
00:50tomojfanatico: I guess maybe it's so we can use different clojure versions in different projects easily? dunno
00:53fanaticotomoj: that makes sense. Still seems wrong to not restore the classpath vars.
00:53tomojyeah
00:54tomojI guess if you have special vars you should write a wrapper around the slime clojure startup that sets them
01:04technomancyfanatico: swank-clojure-project expects projects to be entirely self-contained
01:04technomancyI suppose it'd be convenient if it didn't have to affect the default settings though
01:06technomancyif you feel strongly about it, feel free to open an issue on the github project or discuss it on the mailing list
01:08fanaticotechnomancy: 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.
01:09technomancygreat
01:18jlillyso, in the slime repl, I run (read-line). how can I exit it?
01:19jlillyI've been killing the repl, but I can't actually test anything with (read-line) in it.
01:25tomojjlilly: one possibility is to switch over to *inferior-lisp* to test those functions
01:26bryteisedo you need to restart the *inferior-lisp* then?
01:27tomojI don't think so? not sure what you mean
01:28technomancythat's a known bug; the IO streams aren't hooked up properly
01:28tomojis slime supposed to be able to handle this? (testing with sbcl now)
01:28bryteisehrm im probably confused and thinking of something else
01:28technomancywell; *in* isn't at least... waiting for someone who actually uses *in* to fix it. =)
01:29tomojfyi: yes, it works fine with sbcl
01:39bryteiseis 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)
01:40technomancybryteise: swank-clojure-project will pick up deps in target/dependency automatically
01:41bryteiseah okay, awesome.
01:42technomancystuart'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.
01:43technomancypersonally I like making my projects descend from clojure-pom; seems like the cleanest way to handle dependencies so far
01:43technomancybut since there's not post-1.0 build of clojure in the centralized repos, it's messy all around
01:44technomancyI'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.
02:35vyWhy 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?
02:35jlillyhow do I "run" a clojure file?
02:35vyjlilly: java -cp clojure.jar clojure.main /path/to/myscript.clj
02:36vyjlilly: See http://clojure.org/repl_and_main
02:39jlillythx
03:01jlillyhttp://dpaste.de/bWQs/ having some issues with my classpath. Anyone able to take a look?
03:04arbschtclojurebot: classpath
03:04clojurebotclasspath is (System/getProperty "java.class.path")
03:05arbschthttp://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html
03:06hiredmanjlilly: -cp and -jar are mutually exclusive
03:07jlillyI see.
03:59jamesswifthey folks. would like some advice on the proper clojure way to do the following http://paste.lisp.org/+1WJ9
03:59jamesswifti.e. find the neighbours of a location in an array
04:11hiredmanwell thats good to know...
04:11jamesswift*cough* er yeah
04:12hiredmanI'd user for to remove all that duplicate code
04:15jamesswiftwell 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
04:33jamesswifti'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
04:41hiredmanI am pretty sure you can collapse both those for's and get rid of the ifs
04:44hiredmanalthough, I guess that would end up making a flat list
04:52jamesswiftyeah i would like to keep the structure, so far i have this http://clojure.pastebin.com/m768e9c50 (the lisp paste is down atm)
06:09spuzI'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
06:09spuzI do (:require clojure.contrib.profile) but I get java.lang.ClassNotFoundException: clojure.contrib.profile
06:09spuzwhen I look in the clojure-contrib.jar, I see many .clj files but not many corresponding .class files. Is that normal?
06:11serp_spuz: did you perform any further work on the mandelbrot visualizer?
06:12spuzserp_: I'm trying to optimise it at the moment :)
06:12serp_you should probably consider adding multiple samples per pixel
06:12serp_it'll make it look a lot better
06:12spuzvisual vm is not playing very nice though so I'm trying to use the contrib profile library...
06:13spuzserp_: 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
06:22Chousukespuz: you cloned it with git or downloaded some other way?
06:22spuzChousuke: cloned it
06:25Chousukehmmh
06:26Chousukemaybe the profile namespace requires AOT-compilation (which with contrib is only done if you supply the path to clojure.jar)
06:29spuzChousuke: I did ant -Dclojure.jar=../clojure/clojure.jar
06:32spuzChousuke: what I'm wondering, is should all the .clj files be compiled into .class files as part of that build?
06:33Chousukemost, anyway
06:33Chousukebut it shouldn't really matter whether they're compiled or not
06:33Chousukeexcept for the few namespaces that use gen-class
06:38spuzhmm ok
07:07spuzChousuke: Would you expect this to work?
07:07spuzjava -cp "clojure/clojure.jar;clojure-contrib/clojure-contrib.jar" clojure.contrib.repl_ln
07:07Chousukehmmh
07:08spuzThis 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
07:08ChousukeI'm not sure if the -cp switch supports relative paths
07:08spuzbut when I swap them out for the jars included with the CCW plugin, it works fine
07:08spuzChousuke: yes, it does
07:08Chousukeah, and the clojure-contrib jar needs to be AOT-compiled
07:09Chousukeso if you don't have the class files in the jar it won't work.
07:09spuzah ok
07:09spuzI guess there's a special way of doing that... :)
07:09Chousukewell ant -Dclojure.jar=/path/to/clojure.jar should work
07:10Chousukemaybe a relative path doesn't owrk
07:10Chousukework
07:10spuzChousuke: I'll try the full path
07:13spuzChousuke: full or relative path has the same effect
07:14spuzif I specify the path incorrectly then it complains
07:14spuzso it must be finding clojure.jar
07:14spuzit seems that AOT compilation is only done for a small set of clj libraries
08:19ambient *SLIME compilation* telling me on which line the error happened would be a huge help
08:19ambient"argument type mismatch"
08:21ambientit's always "foosouce.clj:0"
08:22LauJensenambient, for what its worth, that usually means it's something in your main ns declaration, or one of the dependencies it's pulling in
08:22ambienti got just this one source file so yes, that might be the case :p
08:23ambientbut debuggers are a crutch anyway, eh? ;)
08:26LauJensenWell... :) Clojure backtraces have been the source of many tears
08:27licoresseI loathe them backtraces
08:27ambienti've got my analog modelling synth basics now in place: http://paste.pocoo.org/show/145620/
08:27ambientbut it's a bit slower than i want it to be :/
08:27LauJensenWhat can I do with it ?
08:27ambientmy paste? at the moment just run it
08:28ambientlater i wlil add sliders and midi input to modify state
08:41mccraigi 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 ?
08:42somniummccraig: what's the exception?
08:43mccraigNPE
08:44somniummccraig: afaik NO_SOURCE_FILE means its calling something defined in the repl
08:45mccraigright, but i'm putting the def in a file and either (load "foo") or (require 'foo) it
08:45mccraigboth ways i'm not getting line number info
08:45somniummccraig: if you compile a file with a namespace it can give you more info
08:45somniumare you using slime?
08:47mccraigthere is a namespace in the file. it's not helping
08:47mccraigi'm not using slime
08:47mccraigusing a raw repl
08:47somniummccraig: maybe it will be easier to help if you paste the file and part of the exception
08:50mccraighttp://gist.github.com/212667
08:51mccraigis a simplest case reduction
08:51mccraig(use 'foo) (oops)
08:51mccraiggives me a RuntimeException with NO_SOURCE_FILE
08:54mccraigjava.lang.RuntimeException: boo (NO_SOURCE_FILE:0)
08:54somniumthats what it should do
08:54somniumit throws the exception, prints your message, and there's no source because its all defined in the repl
08:58mccraigno, the namespace is in file "foo.clj", which i load with (use 'foo)... it's not defined in the repl
09:00lisppaste8spuz pasted "Type hinted function" at http://paste.lisp.org/display/88831
09:01spuzHey, 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.
09:03spuzany idea how I can find out why the type hint is not doing anything?
09:03Chousukespuz: maybe there is an overload of the setpixel and it can't figure out the correct one?
09:04Chousuke+method :P
09:05spuzApparently, this is the actual implementing class: http://www.docjar.com/docs/api/sun/awt/image/IntegerInterleavedRaster.html
09:05spuzHowever, setPixel only appears to be defined as part of the WritableRaster interface
09:06spuzor class even...
09:06Chousukethe typehint should be okay for the wr
09:06Chousukevariable
09:07Chousukebut I think you need to typehint the parameters
09:07Chousuketry (int x) (int y) #^ints (int-array ..)
09:12somniummccraig: when you type (foo) at the repl there is no source file for that (foo) you just typed
09:12somniummccraig: try putting (foo) under the definition of foo and executing it, you'll get a line number
09:16spuzChousuke: that seems to help, the setPixel reflection warning has gone now too :)
09:16spuzimproves the speed by a few seconds
10:00cypher23Is there another way to "flatten" a list than (apply concat '((1 2 3) (4 5 6)))?
10:13rottcoddcypher23: there is also clojure.contrib.seq-utils/flatten
10:14cypher23rottcodd, exactly what I was looking for, thanks
10:18ambienthttp://paste.pocoo.org/show/145638/ anyone got some performance tips for me? using a lot of atoms and maps
10:18ambientshould i just do every data structure with a vector instead?
10:18ambienti mean array
10:22ambientare there any programs/examples done with clojure where there is a lot of dealing with mutable state with high-performance?
10:26spuzambient: have a look at LauJensen's Transient Brain: http://blog.bestinclass.dk/index.php/2009/10/brians-transient-brain/
10:26ambientit's not exactly very high performance, afaict :p
10:27ambientoh yes, transients, i have to look at those
11:18LauJensenNew blog post - Python vs Clojure: Reloaded - http://blog.bestinclass.dk/index.php/2009/10/python-vs-clojure-reloaded/
11:18LauJensenI took the advice of a few Python users and worked on Rosetta a bit :)
11:19somniumLauJensen: where'd you get the cool cobra?
11:19LauJensenIt's still there
11:20somniumer, I guess its a hooded-python?
11:20LauJensenambient, 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:21LauJensenI'm off again, good evening
11:21ambientwell i could probably do it with numpy a lot faster, but I don't want to insult anyone's sense of aesthetics
11:21ambientevening
11:21licoresseI don't get this line-counting-thing
11:28rhickeyus vs them doesn't help us at all
11:30ChousukeLauJensen: I think the function used in reduce would be more readable if you didn't use #() so much
11:31LauJensenrhickey, I liked the one you did in that programming magazine though, where you slapped Scala, Erlang and a third I don't remember :)
11:31LauJensenI couldn't help feeling a little inferior for taking 1 language at a time
11:31LauJensenChousuke, isn't that usually the case ? :)
11:31ChousukeLauJensen: also the icky sort call is equivalent to (sort-by :salary < data) if I'm not mistaken
11:31rhickeyLauJensen: where?
11:32LauJensenrhickey, you were interviewed by some journal, their first edition I believe. I had a PDF somewhere...
11:33LauJensenChousuke, really? That would be fantastic
11:33rhickeyan 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:34LauJensenrhickey, 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:35licoresseLauJensen: But I need to find out this by myself
11:35rhickeyLauJensen: you are of course free to write whatever you wish, but it doesn't help Clojure IMO to do us vs them
11:36ambientpersonally, i find well done comparisons between languages interesting, but understand that they can generate epic flame wars
11:36LauJensenrhickey, alright - your oppinion counts, I'll take it into consideration
11:36sproingienot sure why the python code in "Top-rank per group" isn't using dicts
11:37sproingiealso the lambda for the key arg for sorted belies a lack of knowledge of operator.itemgetter
11:37rhickeyunless one is an expert in both, you will inevitably shortchange 'them'
11:37somniumLauJensen: are there limits on what libraries you can use to produce the shortest code?
11:37rhickeyand that will just make 'them' angry and unreceptive
11:38LauJensenrhickey, 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:38LauJensensomnium, I don't know - Didn't read the fine print :)
11:39sproingiethe python code using minidom is also an odd choice, python typically prefers etree instead
11:40somniumruby + nokogiri shouldn't be 35 lines, not sure if limited to std library
11:40somniumbut it was interesting, I learned something about python and clojure
11:40sproingietho it's unlikely etree would have made it any shorter
11:43LauJensensomnium, yea I think Python also came across pretty well
11:43sproingiesomnium: the libraries that ship with the standard language distribution i imagine
11:44ChousukeLauJensen: http://gist.github.com/212716
11:44sproingieexcept perhaps for languages where not using a library would be unthinkable, e.g. doing proper xml in C++
11:45somniumsproingie: that gives me a shiver
11:45LauJensenChousuke, aah that's cool
11:45LauJensenYou should drop a link in a comment
11:46Chousukeactually
11:46sproingieC++ for example uses boost for some of its stuff, the solution just mentions that it's using boost
11:47LauJensenDid you guys all know about Rosetta before this post? I never heard of it..
11:47Chousuke(doc group-by)
11:47clojurebot"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:47Chousuketoo bad that's not in core :P
11:47Chousukeyour entire departments thing would become (group-by :department (sort-by :salary data))
11:48sproingiehaskell's got a groupBy in prelude but it relies on the data being sorted first
12:17mccraigah, got it. (.printStackTrace *e) gives me all the line numbers i want
13:36ambientdon't know why but classpaths stopped working after updating clojure-mode :/
13:36ambientthe trick of "(setq swank-clojure-extra-classpaths (list "foobar"))" doesn't work anymore
13:38Chousukeit's not extra-classpaths anymore
13:38Chousukeit's just swank-clojure-classpath
13:38ambientthanks :)
13:38Chousukeand the swank-clojure-jar variable went away too
13:38ambientyou probably just saved me hours
13:52ambientseems there's no real practical difference between using arrays and atoms
13:53ambientat least according to my benchmarks. except arrays are more difficult to manage
13:53LauJensenambient, did you see cgrands last post on arrays ? (multi-dim)
13:53ambientnope
13:53LauJensenhttp://clj-me.cgrand.net
13:53LauJensenHe's writte a couple of times on how to get big performance wins
13:54maaclLauJensen: har du en ide om hvorfor (use 'clojure.test) lige pludselig fejler?
13:54ambientcool. ty
13:54LauJensenmaacl, desværre, har aldrig brugt det
13:54maaclLauJensen: ok
13:54maaclLauJensen: Du går måske ikke ind for tests :-)
13:55ambientLauJensen 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:55LauJensenmaacl, it's best to stick with english in an english speaking chan :) And yes, I do approve of tests, under the right circumstances
13:55ambientone would think that concurrent constructs would introduce significant overhead
13:55maaclLauJensen: ok
13:56djpowellI just posted my live-repl thing on github btw if anyone's interested <http://github.com/djpowell/liverepl&gt;. Lets you hack a clojure repl into any running java or clojure process.
13:56hiredman:( this paper on jvm tail calls lists Clojure under common lisp implementations
13:57LauJensendjpowell, nice, will check it out
13:58ambienthere's the code for both: http://paste.pocoo.org/show/145687/
14:00LauJensendjpowell, that's really great man, nice work
14:01Chousukeambient: type hint the arrays
14:02Chousukeambient: when using arrays there can be reflection that clojure won't warn about, even with *warn-on-reflection* set :/
14:03ChousukeI wonder if that can be fixed
14:03ambientwell *warn-on-reflection* doesn't at least say anything
14:03Chousukeit won't help with arrays :)
14:03ambientaha
14:05ambientwonder how fast java does this, but currently it's rendering 88k in 0.170 seconds. which is something like 500k ops per second
14:05Chousukethe only way to tell if your array accesses are reflected is to use a profiler :P
14:06ambientthere would be some clojure.lang.reflection.foo popping up in the list?
14:06Chousukesomething like that anyway
14:06ambientnah, nothing that i can see
14:12Chousukemight be java.lang.reflect something too
14:12ambientsimple (time (doseq [i (range 88000)] i)) already takes 60 msec so i doubt there's much reflection
14:15Chousukemight be boxing too
14:15Chousukeremember that function arguments are always boxed
14:17ambientah, forgot dotimes. it is 3 msec
14:23ambientoh yes. 170 > 30 msec. im happy
14:23ambientjust did (double foo) inside let
14:23ambientfor all variables
14:24ambientfor future reference, i had an actual reflection error with an array and instead of 30 msec it gave me 5000 msec ;)
14:27licoresseIs there a way to automatically load code when starting up clojure?
14:28licoresselike putting something in a . folder...?
14:28LauJensenlicoresse, user.clj on the classpath will automatically load
14:28LauJensenambient, link to the code you just optimized?
14:28LauJensenChousuke, could you explain boxing ?
14:28licoresseah, thanks
14:28dandersenChousuke: You do Clojure nowadays?
14:29ambientLauJensen something just happened to my emacs, will take a sec
14:29LauJensenk
14:29ambientlike it permanently colored a portion of my code :/
14:29ambienthttp://paste.pocoo.org/show/145692/
14:30LauJensenambient, funny I tried that yesterday
14:30opqdonutthat's irritating
14:30Chousukedandersen: it's fun :P
14:30opqdonutthere was some function to re-syntaxcolor the buffer
14:30dandersenChousuke: 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:31LauJensenambient, thanks
14:32ChousukeLauJensen: boxing is what we call wrapping a primitive value in one of the corresponding classes :P
14:32Chousukedandersen: heh, well, I suppose you'll have to convert everyone to clojure ;P
14:33Chousukefor me it's just a hobby for now :/
14:33dandersenChousuke: I heard about something called "AOT", and being able to use Clojure code from Java.
14:34dandersenChousuke: As you know, I use CL most of the time. I only started actually looking into Clojure yesterday. =P
14:35ChousukeAOT means ahead-of-time compilation. basically compiling your clojure files to class files :P
14:36djpowellalternatively you can use the RT class to dynamically call clojure from java
14:36Chousukethe java devs will complain :D
14:52dandersenChousuke: I'm not sure I understand just how it works in reality, but I guess I'll just have to learn Clojure. =]
15:14licoresseI've added user.clj to the /src directory (which is in my classpath), but clojure don't pick it up when at startup
15:14licoresseWhat am I doing wrong?
15:15ambient(dolist (d (list "path/to/your/stuff")) (add-to-list 'swank-clojure-classpath d)) to your ~/.emacs
15:15licoressenevermind, found it...
15:15ambientah, nvm. i should read first
15:15licoresseit was called userS.clj
15:15licoresseambient: thanks anyway
15:35LauJensenIs there some help/tut/doc out there on how to use reductions?
15:41ambientdoes clojure yet have any supporting swing libs? like swingbuilder for groovy http://groovy.codehaus.org/Swing+Builder
15:42ambient,(reductions + (range 10))
15:42clojurebotjava.lang.Exception: Unable to resolve symbol: reductions in this context
15:42ambient:(
15:42ambientreductions is irreplaceable, honestly
15:44LauJensenambient, there are a few things, did you check out my blog MacSwing meets Enlive? That's one approach, another is something like Miglayout
15:46arohnergiven a class name, is it possible to figure out whether it is an interface or a real class?
15:46arohnerI want supers, but I want to filter out the real classes
15:46ambientLauJensen yeah, that looks nice but it's Mac :) won't fit into my environment where everything is gray, bland and edged
15:47rhickey_,(.isInterface Callable)
15:47clojurebottrue
15:47rhickey_(.isInterface Object)
15:47rhickey_,(.isInterface Object)
15:47clojurebotfalse
15:47arohnerrhickey_: thanks
15:47LauJensenambient, 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:48ambientok, i have to grok that then
15:50LauJensenI sent you the code in a priv
16:14technomancyambient: that's odd; swank-clojure-extra-classpaths still exists as an alias to swank-clojure-classpath
16:14technomancyif you modify one it modifies the other.
16:15ambient*shrug* it just simply didn't work for me
16:15technomancyambient: emacs 22?
16:15ambienti did (setq swank-clojure-extra-classpaths (list "foo" "bar"))
16:15ambientyes, on win32
16:16technomancyworks on 23... didn't realize that was a new feature. =\
16:16ambientgnu emacs 23.1.50.1 (i386-mingw-nt6.0.6002) of 2009-06-30
16:16technomancyand the value of swank-clojure-classpath isn't affected?
16:17ambienti dont really know much about elisp, just the bare necessities to get something set up
16:18ambienttechnomancy here's my .emacs http://paste.pocoo.org/show/145721/
16:22technomancyunfortunately I don't have the resources to test exhaustively
16:49tomojsomething Very Bad just happened :(
16:49tomojhttp://img190.yfrog.com/img190/5002/sshotx.png
16:51tomojthe 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:55tomojdoes any of that look vaguely familiar to anyone? :(
16:58tomojlooks 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:59ambientdo you have *print-length* set?
17:00ambienta simple (range 1000000) will kill my emacs if it's not set to some sensible value
17:00hiredmanbut he is not printing the seq
17:00hiredmanhe is counting it
17:02hiredmantomoj: have you tried to manually count it? (loop [s some-seq count 0] (if (seq s) (recur (rest s) (inc count)) count))
17:03tomojmaybe an error is thrown, and part of the output is all of my data? is that possible, I wonder?
17:04hiredmanhmmmm
17:05technomancybleh; clojure is still called clojure-lang in the pom?
17:05technomancyI thought that had been fixed?
17:06tomojmanually counting causes the same freakout
17:07hiredmantime to start wrapping stuff in (try (catch Exception e (.printStacktrace e)))
17:09tomojwow
17:09tomojsetting *print-length* to 3 made the count call return immediately
17:09tomoj(with no errors)
17:10tomojWTF?
17:11tomojI set! *print-length* to 3, counted, worked fine. same for 30, 300, 3000, 30000, and 300000.
17:11hiredmaninteresting
17:11tomojthen I set! *print-length* to nil, and that call never returned, emacs blew up as before
17:11tomojnot on the subsequent count I was going to do, but on set!ing *print-length* to nil
17:12ambienti get different amount of freezing depending on which type of functions i try to print
17:12tomoj(set! *print-length* nil) shouldn't be printing anything, should it?
17:12ambientsometimes it freezes just the repl, sometimes the whole emacs comes unresponsive
17:12tomojbesides, maybe, "nil"
17:12tomojsomething seems seriously fucked up
17:12ambienti'd thing print-length of nil meant if was infinite
17:13tomojOOH
17:13tomojI think I know what's happening
17:13tomojI bet it's the stupid trick where when you point at a variable, it prints the value in the minibuffer
17:14ambientheh
17:14tomojand my value is hundreds of thousands of lines long
17:14Chousukeheh
17:14Chousukethat would be dangerous with infinite seqs :P
17:15tomojhuh, I wonder why that's never bitten me before
17:15ambienton a related note, anyone know how to automatically set *print-length* on emacs start?
17:15ambientor M-x slime
17:16somniumambient: put it in user.clj?
17:16technomancyambient: you can use slime-connected-hook
17:17tomojhahaha, yeah. (def *bar* (iterate inc 1)) RET *bar* <wait a few seconds> "Java heap space...OutOfMemoryError"
17:17tomojexcept to store all this data I made my heap really big, and apparently slime blew up before java :(
17:18Chousukeprobably swank should bind *print-length* internally :/
17:18Chousukeat least for the minibuffer thing
17:19ambienttrying from user.clj gives error: "unable to establish root binding of: *print-length* with set..."
17:19Chousuketry using alter-var-root :)
17:21somniumtechnomancy: how do you execute clojure code through elisp with slime-connected-ook?
17:22technomancysomnium: rusty off the top of my head; there's an example in clojure-test-mode
17:22technomancypossibly one in clojure-mode too
17:23tomojmaybe this is something slime is doing without swank-clojure explicitly knowing about it?
17:24technomancytomoj: sorry, I don't know much about the actual swank->slime protocol. =\
17:24tomojseems to only happen for vars like *foo*
17:25tomojI'll poke around sometime and see if I can figure out where this is happening
17:25technomancytomoj: you know about the mailing list?
17:27tomojthe clojure one? or swank-clojure, or swank, or slime?...
17:28technomancyhttp://groups.google.com/group/swank-clojure
17:28tomojah, thanks
17:28technomancyjust started it a couple days ago
17:43solussdwhy isn't clojure.core automatically available in any namespace?
17:45technomancysolussd: are you using in-ns?
17:45solussdyes
17:45technomancyyou should use the ns macro
17:45technomancyit Just Works
17:45danlarkin
17:45technomancyin-ns is low-level
17:45solussdOk- I just thought it was weird that java.lang is available, but not clojure.core
17:47ambientoo, more clojure books on the horizon http://www.apress.com/book/view/1430272317
18:16rlbIs 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:17ambienttake-while seems to be lazy
18:17ambient,(doc take-while)
18:17clojurebot"([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
18:18hamzahey 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:18rlbambient: right - the key bit I was interested in is "up-to-and-including"
18:19ambient,(take-while #(<= % 5) (range 10))
18:19clojurebot(0 1 2 3 4 5)
18:21ambient,(conj (take-while #(< % 5) (range 10)) 5)
18:21clojurebot(5 0 1 2 3 4)
18:22rlbright, 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:22rlbOf course I can write what I want -- just wondered if there was already soemething there.
18:22ambientjust add the 42 to the end manually
18:23rlbambient: say you're matching for all lines up to and including the first one that starts with "OK"
18:23rlb(and you're reading from a socket, for example)
18:24rlbAnyway, take-up-to-and-including is easy, though I need a better name...
18:24ambientyeah, that is a bit more tricky then
18:25technomancyit's lame, but you could swap an atom in your predicate function that would get checked on the next call
18:25ambienttechnomancy i dont think that's lame. it's how reductions is done
18:26technomancyambient: I mean it's lame if it clutters your predicate
18:26technomancyit's not lame as a strategy if you abstract it away
18:26ambientok :)
18:39technomancyso... metadata on deftests... good idea?
18:40danlarkinI like it
18:40danlarkinbut I would
19:14danleithere is a reader macro for getting the read-time value of a form, no? (like cl's #.)
19:16danleiI'm pretty sure there was something like this, but I forgot about it ...
19:17Chousuke#=?
19:18danleiI guess, yes
19:19danleibut how to use it, like in CL, I'd do: #.*standard-output*, but #=*out* wont work
19:20Chousukehm, right. it actually only accepts a list form IIRC
19:20danleiok, thanks
19:30slyrus_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:30lisppaste8slyrus pasted "bfs without atoms" at http://paste.lisp.org/display/88865
19:33danleiok, 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:37danleithere must be an easy way to do it, but I just don't have an idea :)
19:37danlei*any
19:53Chousukedanlei: something like (let [repl-out *out*] (run-in-thread (binding [*out* repl-out] (code))))?
19:54danleiChousuke: yes
19:57danleiChousuke: the outer let is necessary, that's what I was missing. thanks
20:07timothypratleyIs 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:08aldebrnI'm having some trouble figuring out how to get arbitrary precision floats, e.g., exp(-1000) ?
20:13aldebrnOr, e.g., (exp (bigdec -1000)) , is still 0 instead of something more useful. Any hints, much appreciated
20:14hiredmanwhat is exp?
20:14hiredman,(doc exp)
20:14clojurebot"clojure.contrib.generic.math-functions/exp;[[x]]; Return the exp of x."
20:14hiredmanthat exp?
20:14hiredman~def exp
20:15aldebrnYeah that exp, exponentiation base e
20:15aldebrnAh it looks like it's just using Java's exp, which probably doesn't know about BigDecimal...?
20:15aldebrnOr ... I may be mistaken
20:17timothypratleyuser=> 1e-1000M
20:17timothypratley1E-1000M
20:17timothypratley(+ 1 1e-1000M) -
20:17timothypratley-> spam
20:18timothypratleydoes that help?
20:19hiredmanit looks like generic math provides extendable versions of the java math methods, but doesn't extend them
20:23hiredmanyou can do something like (defmethod exp [java.lang.BigDecimal] [n] math here)
20:23aldebrnI'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:23hiredmanaldebrn: well the generic math stuff isn't even in the core
20:23hiredmanthat is in contrib
20:24hiredmanhave you looked at the javadoc for BigDecimal?
20:26aldebrnhiredman, tell me how? (doc bigdec) seems terse
20:26aldebrnOhh the Java documentation, ok.
20:28hiredman,(use 'clojure.contrib.generic.math-functions)
20:28clojurebotnil
20:28hiredman,(exp e 1)
20:28clojurebotjava.lang.Exception: Unable to resolve symbol: e in this context
20:28hiredmanbah
20:28timothypratleyuser=> (.scaleByPowerOfTen 1M -1000)
20:28timothypratley1E-1000M
20:28hiredman,(exp 1)
20:28clojurebot2.7182818284590455
20:30aldebrnI 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:31hiredmanso it looks like the main stumbling block is BigDecimal's horrible .pow method
20:32hiredman,(java.math.BigDecimal. (exp 1))
20:32clojurebot2.71828182845904553488480814849026501178741455078125M
20:32aldebrnNoob question: difference between "java.math.BigDecimal." and "bigdec"?
20:33hiredman,(doc bigdec)
20:33clojurebot"([x]); Coerce to BigDecimal"
20:33hiredman,(bigdec (exp 1))
20:33clojurebot2.7182818284590455M
20:33hiredmaninteresting
20:34hiredmanwell the out put of (exp 1) is a Double, I think
20:34hiredman~def bigdec
20:36hiredman,(class (exp 1))
20:36clojurebotjava.lang.Double
20:37hiredman,(bigdec (float (exp 1)))
20:37clojurebot2.7182817459106445M
20:37hiredman,(bigdec (long (exp 1)))
20:37clojurebot2M
20:37hiredmannice
20:37hiredmananyway, bigdec seems to lose percision for somereason
20:43aldebrnRight :-/ I will use java.math.BigDecimal. in the meantime
20:43aldebrnHopefully my complete ignorance of Java will not be too big a problem.
20:44hiredmanwhat you really need is an implementation of pow for [BigDecimal BigDecimal]
20:45aldebrnSo 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:47aldebrnI think I have all the pieces to implement a bit of numerical code related to my research except BigDecimal exp :)
20:48aldebrnI've seen this with-precision function in relation to Clojure, but that doesn't seem to change anything
20:49aldebrn,(with-precision 5 (/ 1 3))
20:49clojurebot1/3
20:49aldebrn,(with-precision 5 (/ 1 3.))
20:49clojurebot0.3333333333333333
20:49aldebrn,(with-precision 50 (/ 1 3.))
20:49clojurebot0.3333333333333333
20:49aldebrnheh cool
20:50hiredmanyou aren't doing bigdecimal math there
20:50hiredman,(with-precision 5 (/ 1M 3.))
20:50clojurebot0.3333333333333333
20:50hiredmanhmmm
20:51hiredman,(with-precision 2 (/ 1M 3))
20:51clojurebot0.33M
20:51solussd,(with-scale 50 (/ 1 3.))
20:51clojurebotjava.lang.Exception: Unable to resolve symbol: with-scale in this context
20:52aldebrnGotcha. Maybe I can implement a quick Taylor series expansion for exp for now
21:12aldebrn~def pow
21:13aldebrnWhat's the story with these defmathfn-1 and defmathfn-2 (besides the 1 or 2 gives the arity of the function)
21:15hiredmanI'm not sure I like generic math
21:16aldebrnby tht you mean java.lang.Math?
21:16hiredmanno, I mean clojure.contrib.generic.math-functions
21:18aldebrnCould ou explain your potential dislike?
21:19hiredmanwell, for one thing, as implemented it is just a wrapper over Math.*
21:19mrpikais anyone else have troubling view parts of the api page on clojure.org?
21:20hiredmanbut 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:20aldebrnFor a language as young Clojure, I'm incredibly impressed at how solid its math capabilities are. But I see what you mean
21:21hiredmanI wonder if anyone is using generic.math-functions
21:22aldebrnLuckily 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:22aldebrn(I am about to :-/ but not for extending the library/language)
21:23hiredmanI've never done any math heavy stuff, so I dunno
21:25ambientclojure has incanter, java has colt. those that i've come across
21:27aldebrnIncanter looks fabulous, I will risk making an ass of myself by posting there, asking about math functions that support BigDecimal
21:27hiredmanI've haven't used incanter, but the logo is so slick, it has my vote
21:28liebkealdebrn: 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:28liebkehiredman: thanks for the logo endorsement :)
21:30aldebrnliebke, 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:31hiredman:)
21:35aldebrnliebke, what are your future plans for Incanter?
21:36liebkealdebrn: Here's the roadmap as it stood a month ago: http://incanter.wordpress.com/2009/09/03/incanter-roadmap/
21:37liebkealdebrn: I might have to take back what I said about Parallel Colt supporting BigDecimal :(
21:37aldebrn:( on its frontpage I only see single/double
21:37hiredmanliebke: what font is that, in the logo, btw?
21:38aldebrnAm I justified in being very impressed at how complete Incanter is, given that it's only less than 2 years old?
21:39liebkehiredman: I'll look it up, I always forget -- I really like it
21:39liebkealdebrn: thanks, Incanter is less than a year old, but I was able to leverage Parallel Colt and JFreeChart
21:43liebkehiredman: the font is Garamond
21:43hiredmanah, thanks!
21:44aldebrnliebke, 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:45liebkealdebrn: I've never used Numpy or Matplotlib, but I've heard great things about both
21:55slyrus_liebke: is this the R-alike in clojure I've heard vague rumors of?
21:55liebkeslyrus_: yep
21:59slyrus_the suggested google search "incanter's absorption elitist jerks" is clearly not the one i'm looking for
21:59liebke:)
22:00liebkethe website is http://incanter.org
22:01slyrus_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:01slyrus_doing something R-like with clojure sounds like a great idea.
22:02liebkeslyrus_: have you seen common-lisp-stat? http://github.com/blindglobe/common-lisp-stat
22:02slyrus_no, I haven't seen it lately, but I remember tony was embarking on that
22:15aldebrnSo any hints on where I would add code to make pow or exp handle BigDecimals? In Incanter, Clojure itself, or Java?
22:16aldebrnMeaningless question I know..
22:17hiredmanI'm not sure how to implement pow
22:17chouserBigDecimal has a pow method
22:18chouser(.pow 5M 10)
22:18chouser,(.pow 5M 10)
22:18clojurebot9765625M
22:18hiredmanchouser: but it takes a double or an int or something
22:18chouseryeah, an int
22:19aldebrnIs 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:19hiredmanto implement exp of a bigdecimal, I think you need something like (.pow e bigdecimal)
22:19chouseraldebrn: every time I suggest submitting a patch to the JVM I get laughed at, so that's probably not the way forward.
22:19hiredman:P
22:20aldebrn(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:20aldebrnin other cases
22:20chouserthere's a clojure.contrib.math that would probably welcome such things.
22:20aldebrnchouser, thanks for the info.
22:20liebkealdebrn: 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:21aldebrnI'll be very interested in vectorized exp for matrixes down the road liebke
22:21hiredman(defmethod pow [java.lang.Number java.lang.BigDecimal] [base exp] some math here)
22:21aldebrnBut I suspect it'll be challenging enough to do the scalar case, thanks for the suggestion
22:22liebkealdebrn: me too :) but that's going to be hard until Parallel Colt does
22:24chouserrhickey: any chance function params will ever support :as ?
22:25aldebrnliebke, I'll try to port Mpmath's real-valued exp to Clojure and bug this channel/Incanter group: http://tinyurl.com/yk3yxq5
22:25liebkealdebrn: that sounds great!
22:27hiredmanchouser: what do you mean by that?
22:35slyrus_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:36slyrus_liebke: have you (or others) tried to get clojure talking directly to an embedded R?
22:36liebkeslyrus_: yeah, Colt does most of the heavy lifting
22:38slyrus_a proper lispy language, java gui stuff, and bioconductor all under one roof would be pretty neat
22:38liebkeslyrus_: I haven't heard of any attempts to do so
22:38liebkeCould be cool :)
22:41slyrus_there must be some R/Java interoperability somewhere
22:41liebkeslyrus_: I do think there are already bridges between R and Java
22:42slyrus_i suppose that would be the place to start
22:42liebkeRServe has a Java API too
22:44slyrus_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:56technomancyliebke: it's good to see you moving away from jars in the git repo
22:56liebketechnomancy: haha, I thought you would like that :)
22:56technomancytook me 40 minutes to push my fork out; it was absurd
22:58technomancyonce 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:58liebkeyes, 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:58technomancyyou can be forgiven for checking jars into git right now just because the alternatives are so bad.
22:58technomancyhah!
23:26lisppaste8slyrus annotated #88865 "another bfs/dfs iteration" at http://paste.lisp.org/display/88865#1
23:49solussdHow do I import everything from a java package? e.g., I want to do something like this: (import '(java.swing *))
23:49solussd*java -> javax
23:50technomancysolussd: clojure doesn't work like that
23:50technomancyimport what you use