#clojure logs

2010-04-07

00:01dnolenwhat's the best strategy for making sure an agent isn't queueing up a whole bunch of actions?
00:07_atonot sure if there's a proper way to do it
00:07_atomaybe... (when (> (.getQueueCount my-agent) 10) (await my-agent))
00:13konrWhy am I not being able to extend a particular class with proxy? I'm getting an "IllegalAcessError" with this class, but not with others
00:30nteongood evening
00:35technomancyTheBusby: hang on, you're saying (str "Main-Class: " (apply str (replace {\- \_} (str main)))) works but (str "Main-Class: " (.replaceAll (str main) "-" "_")) does not?
00:36technomancyTheBusby: oh, never mind; looks like this was fixed in git already; heh
00:36dcnstrcthi. How do I serve a javascript file from my compojure app ? I want for this compojure app to run as a single jar file using jetty so I can't program in a path to read the .js file from.
00:37dcnstrctI can't hard code a server path I mean..
00:37dcnstrctcan I serve the .js right out of the jar file somehow ?
00:38metronomedcnstrct: you can use a .war container for that
00:38dcnstrctso far I have done (def javascript "all my js lives in here") and then served that... but I'm tired of escaping quotes
00:39dcnstrctif I use a .war then I need a java application server to deploy to
00:39dcnstrctI want to make a single jar file that you run and it starts a server on 8080 completely self contained
00:39dcnstrctI'm going to wrap it in a .exe and ship it to a windows user to run on his desktop
00:40dcnstrctso I can't tell him "go setup a java application server"
00:40_atodcnstrct: if you include the js file in the jar then you can get at it via getResourceInputStream or something... let me find the exact method..
00:40metronomethen why not just bundle the .js files with the exe?
00:40dcnstrctsweet
00:41dcnstrctmetronome, that might work too
00:41dcnstrctanother problem though is that I want it to still work when I'm running it in a slime
00:41dcnstrctduring testing
00:41dcnstrctbut I guess I can handle that as a seperate issue
00:41dcnstrctyou can't always have your cake and eat it too
00:42metronomeI guess you could do what _ato says then
00:42technomancythough M-x swank-clojure-project hasn't had a stable release that honors them yet
00:43_atoI think it should be just something like: (.getResourceAsStream (clojure.lang.RT/baseLoader) "foo/bar/myfile.js")
00:43dcnstrctgreat, I'll give it a shot. thnx
00:44_atoI wonder...
00:44_ato,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")
00:44clojurebotnil
00:44_atohmm
00:44_atoah
00:44_atoworks in my repl, must be a sandbox thing
00:47dcnstrctit works! gracias
00:48dcnstrctnow can anyone think of an easy way to tell it to render from an absolute path when running inside slime and from the jar any other time ?
00:48dcnstrctI bet swank-clojure-project sets some kind of variable I can use
00:48TheBusbytechnomancy: the fix in git works fine. I was simply provding the fix I used against 1.1.0. DLing the latest lein now ;)
00:48technomancygreat
00:49technomancydcnstrct: if you use lein swank it will be able to load from the resources directory
00:49dcnstrctHRMMm ok thnx I'll get it if I'm not already using it.
00:51TheBusbytechnomancy: so I guess I'll need to wait for 1.2.0 before a stable version is out with the bug fix? (raw/stable pulls for 1.1.0 and doesn't appear to include that fix...)
00:51dcnstrctyou're right it just works
00:51technomancyTheBusby: yeah, I haven't backported any fixes so far
00:51technomancyTheBusby: using the version from git shouldn't be too bad though; let me know if you run into problems
00:51TheBusbythat's fine. I'll just stick with my hand fixed one until 1.2.0 and then switch back
00:52TheBusbyneed to keep a bunch of machines in sync, so I'd prefer to stick to a label/tagged version.
00:53technomancyok... not sure how far 1.2.0 is.
00:53technomancyit's not just around the corner
00:53TheBusbywell other than this tiny issue, lein has been working great ;) No hurry
00:54peregrine81I cannot get vimclojure (probably vim) to work correctly..
00:54peregrine81trying to open a new reply using \sr and it just puts me in insert mode
00:55bmasontechnomancy: thanks for making Lein! it has really eased my linking pain
00:56peregrine81how do I use vimclojure? The doc says type <LocalLeader>sr to open a new repl
00:57peregrine81I've got ng running
00:57technomancybmason: cool!
00:58bmasonwe were having a chat the other day about features to add to lein... I don't know if anyone went and did anything about it though
00:59mikemperegrine81: have you opened a .clj file first?
01:00peregrine81mikem: yep, I've got the plugin installed, I can do completions, highlighting...
01:00technomancybmason: remind me which features?
01:00mikemperegrine81: so what happens when you hit <LocalLeader>sr?
01:01bmasonah... three main ones that I can recall... being able to search repos, resolving dependencies, and having a default version (latest stable)
01:01peregrine81I am assuming my LocalLeader is \ cause I haven't changed it. Nothing happens, when I press s it puts me in insert
01:02mikemperegrine81: do you have the appropriate options set in ~/.vimrc? namely, clj_want_gorilla and vimclojure#NailgunClient?
01:02mikembtw, which version of VimClojure are you using?
01:03technomancybmason: searching repos would need some server-side support
01:03technomancywhat do you mean by resolving dependencies?
01:03peregrine81mikem: 2.1.2
01:03peregrine81mikem: lemme check .vimrc
01:03bmasonsomething that would probably also require some support outside lein :)
01:03bmasonI mean resolving hierarchical deps
01:04mikemperegrine81: you may be interested in an alpha version of 2.2.0: http://groups.google.com/group/vimclojure/browse_thread/thread/d15b0174d2a1e51 -- but 2.1.2 should work also :)
01:04bmasone.g. I add 'cupboard' to my deps, it needs 'berkeleydb', which needs a couple other jars
01:04peregrine81the vimclojure#NailgunClient is not mentioned in the docs.. but I did not have gorilla I will add and retry
01:04technomancybmason: if that's not working it's a pretty fundamental bug
01:05bmasonreally?
01:05bmasonhuh... didn't know it was supposed to
01:05technomancyyeah, that stuff is handled behind the scenes by maven
01:06mikemperegrine81: there is a README.txt that ships with the 2.1.2 files, as well as a clojure.txt in the doc/ folder. between the two files, all this stuff should be documented
01:06_atoClojars is now providing the same search stuff maven central does (which eclipse etc use): http://clojars.org/repo/.index/
01:06_atothe zip is just a zipped up lucene index
01:07technomancyoh, cool
01:07technomancybmason: what do you mean about having a default version?
01:08bmasone.g. :dependencies [clojure], and it automatically uses the current stable release
01:09technomancyoh, yeah
01:09bmasonnone of this is really major
01:09bmasonjust stuff that would save steps for the developer
01:09technomancythe problem with that is it will cause code to break down the line even when your project hasn't changed
01:09bmasonyeah
01:09bmason:)
01:09technomancyone day it works fine; the next it mysteriously doesn't
01:10technomancyyou still get this with snapshot deps, but you try to minimize those, and then you know what you're getting into... kind of a necessary evil
01:10technomancyanyway using "lein new" should make it easier since that will leave you with the latest clojure at the time of the lein release
01:10technomancyand having a search would make it even easier
01:10bmasontrue true
01:11technomancyI'd love to see something like "lein add cupboard" that could search clojars, maven central, etc, and add a dependency to your project.clj for you
01:11bmasonyeah, really my biggest hurdle has just been trying to figure out *where* the jars I'm looking for are
01:11technomancyif you're looking for a fun project that would be my suggestion. =)
01:11technomancybmason: you know about jarvana.com?
01:11bmasonjarvana doesn't cover all the repos
01:12technomancytrue
01:12bmasonwhereas lein could hopefully tell you whether a package is in any of the repos that it's using
01:12_atothe starting point for anyone wanting to implement search would be to take a look at this: http://www.sonatype.com/people/2009/06/nexus-indexer-api-part-2/
01:13_atothat's what most maven repo search things are using underneath as far as I can tell
01:13bmasongotcha
01:15technomancybmason: that would make a great plugin, but unfortunately there's no way right now to activate plugins on a user-wide basis
01:15technomancyjust on a per-project basis
01:15technomancyit's on the list though; shouldn't be hard
01:17bmasonis "the list" accessible to mere mortals?
01:18_atobmason: http://github.com/technomancy/leiningen/raw/master/todo.org
01:18technomancyonly to org-mode users, sorry =)
01:18bmasonok, good link
01:19technomancyI have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =)
01:19bmasonno worries... I really just wanted to make sure the ideas we were discussing weren't getting lost
01:22peregrine81mikem: I probably couldn't be more frustrated by this... :/
01:22bmasonwell, good night guys
01:22bmasonthanks for the information :)
01:26mikemperegrine81: still not working?
01:26peregrine81mikem: i cannot see why its not..
01:27mikemyou said the nailgun server is up and running, right? did you start it with a classpath which includes the files you're opening in vim?
01:28peregrine81no....
01:28peregrine81i just used the command
01:28peregrine81mikem: starting to see like that nailgun is not worth all the work
01:28peregrine81/see/seem
01:29mikemperegrine81: well, it's working fine for me :)
01:29peregrine81mikem: why would it need to be in the classpath? ANd I have to run the java command everytime I need to edit some files?
01:30mikemso, to recap: I start nailgun with, I have the following two lines in my .vimrc: "let clj_want_gorilla = 1" and 'let vimclojure#NailgunClient = "/home/mike/src/clojure/vimclojure/ng"'
01:31peregrine81mikem: I have the lines in my .vimrc and I was under the impression I could start ng and forget it in a screen session
01:31mikemperegrine81: I think the files you're editing (and their dependencies) need to be in the classpath, because you end up sending some code to the nailgun server which then compiles and runs said code
01:32mikemmy workflow is starting one ng server per coding session for the project I work on. I don't work for more than one project at one time
01:33mikemif you work on more than one project at any one time, I imagine it should be OK to launch the nailgun server with a classpath including all your dependencies
02:11woobyis there an easy way to write back out as xml the structure that clojure.xml/parse returns?
02:11hiredmanthere is a xml/emit
02:12hiredmanbut, uh, it is not nice to use
02:14woobyhm, looks like it barfs to *out*
02:14hiredmanright
02:15woobybest way to mitigate, run in binding?
02:16hiredman,(doc with-out-string)
02:16clojurebotTitim gan éirí ort.
02:17hiredman,(doc with-out-str)
02:17clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
02:17woobyoh awesome, thanks man
02:17hiredman:/
02:17woobythe good almost cancels out the bad
02:17hiredmanI hope it works for you
02:18woobythanks, about to give it a shot here
02:23woobyyup, we're cooking
02:23woobythanks again
03:04zmilaif (fun x) returns some transformation or false, is this idiomatic to recieve only not-falsy:
03:04zmila(filter #(identity %) (map fun some-seq))
03:04zmilaor there is smth more elegant?
03:06zmila,(filter #(identity %) (map #(if (even? %) (* % %) false) (range 1 10)))
03:06clojurebot(4 16 36 64)
03:08hiredmanuh
03:08hiredmanjust identity
03:08Raynes(filter identify ..)
03:09hiredmanor, (remove false? ...)
03:10zmilayes! remove false? is the answer, thx hiredman
03:10Raynes,(false? nil)
03:10clojurebotfalse
03:10noidizmila, it's easier and faster to run the filter before the map
03:11noidi,(map #(* % %) (filter even? (range 1 10)))
03:11clojurebot(4 16 36 64)
03:12zmilanoidi, my example was wrong. I want to calculate fun x, then check if it is not false and collect only such results
03:12noidiok
03:14zmila(remove false? (map #(let [x (* % %)] (if (even? x) x false)) (range 1 10)))
03:24woobyi found out about comp the other day, can be useful for stuff like that
03:24wooby(remove false? (map (comp even? #(* % %)) (range 10)))
03:25woobyhm, can i use proxy to implement a constructor?
03:27woobynevermind
03:31zmilacomp is good, i've to learn more. but in this example it returns seq of true's :) but not seq of squares
03:33woobyah ;)
03:33woobyhave you gotten into 'for' at all?
03:33woobyuseful for same kinds of things also
03:37zmilayes, wooby, i know about (for ). i prefer to use filter/map in first turn, then for, lastly loop/recur :)
03:38konrIs there a tutorial or some other resource to shed some light on the error stack?
03:49zmilait's hard to read my own clojure code, written a month ago :(
03:52esjzmila - this is the main reason I write tests, so that I can understand later how I intended a function to used :)
03:53zmilait's myth about one-liners :)
03:54zmilaone line: for the body, one-two lines: doc about params and return, and one-two more: test or example of use
03:54esjyou're ahead though
03:54_atoyeah, having tests helps a lot. Someone was asking me the other day how some Java code I wrote 2 years ago was supposed to work, it would have taken much longer to figure out without the tests, they made it obvious
03:54RaynesJava code!?! Blasphemy.
03:55_atoClojure barely existed at the time
03:57tomojwell, you should've simply written clojure yourself
03:57_atohaving lots of really small functions rather than a few large functions seems to help a lot as well
03:57zmilain eclipse i can search for a method's references and see where and how it is used :) and method's signature helps to know what data gets in and out.
03:57zmilasmall clojure function is often equivalent to medium java function :)
03:58esjYeah, I'm still getting my head around arranging them all so I don't up with some kinda function confetti
03:59zmilaeven in java i prefer not to write function with more then one cycle. but in clojure one-liner may have two or three map/filter/reduce :)
04:00_ato->> is very nice for that
04:01_atoI also like to name the map/filter functions if they're any more complex than #(< % 5)
04:02tomojI've noticed that sometimes I want a function that is just like take-while, except it takes one more element (i.e. the first one that doesn't satisfy the predicate)
04:02tomojor, it takes a predicate which identifies sentinels, then takes everything up to and including the first sentinel it sees
04:03tomojwhat I'm look at now is (concat (take-while #(not (= % sentinel)) s) [sentinel])
04:03tomojwhich is evil
04:04esjtomoj: I've been doing just that...
04:05zmilasimplicity and conciseness are contagious :)
04:06_ato,(concat (take-while (complement #{0}) [1 2 3 0 1 2 3]) [0])
04:06clojurebot(1 2 3 0)
04:06_atohmm
04:15doseq_ato: I posted off my contrib agreement yesterday!
04:15doseqHow exciting.
04:18_atodoseq: cool. :) now the waiting part. I think Rich checks his mailbox weekly or so. You'll know when he's received it as your name will get added to the contributors page on clojure.org
04:19doseqha, there you are.
04:21RaynesI don't have a printer. :(
04:21RaynesSomebody mail me the the CA. ;)
05:23Raynesdefn: ping
05:54AWizzArd~max people
05:54clojurebotmax people is 269
06:03tomojit would be cool if we could automatically run the tests contained in old versions against the current version
06:05tomoje.g. I'm about to tag 1.3.0. the tests have changed a bit since 1.2.3, but the tests that were in 1.X.* for X<3 should still pass against the 1.3.0 src
06:07bsteubertomoj: if you want your old tests to still work, why not leave them in?
06:07tomojwell, I probably would do so
06:07tomojbut those tests might have slightly changed
06:08tomojfor introducing new backwards-compatible functionality
06:08tomojif you always change the tests in such a way that the old behavior is still tested, there's no need, you're right
06:09tomojbut it seems like it might be a valuable sanity check, just to make sure you haven't broken something? not sure
06:09bsteuberif you want to be backwards-compatible, it es part of your spec - so you should test it, I'd say
06:10bsteuberyou can move it to a module like backward-tests
06:10tomojthat makes sense
06:11tomojhaving tests run that aren't actually in the source code but only in history does seem a bit crazy
06:11bsteuber:)
06:38zmilahow to flatten result of (map fun seq) if fun may return nil, 1 item or list of items?
06:40Chousukemake it always return a list of items and use mapcat
06:40Chousuke(or nil, of course)
06:45tomojthere's a java class Coordinate with a constructor that takes two double arguments
06:46tomoj(Coordinate. 1 1) works fine
06:46tomojhow?
06:46clojurebotwith style and grace
06:46tomojyes indeed
06:46tomojclojure's java interop specially checks if a cast can be performed to make the signature match?
06:47tomojor is this a java thing I don't remember?
06:53zmilai'm afraid of mapcat - it seams to be slow
06:56tomojwell, it's not lazy, is it
06:56tomojare you mapping over a lazy seq?
07:00zmilai want to calculate count of unique results, so laziness will not help here, does it?
07:01tomojnope
07:01tomojdid you make the function always return a seq or nil? or still trying to find a way where it can return non-seqs?
07:03tomojI wonder how (apply concat) works
07:04tomojdoes it realize every mapped value and only then concat them?
07:05_ato,(clojure.contrib.seq-utils/frequencies [:a :a :a :b :b :a :c])
07:05clojurebot{:c 1, :b 2, :a 4}
07:05_atozmila: do you mean like that?
07:06_atooh wait
07:06_atowould you answer be 3?
07:06tomojusing reduce instead of apply makes it 3.5 times slower for me
07:06tomoj(mapcat, that is)
07:08zmilai'll try apply concat
07:08tomojmapcat is apply concat
07:09tomoj(mapcat f xs) == (apply concat (apply map f [xs]))
07:09tomojso you can save having to apply the map: (apply concat (map f xs)), but it doesn't seem any faster to me
07:16zmilai must be ashemed :) just put (println xx) in several end-places, run all in repl, then captured result into text editor, find-removed braces, and put (into #{}), then call count
07:18tomojoh, you wanted to collect it all into a set?
07:18zmilai want to calc (count distinct ...)
07:18tomojyeah I think I understand now
07:19zmilai have to read some theoretical papers on func-programming with trees.
07:20zmilalists are ok. but trees - where I have two recursions ... weak point for me
07:21tomoj,(require 'clojure.set)
07:21clojurebotnil
07:21tomoj,(clojure.set/union [1 2 3] [3 4 5])
07:21clojurebot[1 2 3 3 4 5]
07:21tomojweird
07:22tomojI wonder what the best way to add the elements of a coll into a set are
07:22tomojs/are/is/
07:23tomoj,(apply conj #{} [1 2 3])
07:23clojurebot#{1 2 3}
07:23tomoj?
07:24ChousukeI'd prefer (into #{} [1 2 3])
07:25Chousukeit's shorter, and it uses transients :)
07:25tomojah, yes
07:26tomoj(defn mapunion [f & colls] (reduce into (cons #{} (apply map f colls))))
07:26tomojdoesn't seem to be much faster than mapcat
07:26tomojeven though mapcat returns duplicates and all in one big seq
07:27tomojit's doing more work eliminating duplicates, I guess
07:27ChousukeI don't think you should use reduce with into
07:27Chousukeuse apply instead
07:28Chousukethat will allow it to use a single transient for the whole operation
07:28zmilarun time 58 sec, and answer is correct - so now i have 99 problems solved! :) one more until next level :)
07:28tomoj(into #{} (apply map f colls)) ?
07:29tomojer, no
07:29Chousuke,(apply into #{} (map (comp map inc) [[1 2 3] [3 4 5]]))
07:29clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
07:29ChousukeHMM
07:29Chousukeoops
07:29Chousuke,(apply into #{} (map (partial map inc) [[1 2 3] [3 4 5]]))
07:29clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$into
07:30tomojyeah, couldn't figure out what you meant
07:30Chousukeoh, it doesn't support more than one collection? :/
07:30Chousuke that's a fault if you ask me
07:31tomojwe can always (into #{} (mapcat ...))
07:31tomojbut that certainly won't be any faster than mapcat :)
07:31Chousukemapcat shouldn't be slow
07:39tomojhttps://gist.github.com/bf8f747e4ffa29591665
07:39tomojusing a single transient set and conj! is about the same as mapcat
07:40tomojeven if you call set on what you get back from mapcat
07:40tomojunless I screwed up
08:40dgreensp,(prn 3)
08:41clojurebot3
08:41dgreensp,(first (for [i (range 10)] (prn i)))
08:41clojurebot0 1 2 3 4 5 6 7 8 9
08:41dgreenspwhy is that not lazy? actually, it is, sometimes (on one machine) but not others, and not here
08:42_atodgreensp: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
08:42zmila,(first (for [i (range 40)] (prn i)))
08:42clojurebot0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
08:43zmilasee chunk-size :)
08:45dgreenspah, thanks; a little creepy but I can kind of see the trade-off
08:45dgreensp,(first (for [i (take 10 (iterate inc 0))] (prn i)))
08:45clojurebot0
08:45dgreenspis that guaranteed to work? or will "iterate" become chunked or something?
08:46dgreenspheh
08:47licoresse .
08:47dgreenspit's just that I'd rather not use the "unofficial" drop-into-Java solution from the blog post.
08:51_atoI'm not sure
08:51_atolooks like seq1 still hasn't yet been added to git :(
08:53SynrGi have meticulously documented the jline issue i mentioned with clojure-repl on linux the other day here: http://bugs.debian.org/576814
08:53SynrGnow, presumably this is an upstream issue and next, the debian maintainer forwards this upstream.
08:55dgreensp_ato: actually chunking will work fine here. good to know it's still lazy. thanks
08:56LauJensenHi all - I'm fiddling with clojure.test and wondering about the convention. If I'm using namespace x.y.z, is putting test/x/y/z/test.clj sufficient for lein test to know what to do ? Provided that test.clj has the namespace x.y.z.test
08:57tomojsrc/x/y/z.clj <-> test/x/y/test/z.clj
08:57tomojx.y.z <-> x.y.test.z
08:57esjyup
08:58tomojthat's clojure-test-mode's convention
08:58_atoSynrG: in the meantime use rlwrap instead?
08:58SynrGrlwrap?
08:58tomojbut `lein test` will just run ALL tests, I think
08:58tomojso you can, I think, use whatever convention you like
08:58LauJensenthanks tomoj I'll give it a whirl
08:58SynrGah, a generic thing
08:59_atoyeah, uses readline (like bash etc) I think it provides more editing features than jline too
09:01AWizzArdWhen I want to inject some configuration info into my JVM in the call (in emacs) to clojure, should i then do this best via dynamic vars, with the "java -Dproperty=value" option?
09:01LauJensentomoj: So the problem remains, that the test doesnt run - How do you troubleshoot that in a sane way ?
09:02SynrG_ato: reverse incremental search is one i rely on heavily
09:02tomojhow are you defining the tests?
09:02_atorlwrap certainly does that
09:02_atoand history saving
09:02LauJensentomoj: deftest/testing/is
09:02chouserand tab completion
09:03tomojhmm.. deftest should certainly work
09:03esjLauJensen: the are macro is mega-useful
09:03LauJensenesj: Lets look into that once testing actually works/runs :)
09:03LauJensentomoj: It just outputs Total: {}
09:04SynrG_ato: jline does history saving
09:04tomojLauJensen: try running `lein test` on a `lein new` skeleton?
09:04SynrGtab-completion, ah, nice
09:04_atoAWizzArd: that'll only work if you're spawning java from inside emacs -- not when connecting to an remote swank server. But maybe that's okay for use-case?
09:04_atoyour use-case*
09:04SynrGso i guess it has some language-awareness somehow?
09:04AWizzArd_ato: yes, but anyway, do you have another suggestion?
09:05tomoj`lein new foo && cd foo && lein deps && lein test` should give you 1 failure
09:05AWizzArdI would just like to inject information into a Clojure during start up.
09:05LauJensentomoj: Runs fine
09:05chouserSynrG: well, you can teach it things -- give it a completion file and/or command line options for what defines a "word"
09:05AWizzArdIn my .emacs I don’t see how I can add command line args, as in swank-clojure-command-line-args, so I thought I could add a -D to swank-clojure-extra-vm-args
09:05_atoAWizzArd: if it has to be during startup then yeah, that's probably the best way to do it
09:06tomojLauJensen: hmm.. any weird deps in your project.clj? leiningen stuff maybe?
09:06LauJensenNo - I'll fiddle, thanks for the help
09:06chouserSynrG: I haven't bothered to populate my completiong file yet, but within a single session it learns from expressions you enter and will complete those words later
09:06tomojit should just find every test defined in any clj file under test/, I think
09:09zakwilsonHaskell's Data.Map has union, intersection and difference functions. I don't see equivalents in the Clojure API. Are they there under different names? They're easy enough to write, but I see no point in reinventing the wheel without cause.
09:11_ato,(clojure.set/union #{1 2} #{2 3})
09:11clojurebot#{1 2 3}
09:11_atozakwilson: see http://richhickey.github.com/clojure/clojure.set-api.html
09:12chouserzakwilson: those sound like set ops, so I'm not sure how Haskell defines them on maps.
09:12dgreensp,(into {:a 1 :b 2} {:c 3 :d 4})
09:12clojurebot{:a 1, :b 2, :c 3, :d 4}
09:12chouser,(apply dissoc {:a 1, :b 2} (keys {:b 2, :c 3})) ; difference?
09:12clojurebot{:a 1}
09:12chouser,(select-keys {:a 1, :b 2} (keys {:b 2, :c 3})) ; intersection?
09:12clojurebot{:b 2}
09:12triyoWhats the most idiomatic way to model data associations in Clojure?
09:12_atoah map.. missed that
09:13AWizzArdIs there already a tool, possibly in Contrib, which helps to load config files? I am about to implement a little (load-config) or something like that which will load .clj files to configure computer specific settings.
09:13tomojhmm, I'm confused
09:13tomojlein says it downloaded clojure-contrib-1.2.0-master-20100122.191106-1.jar from clojars
09:13SynrGchouser: ah, nice.
09:14_atoAWizzArd: what would such a tool do? isn't loading a clj as configuration just a matter of calling (read ..) on the file?
09:14triyonested maps or some other better suited strategy?
09:14tomojseems like clojars somehow forwards to http://build.clojure.org/releases/org/clojure/clojure-contrib/
09:14SynrGoh, and it does paren flashing. super!
09:14tomojbut there is no 1.2.0 there
09:14zakwilsonchouser: they work like the set ops with respect to keys, and prefer the values from the first argument.
09:14_atotomoj: clojars does even trickier stuff than that
09:14SynrGsubmitting this extra info on the bug to use rlwrap as a workaround. thanks, guys
09:15_atoit forwards snapshots to http://build.clojure.org/snapshots/
09:15chouserSynrG: it has a decent vi-bindings mode too. It's no vim, but better than nothing. :-)
09:15tomojoh, I see
09:15SynrGchouser: sure :)
09:15zakwilsonThere are also union/intersection/difference With functions, that take a combination function (usually something like concatenation, addition or subtraction)
09:15tomojI guess my question is then, why is the clojure-contrib snapshot so old?
09:15chouserzakwilson: so the expressions dgreensp and I pasted here should get you started
09:15SynrGthere's a separate debian bug asking for clojure to Recommend jline, so i think I'll cross-reference this bug in that bug ... as this is clearly a superior solution
09:16psykoticzakwilson: there's merge, which is like haskell's data.map union. there's also merge-with, which lets you specify how to merge rather than preferring the first unconditionally.
09:16AWizzArd_ato: it would look up an environment variable, such as $CONFIG_ID which is maybe set to "ato" on *your* computer. Then when you include the com.company.server namespace in your project, it will have (def *port* 80) as default, but then after all the defs you place a (load-config). And then it looks up *your* specific config file from the repository, for exmaple /hg/clj/configs/ato/com/company/server.clj
09:16zakwilsonchouser: Yep, those are about what I was looking for. I just wanted to know if I had to write them, or if they had different names.
09:16AWizzArdAnd in your config you have a (def *port* 8080) and other settings for your server, or whatever it is.
09:18_atoah, so per-environment configuration? Ah no I don't think I've seen something that does that, shouldn't be hard to write though.
09:19AWizzArd_ato: yes, it’s a simple write
09:19triyo,*clojure-version*
09:19clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
09:21dgreenspzakwilson: it's kind of jarring coming from Haskell or Scala to find a collections library with no nouns, only verbs, and fewer of those :)
09:24dgreenspcan I define my own ISeqs?
09:25chouserdgreensp: sure, a couple different ways
09:25dgreensp(clojure doesn't have interfaces, but doesn't really replace them either, except maybe with multimethods...)
09:25tomoj1.2 does
09:26chouserdgreensp: clojure has interfaces, but they're less useful than protocols and multimethods
09:27dgreenspare protocols new? I'm working off of 1.1
09:27chouserdgreensp: probably the easiest way to provide your own behavior for an ISeq is with 'lazy-seq'
09:27chouserdgreensp: yes, protocols are in github master, not in an official release yet.
09:27AWizzArddgreensp: https://www.assembla.com/wiki/show/clojure/Protocols
09:27chouserdgreensp: but even in 1.1, clojure fully supports Java interfaces
09:28dgreenspyeah, though Java interfaces should be treated as for interop only I assume
09:28dgreenspI guess ISeqs are a bad example, they are easy to build
09:29zakwilsondgreensp: I actually learned Clojure before Haskell, but I haven't used Clojure very much lately.
09:29dgreenspwhat about random-access seqs, like java.util.List or scala's "Seq" class, which have a size and an apply/get method?
09:29chouserwell, as you say they're not really replaced by anything in 1.1, so they can be useful outside of interop
09:30dgreenspI'm actually making a random-access seq right now in some code with a custom backing
09:30chouserdgreensp: have you looked at 'proxy'?
09:30dgreenspyes, I know a bit about proxy; trying to be idiomatic I guess
09:31chouserproxy is the best way to implement interfaces in 1.1
09:31chouserand it's entirely idiomatic
09:31dgreenspok, though the interface itself is always defined in Java code somewhere...
09:33chouseryou can defined new interfaces using gen-interface, though you do need to AOT compile that.
09:33dgreenspheh, that's cool
09:33dgreenspclojure's interop has definitely been thought through
09:33dgreenspI'm having a great time with it
09:34chouserdgreensp: this story is dramatically improved now in what will become 1.2
09:34chouserprotocols are awesome
09:34dnolen*dramatically*
09:44dgreenspsweet, looking forward to what's coming in 1.2.
09:48dgreenspmy initial skepticism about clojure's potential for speed (I've written a lot of tight loops in Java) is subsiding
09:54dnolenso after 1 1/2 of Clojure I'm finally starting to look into agents :) So is the difference with send-off/send that send-off creates a thread per agent?
09:54dnolen1 1/2 years
09:54chouserdnolen: not necessarily.
09:55chouserdnolen: the difference is that the number of threads in the send pool is bounded by the number of processor cores, the send-off pool is unbounded.
09:55dnolenchouser: I'm using send and it looks like sleeping the thread slows all other agents down.
09:56chouserdnolen: right, if your action is constrained by anything other than the CPU (sleeps, IO blocking, etc.) you should use send-off.
09:57dnolenchouser: so you're saying that send would use a thread send pool of 2 if I have two cores?
09:57dnolenor just some optimal small number?
09:57dnolenI have 150 agents
09:58chouserdnolen: the send pool currently has a max of cpus+2 threads, so 4 in your case. But that's of course an implementation detail that might change.
09:59chouserthe number of agents doesn't matter
09:59AWizzArd,do
09:59clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
09:59AWizzArd,(fn [a] do(* 2 a))
09:59clojurebot#<sandbox$eval__8370$fn__8372 sandbox$eval__8370$fn__8372@16e1533>
09:59AWizzArd,((fn [a] do(* 2 a)) 100)
09:59clojurebot200
09:59AWizzArdwhy can do be resolved here?
09:59dnolenchouser: thx, I now am a little bit closer to understanding agents :)
09:59Chousukeit's probably just ignored rather than resolved
10:00chouserwhat matters is what the agents are doing. if the action you want to send will block or sleep, use send-off. If it will just burn cpu (tight loops, math, etc.) use send.
10:00Chousuke,(do do 2)
10:00clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:00carkh,((fn [a] interleave (*2 a) 100))
10:00clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--8382$fn
10:00Chousuke,(fn [x] do 2)
10:00clojurebot#<sandbox$eval__8388$fn__8390 sandbox$eval__8388$fn__8390@218a7f>
10:00Chousuke,(fn [x] foo 2)
10:00clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
10:00Chousukehmm, interesting
10:01chouser,(fn [] do)
10:01clojurebot#<sandbox$eval__8398$fn__8400 sandbox$eval__8398$fn__8400@c06cac>
10:01chouser,(fn [] do do)
10:01clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:01Chousukewhat does that return?
10:01Chousuke,((fn [] do))
10:01clojurebotnil
10:02Chousukethat's... rather weird.
10:02carkhit isn't
10:03chouser,[do]
10:03clojurebotnil
10:03carkhspecial forms are special !
10:03chouser,[do do]
10:03clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:03Chousukechouser: that definitely is weird
10:03Chousuke,[do 2]
10:03clojurebot2
10:04Chousuke:D
10:04chouserha!
10:04chouserAWizzArd: so, um... don't do that.
10:06chouserwell, there it is. if an "implicit do" starts with the symbol 'do', that symbol is ignored
10:06stuartsierraDoes Incanter plotting work in headless mode? e.g., to generate PNGs
10:06liebkestuartsierra: yes, use the save function on the chart object
10:08stuartsierraok
10:09stuartsierraOne of my students couldn't get it to run on a plain-text SSH session.
10:09chouserhttp://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622
10:11liebkestuartsierra: I have seen that issue before, when loading incanter.processing, but not with incanter.charts.
10:13bsteuberchouser: what is this good for, then?
10:13stuartsierraok, might be because they're just running the uberjar
10:13liebkeeven that shouldn't be an issue, if they are not loading incanter.processing, unless they have a really old version
10:14liebkestuartsierra: if you use ssh -X when working with Processing, then it should load fine.
10:15chouserbsteuber: the 'do' thing? it's just an implementation detail leaking out.
10:15chousernot to be relied upon
10:16chouserand is only going to cause problems if you name your own things 'do', which you really really shouldn't do.
10:16chouser,(let [do 5] do)
10:16clojurebotnil
10:16stuartsierraliebke: I told them to download 1.0.0
10:16Chousukethat really should fail :/
10:16Chousukewith an exception
10:16chouser,(let [do 5] nil do) ; seriously, don't do this
10:16clojurebot5
10:16liebkehmm, 1.0.0 shouldn't fail
10:17bsteuberchouser: sure, I was just curious :)
10:17AWizzArdre
10:17wthiddencgrand: thanks for your blog post about flattening reduces I had a chance to use such an idiom today.
10:17chouserbsteuber: me too :-)
10:17AWizzArdchouser: I don’t want to do that, but in #Clojure.de we just stumbled upon such a piece of code and I was curious why (do do(+ 1 2)) doesn’t work, but the same thing inside a fn does.
10:19chouserAWizzArd: well, I explained that. both are unsupported, but only one is caught by the current compiler.
10:20chouserAWizzArd: http://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622
10:20chouserAWizzArd: if an "implicit do" starts with the symbol 'do', that symbol is ignored
10:21AWizzArdchouser: oh good thanks, that is what I was looking for. So, it’s the compiler.
10:22tomojok, but what about [do 3] ?
10:23chouserheh, yeah that's probably something else.
10:23AWizzArdoh
10:24tomojI mean, I'd expect [do 3] to be [3], not 3
10:25Chousukeit's because the compiler uses RT.first to check for the do symbol
10:25chouseror [nil 3] or an error, right.
10:25Chousuke,#{do 3}
10:25clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:25Chousuke,#{'do 3}
10:25clojurebot#{3 do}
10:25Chousukehmm
10:25Chousuke,#{'do 2344}
10:25clojurebot#{2344 do}
10:26Chousuke,#{do -1}
10:26clojurebot-1
10:26Chousuke:P
10:26AWizzArdstrange
10:26Chousuke,(seq #{do -1})
10:26clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:26Chousuke,(seq #{'do -1})
10:26clojurebot(do -1)
10:27chouserChousuke: I think it's a different issue
10:27chouser[...] is not an "implicit do"
10:27chouserbut still looking...
10:30liebkestuartsierra: I just tested version 1.0 with plain ssh (no -X option), and charts loaded without error (processing, of course, had the usual initialization error). So make sure your student isn't loading processing instead of charts (unless they use ssh -X).
10:33tomojthat negative thing is very very odd
10:33tomoj,#{do -9}
10:33clojurebot-9
10:33tomoj,#{do -10}
10:33clojurebot-10
10:34tomojactually
10:34tomoj,#{do -16}
10:34clojurebot-16
10:34tomoj,#{do -17}
10:34clojurebotjava.lang.Exception: Unable to resolve symbol: do in this context
10:34tomojthought it only worked for one-digit negative integers, but no, even weirder...
10:35npoektopwhat's wrong with (:use [com.server.tests.testhelpers :only (run-these-tests)])? when i add this line to ns, it says "at com.server.tests.junit$runtests__1343.invoke(junit.clj:30) [java] at user$eval__1347.invoke(NO_SOURCE_FILE:1)"
10:36Chousuketomoj: it's because the hash codes happen to decide the order
10:37Chousuke,(map #(.hashCode %) '[-17 do -9])
10:37clojurebot(-17 -1640328432 -9)
10:37ChousukeI suppose that somehow decides the order :/
10:38tomojahh, I see
10:38npoektopand it says [java] Caused by: java.lang.NullPointerException
10:40tomojnpoektop: do you have something in testhelpers.clj that calls runtests?
10:41tomojif you put some code it testhelpers.clj at the top level (not inside defns/etc), it will be run when you try to use the namespace
10:44npoektoptomoj, even if i use :only?
10:44tomojyeah, :only doesn't mattter
10:44tomojthe file has to be loaded
10:45npoektopand no, no runtests in testhelpers.clj
10:45tomojand when the file is loaded, any top-level code is run
10:45tomojoh, hmm
10:46tomojcan you paste testhelpers.clj somewhere (e.g. paste.lisp.org)
10:47AWizzArdStill, it really does not seem very intuitive with its current behaviour.
10:52npoektoptomoj, http://pastebin.com/SJheevSF
10:54tomojwell, I don't see any bad toplevel code there
10:54tomojmaybe in one of your other namespaces which is required by testhelpers?
10:55tomojnpoektop: this error is happening when you try to load junit.clj?
11:16konrWhat's the direct translation of pen-width.valueChanged.connect(foo,"setPenWidth(int)")? (.connect (.valueChanged pen-width) foo "setPenWidth(int)")?
11:18Chousukehmm
11:19ChousukeI would do (-> pen-width .valueChanged (.connect foo "setPenWidth(int)"))
11:24konrmuch nicer, Chousuke! These arrows seem to be always handy
11:31konrshouldn't this thing have a method foo? http://pastebin.com/WHnG4D32
11:36chouserkonr: proxy can only implement existing methods, not define new ones.
11:37npoektophow to splice a vector of args to another function's args? (defn foo [& args] (require _spliced_args_))
11:38bsteubernpoektop: apply
11:40bsteuber,(let [myfun (fn [& args] (apply + args))] (myfun 1 2 3 4 5))
11:40clojurebot15
11:41npoektopbsteuber, thank you. It's so obvious that i'm confused)
11:41bsteuber:)
11:42stbgzhello there anybody knows how to change the class path in swank-clojure?
11:43liwpstbgz: I just use the swank-clojure-project function and leiningen
11:44stuartsierraI use Maven and the clojure:swank goal
11:44liwpstbgz: or do you mean after you've launched slime?
11:45bsteuberstbgz: there are emacs vars called swank-clojure-classpath and swank-clojure-extra-classpath
11:46stbgzwell I trying to add a jar to my project but after I run slime I get a ClassNotFound exception when trying to load the classes of the jar, I added swank-clojure-project to my .emacs and still no luck
11:47bsteuberswank-clojure-project doesn't belong in the .emacs
11:47bsteuberit is meant to be called by hand
11:47carkhso who was it that gave the advice to automatically delete trailing spaces when saving in emacs ? verrrrrry bad advice =)
11:48carkhi have this file with lots of database statements that update the database to match my program version
11:48carkhand lots of lines are ending with a ","
11:48carkhwhich i guess is considered as a white space by clojure mode
11:49carkhso when i save the file, all my trailing commas are deleted
11:49stbgzhmm so load slime and then run swank-clojure-projecct
11:49stbgz?
11:50carkhhow would that help ?
11:50carkhanyways it's too late, i need to go back put all the commas in place and retest the whole thing ='(
11:51stbgzwhat about adding the swank-clojure-classpath and
11:51stbgz swank-clojure-extra-classpath in my .emacs file?
11:51liwpstbgz: no, just do M-x swank-clojure-project (requires that you have a leiningen project.clj in your project directory)
11:52carkhstbgz: oh sorry i thought you were reacting to my crying
11:52liwpstbgz: swank-clojure-project will start slime for you
11:53liwpstbgz: using swank-clojure-(extra-)classpath is a real pain because you need to edit your .emacs when ever you change the clojure project that you're working with
11:53carkh~seen technomancy
11:53clojurebottechnomancy was last seen in #clojure, 634 minutes ago saying: I have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =)
11:54stbgzI see I was trying to do it without having leiningen around
11:54bsteuberstbgz: so swank-clojure-project finds all jar's in your project's lib subfolder
11:54bsteuberif you have clojure.jar etc. there, it's fine
11:55bsteuberI just set swank-clojure-classpath for setting the version slime uses without projects, when I just want a repl to play
11:55liwpstbgz: an alternative is to write a script that calls java for you with an appropriate classpath and then setup swank-clojure to call that script rather than java when you start slime
11:56liwpstbgz: if you google around for slime / clojure / start script you should be able to find some examples - I've seen some shell scripts and a ruby script IIRC
11:57liwpbut leiningen and swank-clojure-project is definitely the easiest way to get going once you have leiningen running, i.e. you've downloaded all of Internet with maven etc.
11:57stbgzI see i was trying to modify the swank-clojure.el but that's not the best idea
11:57liwpnope :-)
11:58stbgzalright it seems like I'll have to install ant+mave+leinigen
11:58stbgz:S
11:58liwpstbgz: enjoy :-/
11:58stbgzthanks guys
11:58stbgzcheers
11:59liwpnp
12:26underdevIs there an api index somewhere that has the clojure.core api indexed by... err.. how to say this.. what it's used for?
12:26underdevi would say function, but that wouldn't make sense in this context :)
12:27underdevie namespace functions, collection functions, etc
12:30ndimiduki get an exception when using `lein compile` from (gen-interface :name com.foo.IFoo :methods [[foo [String] "[Ljava.lang.String;"]]).
12:30ndimidukException in thread "main" java.lang.ClassFormatError: Method "foo"
12:30ndimiduk in class com/foo/IFoo has illegal signature "L[Ljava/lang/String;;"
12:30ndimidukwhat am i doing wrong?
12:57ndimidukhow do I specify a native array in a method signature within gen-interface?
12:58kotarak"[B;" or so
12:58kotarak,(class (into-array ["foo"]))
12:58clojurebot[Ljava.lang.String;
12:58ndimidukI'd like to return a String[] and using "[Ljava.lang.String;" doesn't work
13:00kotarakndimiduk: can you paste your code?
13:00ndimidukso, I have (gen-interface :name com.foo.Foo :methods [[foo [String] "[Ljava.lang.String;"]])
13:00kotarakhmmm
13:00kotarakseems right
13:01ndimidukhttp://gist.github.com/359131
13:02ndimidukoops, that type is not what i ment
13:03ndimidukfixed
13:03ndimidukyeah, so this doesn't compile. i'm using leiningen
13:04ndimidukException in thread "main" java.lang.ClassFormatError: Method "foo" in class com/foo/IFoo has illegal signature "L[Ljava/
13:04ndimiduklang/String;;"
13:06ndimiduklooks like clojure.asm.Type/getObjectType() always prepends 'L' and appends ';'
13:06ndimidukwhich is called from clojure.core/generate-interface
13:06ndimidukhttp://github.com/richhickey/clojure/blob/29389970bcd41998359681d9a4a20ee391a1e07c/src/jvm/clojure/asm/Type.java#L270
13:08ndimidukhttp://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L614
13:08dnolenndimiduk: because the JVM expects that
13:09ndimidukdnolen: in addition to what's provided in "[Ljava.lang.String;"?
13:09ndimidukdnolen: because the compiler says "L[Ljava.lang.String;;" is not a valid type specifier
13:10ndimidukdnolen: oh, you just joined. the context is http://gist.github.com/359131 won't compile
13:10dnolenyeah, I was about to say I think I missed something
13:12kotarak,(clojure.lang.RT/classForName "[Ljava.lang.String;")
13:12clojurebot[Ljava.lang.String;
13:12kotarakHmm, it's not possible to inject class into gen-interface, no?
13:13ndimidukkotarak: correct. I tried (type (into-array [""])) instead of the type string. doesn't work.
13:15chouserhm, you might try #=(java.lang.Class/forName "[Ljava.lang.String;")
13:16kotarakchouser: is there a reason gen-interface does things differently to gen-class?
13:16ndimidukchouser: haha, that works
13:16kotarakchouser: the latter basically uses with RT/classForName.
13:17chousersorry, I haven't really looked at this issue
13:17chouserRT/classForName should work as well. the key is #=()
13:18kotarakchouser: I meant that gen-class uses internally RT/classForName to resolve the classes, while gen-interface does not.
13:19chouserno, I have no idea.
13:20kotarakhttp://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L83 vs. http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L599
13:20kotarakMaybe this could be unified.
13:21chousergen-interface is largely superceded by definterface
13:21kotarakk
13:22chouserit has classloader magic that lets you redefine existing interfaces.
13:23kotarakoh, ah, "here be dragons"?
13:23The-KennyWasn't "here be dragons" the slogan of the latest chaos communication congress in berlin?
13:23chouserhm, pretty sure it's good magic
13:24stuartsierraWhat's the goal of definterface vis-a-vis defprotocol?
13:25fogusprimitives
13:25kotarakI would suspect host interaction
13:25chouseryou both beat me to it. I think those are the two benefits currently. Dunno how either of them stand up long-term
13:26chouserdefprotocol already creates a same-named host interface if you AOT
13:26chouserand I imagine defprotocol eventually will support the same primitives supported by fn
13:28ndimidukdef{interface,protocol} are in 1.2, yes? should i be using that api instead?
13:28ndimiduki've been working with clojure-1.1.0 because contrib is stable along side it.
13:30fogusI know that Clojure macros tend to have implicit pairs (i.e. cond case etc...) and I know how to write a macro that handles them (i.e. partition 2) but what about on the other hand if we are writing a macro to build the implicit pairs? I currently have an aux function that returns ((:a 1) (:b 2)) and have only been able to have success doing ~@(flatten the-pairs). Seems like there is a better way
13:31chouserI've used (apply concat the-pairs)
13:32kotarak,(apply concat [[1 2] [3 4]])
13:32clojurebot(1 2 3 4)
13:32foguschouser: That's perfect! Now I can avoid defining flatten
13:33kotarak,(mapcat identity [[1 2] [3 4]])
13:33clojurebot(1 2 3 4)
13:33foguschouser: thanks. You should write a book or something
13:33chouserother times it's useful to treat the seq of firsts and seconds separately, in which case interleave is handy
13:34chouserfogus: you mean instead of frittering away my time answering questions here, don't you. ;-)
13:34foguskotarak: Thanks.
13:35dnolenndimiduk: I use clojure 1.2.0 and contrib 1.2.0 they "seem" ok . it's might be little a bit of a workflow hassle (if you use lein or something) but it's worth it I think.
13:35kotarakfogus: many ways to Rome - eh - flattened lists. ;)
13:36foguschouser: Thanks. In this case the flatten is the answer, but what case do you see for treating them differently?
13:36foguskotarak: Seems I need to study up on the fine art of flattening
13:37kotarakfogus: and then maybe write a book about it. ;)
13:38dakrone"Flattening will get you everywhere"
13:39dakroneoh wait, maybe that's Flattery
13:39kotarakFlatten in Action, Pragmatic Flattening, The Art of List Flattening (the 5 Volume version), ...
13:39fogusHead First Flattening
13:39stuartsierrafogus: I like Head First Flattening.
13:39dakroneLearn to Flatten in 21 days
13:39kotarakTouch yourself flattening in fixnum days
13:40kotarakTeach
13:40fogusstuartsierra: sounds painful. ;-)
13:40stuartsierrayes
13:40fogusI've been waiting 2 days to say that
13:40stuartsierra:)
13:42kotarakIf I set System.in to something else... will it automagically picked by
13:42kotarak*in*?
13:42stuartsierraI don't think so
13:42kotarakgeez
13:44stuartsierra*in* is a Var in its own right, not identical to System.in
13:44fogusAlmost perfect... Just need to find a way to get rid of that ~~x
14:01maaclIs there an elegant way to interact with Java lists that only implement get() and size() methods?
14:02kotarakmaacl: define a seq on them
14:03maaclSo implement first rest and cons?
14:03hiredmanhow is that a list?
14:04maaclhiredman: It is quite strange but that is what several of the classes in the XOM library looks like.
14:04maaclThey call them lists, but I would tend to agree with you.
14:05hiredman(map #(.get LIST %) (range (.size LIST)))
14:05hiredmanor (take (.size LIST) (repeatedly #(.get LIST)))
14:06maaclah
14:06chouserI've used map like that a few times
14:06slyphonnumber of elements in a seq?
14:07chouserslyphon: count
14:07slyphonty
14:07chouserbut that's O(n) on a seq -- forces the whole thing
14:07slyphonyeah, that's ok in this situation
14:09maaclthanks - that will make it less painful
14:21Licenserdoseq: I read about your idea I've something to look at for you
15:41slyphonis it possible to run a single deftest?
15:45zaphar_psslyphon:in emacs M-x clojure-test-run-test while on the deftest form to run
15:45slyphonoh sweet
15:45zaphar_psor is it clojure-test-runtest?
15:45zaphar_pscan't remember off hand
15:45slyphonhmm
15:46slyphonthat seems like it doesn't run fixtures
15:46zaphar_psslyphon: yeah it probably doesn't
15:46slyphoneh, w/e
15:46slyphonzaphar_ps: thanks
15:47zaphar_psthere is a clojure.test/runtest also I believe haven't really used it though
15:47slyphonhrm
15:47slyphoni thought it was only "run-tests"
15:48carkhjust run it as a function with no parameters
15:48slyphonrun which?
15:48slyphonthe deftest?
15:48carkhyes
15:48slyphonoh
15:48carkh(test-id-seq-update)
15:48slyphonoh, good call
15:48zaphar_pscarkh: does that run the fixtures as well?
15:48slyphon:)
15:49slyphonyeah, apparently it does
15:49slyphonoh wait
15:49carkhzaphar_ps: i really don't know =P
15:49slyphonno
15:49slyphonit don't
15:49zaphar_pscause I thought the emacs one just did that
15:49slyphons'ok
15:49zaphar_psyeah
15:49zaphar_psyou can always run the fixtures manually
15:49slyphonyeah, i have a macro i can wrap the body of the test with
16:08chouserthey say it's "in production", though I'm not exactly sure what that means.
16:09LauJensenchouser: That probably means that they are cleaning out your typos
16:09chouserhopefully
16:10LauJensenDid you write your part in Vim by any chance ? :)
16:10chouserof course
16:10chouseram writing
16:10LauJensenok, and ehm.. I'm guessing no spelling correction in Vim?
16:10carkhah damn you're not chouser anymore but c-houser =/
16:11LauJensencarkh: You thought he was chinese too ?
16:11carkhnah just thought he was very picky !
16:22shaleshi, I'm trying to setup a google appengine project with clojure and maven
16:23shalesspecifically trying to get the make changes <-> see results loop nice and tight
16:25shalesI've got the clj source files in layed out like a war and am running the appengine devserver directly from that so I can see changes by just reloading the browser
16:26shalesbut for this to work, whenever I require a namespace it also needs to :reload
16:27shalesIs there a better way to handle this than putting :reload everywhere? Is having all of these reloads in a deployed app even a bad idea?
16:27chouseryou can do a single :reload-all at the top
16:28shalesoh, yeah. perfect. thanks!
16:29shalesI think I read that, but then totally forgot about it
16:31slyphonis there something in contrib that will diff two hashes?
16:31slyphoner, hash-maps
16:31slyphonand return just the differences?
16:32chouserjust diffs among keys, or values also? recursively?
16:32slyphonwell, in this case it's a flat hash-map
16:33slyphonin my code, i return a db row, and stash a copy of the original hash in the metadata, when that "row" is altered, and then used as the argument to my "update" function, i want to only update the cols that have changed
16:34chouserah, so the keys are the same? you want a list of keys for which the values are different?
16:34slyphonyeah, that sounds right
16:36slyphoni mean, i could probably write a for statement that does it, but i wanted to see if there were something clever that already existed
16:36chouserI don't know of such a thing.
16:36slyphonok :)
16:36chouser,(let [oldm {:a 1 :b 2} newm {:a 1 :b 3}] (remove #(= (oldm %) (newm %)) (keys oldm)))
16:36clojurebot(:b)
16:36slyphonoooh
16:36slyphonnice
16:36slyphonchouser: ty
16:49slyphonhrm
16:49slyphonif-let would be more useful it seems if it had an alternative 'else' value
16:57kotarakslyphon: like (let [foo (or if-let-clause else-value)] ....)?
16:57drewr,(deftype Foo [] IPersistentMap) (merge {} (Foo))
16:57clojurebotDENIED
16:57slyphonkotarak: something like that
16:58slyphoni guess it's intended to be used in specific situations
16:59slyphonit'd kind of behave like 'get' with the alternative value
17:00kotarakslyphon: it's called "or", no?
17:00slyphonheh, i guess it is
17:00Borkdudeif you would have kotarak's one, why not just use an if inside a let?
17:00slyphonwell, that's what i've been doing
17:01kotarakslyphon: (if-let [foo (bla) hypothetical-else] ...) <=> (let [foo (or (bla) not-so-hypothetical-else)] ...)
17:01slyphonyeah, i guess i wasn't thinking very creatively about it
17:04slyphonkotarak: i guess it's that if say, i'm using if-let to avoid some computation in the case that the test is logical false, then the (or) doesn't really help me, as the body of the if-let will still be evaluated
17:04slyphonit's more (or (if-let [...) alternative)
17:05kotarakslyphon: ??? I don't get what you want to do. (or (if-let ...) alternative) is equivalent to (if-let [..] (bla) alternative)
17:06kotarakslyphon: more or less
17:06slyphonmaybe i don't understand if-let
17:07slyphonthe first binding *is* the test, no?
17:07slyphonoh, hrm
17:08kotarakslyphon: (if-let [local (test)] (logical-true-branch might use local) (logical-false-branch))
17:08slyphonkotarak: ok, i didn't know there were two forms
17:08slyphonlike with 'if'
17:08kotarakslyphon: well, it's called if
17:08slyphonhah
17:08slyphontrue
17:08kotarakslyphon: there is also when-let
17:08Borkdude,(doc if-let)
17:08clojurebot"([bindings then] [bindings then else & oldform]); bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"
17:08Borkdudemight want to read that ;)
17:08kotarakslyphon: which is called when
17:09slyphoni need toi-let
17:09slyphon_away;)
17:12bittihm
17:12bitti(defn hash-map
17:12bitti "keyval => key val
17:12bitti Returns a new hash map with supplied mappings."
17:12bitti ([] {})
17:13bitti ([& keyvals]
17:13bitti (. clojure.lang.PersistentHashMap (create keyvals))))
17:13bitti
17:13bitti(defn hash-set
17:13bitti "Returns a new hash set with supplied keys."
17:13bitti ([] #{})
17:13bitti ([& keys]
17:13bitti (clojure.lang.PersistentHashSet/create keys)))
17:13bittiwhy sometimes the . syntax and then the / syntax for static method calls are employed?
17:13bittijust a inconsistence?
17:14kotarakbitti: old code is not changed. only in case of a patch. new code uses / syntax
17:14_ato/ is newer and didn't used to exist
17:14bittiic
17:15bittibut a patch has to be a fix? there are no consistency patches?
17:16kotarakbitti: yes. only fixes. consistency patches don't help anything, just bear the risk of introducing new bugs.
17:17The-KennyIsn't / just for static methods and . for "methods"?
17:18bittikotarak: yeah, that's why many projects never get refactored...
17:18kotarakbitti: consistency != refactoring
17:18kotarakThe-Kenny: (. SomeClass (staticMethod)) is the ancient way
17:19The-Kennykotarak: Oh ok
17:19BorkdudeThe-Kenny, in the first example create is also a static method
17:21bittikotarak: yeah it isn't refactoring, it's a kind of refactoring.
17:21bittieven a simple thing like rename is a kind of refactoring
17:26lancepantzis it possible to destructure mutlidimensional data structures?
17:26lancepantzlike {:foo {:bar "a" :baz "b"}}, can i bind to baz?
17:27kotarak,(let [[[a b] c] [[1 2] 3]] (vector a b c))
17:27clojurebot[1 2 3]
17:28lancepantzwhat about with maps?
17:28kotarakhmm let's see
17:29kotarak,(let [{:a {:b b :c c} :d d} {:a {:b 1 :c 2} :d 3}] (vector b c d))
17:29clojurebotjava.lang.Exception: Unsupported binding form: :a
17:31kotarak,(let [{{b :b c :c} :a d :d} {:a {:b 1 2} :d 3}] (vector b c d))
17:31clojurebot3
17:31kotarak3?
17:31lancepantzhahaha
17:31lancepantzthat's what i said
17:31drewrI thought this was supposed to be working now http://gist.github.com/359487
17:31hiredman,(let [{{baz :baz} :foo} {:foo {:bar "a" :baz "b"}}] baz)
17:31clojurebot"b"
17:32lancepantzthere we go
17:32lancepantzthanks hiredman
17:32kotarak,(let [{{b :b c :c} :a d :d} {:a {:b 1 :c 2} :d 3}] (vector b c d))
17:32clojurebot[1 2 3]
17:32kotarakStupid cut'n'paste bug.
17:32lancepantzthat helps, thanks guys
17:33lancepantzi think we're kinda thin on destructuring documentation
17:33kotaraklancepantz: well the recursive thing is described on clojure.org/special_forms
17:34Borkdudeit would be useful if the api had examples
17:34bittisurely lot's of irc/erc users here. no?
17:34bittiwho do you avoid smiley parsing in s-expr?
17:35bittis/who/how/
17:35licoressein colloquy?
17:36Borkdudesmiley parsing? the repl isn't an instant messaging program? ;)
17:37bittiBorkdude: sure, but this channel has a lot of s-expr
17:37Borkdudebitti: clojurebot is activated by a preceding comma
17:37licoressebitti: check with your client
17:37Borkdudeah you mean that
17:37Borkdudegtg
17:38bittiseems he didn't know a solution...
17:38_atobitti: simply don't enable the erc smiley module?
17:38_atoit's off by default isn't it?
17:38licoresseso bitti is using erc
17:39bittiI just try. I used to use irc, was enough for me
17:44carkhbitti: emacs currently comes with rcirc, very easy to use
17:47bitticarkh: yeah, that's what i meant, irc is just an alias for rcirc in emacs
17:48bitticarkh: but no matter how easy it is, I need my smileys, but not in s-expr
17:48carkhthe smiley thing doesn't come preconfigure, you probably added a script to your .emacs
17:48carkhohhh i see
17:49carkhwell you need to check your added script and modify it =P
17:50carkhtho smiling sexps must be sexxy =)
17:50bittiok, I may try to adopt all the smiley regexps :/
17:51carkhclojurebot: clojure is also making your sexp smile
17:51clojurebotYou don't have to tell me twice.
17:57brian__noob question> I want to send a number value in a multimethod, something like (defmethod count-cat [:toys :set] [category action value] (prn value))
17:58brian__then (count-cat {:category :toys} {:action :set} 10) , but doesnt work
17:59carkhwhat's your defmulti looking like ?
18:00brian__ (defmulti count-cat (fn [c a v] [(:category c)(:action a)(v)]))
18:01carkhremove the (v) from the body
18:01brian__ok
18:02brian__whats the body?
18:02carkhmake it look like that : (defmulti count-cat (fn [c a v] [(:category c)(:action a)]))
18:03brian__ok, thnks
18:03carkhdon't forget to recompile the defmethod after this
18:03brian__ok
18:04dakronealright, need some parsing advice
18:04dakronewhat would be the best way to accomplish this transformation: http://pastebin.com/f5gX4TbZ
18:04dakronekeeping a stack seems like a reasonable way, but not easy to do in Clojure
18:06tomojhow would you generate matrices like [[1 2 3] [8 9 4] [7 6 5]] (i.e. (iterate inc 1) spiraling around the matrix) in clojure?
18:06carkhdakrone: can't you just use the normal call stack you get when calling functions ?
18:06licoressepartition?
18:06tomojI can think of one way by threading a set through, but that seems too much like the imperative version to me :(
18:07dakronecarkh: what do you mean?
18:08carkhdakrone: just recursively call the same transforming function
18:08carkhwhen it's comes back from the recursive call, that's like a pop
18:08dakroneI'm just not really sure how to keep that all in a struct sort of structure
18:09carkhif the goal is only to make the transformation you're showing there, that's a very easy function to write
18:09dakronetomoj: (map #(into [] %) (partition 3 (take 9 (iterate inc 1))))
18:09dakrone,(map #(into [] %) (partition 3 (take 9 (iterate inc 1))))
18:09clojurebot([1 2 3] [4 5 6] [7 8 9])
18:10tomojdyslexic? :P
18:10dakronetomoj: ah yea, a bit :P
18:10Chousukedakrone: map vec instead :P
18:11tomojlike this https://gist.github.com/c0657ce9ce2850c9bb25
18:13dakroneahh yea, that's much more difficult
18:14RaynesAnyone have the link to that Clojure for Lisp programmers transcript handy?
18:17carkhdakrone: : check this http://pastebin.com/HPsRy8yu
18:18carkhnot exactly what you asked, but pretty close
18:20dakronecarkh: that's really cool, never used ` and ~ outside of a macro
18:20carkhah my bad, makes it harder to understand =/
18:21dakroneit's not bad, it just never occurred to me to use them outside of a macro
18:22carkhi think you should use maps : instead of (:tag symbol :chunk ...) have {:tag symbol :chunk ..}
18:23carkhthat's more clojuresque
18:23carkhalso the chunk part should always be a sequence, not sometimes a sequence and other times the sub-chunk itself
18:25dakronehaving a hard time trying to figure out how to get it run through the function, it comes out as a string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))"
18:26dakrone(eval (str "(tb '" str ")")) doesn't do the trick
18:26carkh,(read-string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))")
18:26clojurebot(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))
18:27carkhyou're using some natural language processing library ?
18:27dakroneyes
18:27dakroneopennlp
18:27carkhnice =)
18:27dakroneunfortunately they keep all the actual tree structure for this private, so instead I'm trying to parse the string output
18:28dakroneahh, there we go, (tr (read-string (.toString sb))) did the trick
18:28carkhnice =)
18:28dakronethat's awesome, thank you very much carkh :)
18:28dakroneI'll credit you in the source
18:29carkhhehe no need
18:29dakroneon the same note, there isn't an easy way to bypass the private var restriction for java classes in clojure, is there?
18:30dakronethat'd make this much better than attempting to parse a string
18:30maxhodakis it possible to access a password-protected maven repository using lein?
18:30Chousukedakrone: make sure the string form of the structure always makes sense if parsed as a clojure structure.
18:31dakroneChousuke: you mean, a valid s-exp?
18:31Chousukedakrone: I guess so
18:31Chousukedakrone: it does look like it's designed to be one
18:31dakroneyea, it does, but I'll write tests to make sure
18:32maxhodaktechnomancy|away:
18:32Chousukethings like apostrophes or double quotes could result in something unexpected
18:32dakronehmm.. good point, that would throw things off
18:32Chousukeor the # character :P
18:34carkhah true, you might want to use a real parser
18:35carkhlike fnparse from joshua choi
18:36Chousukein common lisp you'd probably customise the reader to treat ' as a symbol character and have it produce |it's| or something for things with apostrophes but Clojure unfortunately is not so flexible :P
18:37carkhwell the parsed languae looks quite regular so it should be easy to parse
18:37carkhor you could search and replace special cases beforehand
18:37Chousukethough I'm sure no-one would mind an extensible reader, as long as it's done sanely.
18:38carkhChousuke: you think CL's reader is not sane ?
18:38Chousukecarkh: well, reader macros don't compose very well
18:39carkhhow would you do it so they're composable ? looks like a difficult task
18:39Chousukeindeed.
18:39carkhi used reader macros maybe twice
18:40ChousukeI kind of like the scheme approach to reader macros; at least as far as I understand it
18:40carkhah i never played with any scheme
18:40carkhbesides this one ><
18:40ChousukeAt least PLT scheme has a #lang pragma that lets you change the language on the fly
18:41Chousukebetween, say, various standard revisions or typed scheme for example
18:41ChousukeIt's probably not ideal, or even a complete solution, but something similar could work
18:42carkhi guess reader macros would be saner with a lexical scope
18:42Chousukeperhaps
18:43carkhthat would reove a whole bunch of composability issues
18:43carkhremove*
18:44Chousukehowever, the bigger issue probably is that you could end up with everyone creating all kinds of weird mini languages bearing little resemblance to plain Clojure
18:44carkhah true, i hated cl-sql for that
18:45carkhnot quite sure on the name of that library anymore =/
18:45dakronehow badly-frowned-upon would be doing something like this: http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html ?
18:46Chousukethough I would err on the side of optimism in this case. ;P The Clojure community tends to listen to Rich and if he says people shouldn't go crazy with reader mods (assuming they become possible someday in the first place) then I think most people would listen
18:48carkhdakrone: in the long run i think you're better off doing the work to do thing the good way
18:49dakroneokay, I'll do it that way, I'll check out fnparse too
18:49carkhthere might also be some other library that does parsing for you presenting a "DOM" of some kind
18:49tomojChousuke: weird mini-languages is an issue? :P
18:50carkhhaha who doesn't love CL's loop macro ?
18:50Chousuketomoj: I think fear of fragmentation and lack of composability are the primary reasons why Clojure's reader is not extensible.
18:50Chousukeand that it's written in Java, but that's another thing entirely. :P
18:51dnolenanyone know how to constrain the amount of RAM swank-clojure-project starts the REPL with?
18:51Chousukethere was some parameter to specify jvm args
18:51The-Kennydnolen: There's some variable "swank-clojure-extra-jvm-args" or so in swank-clojure.el
18:52Chousukepass -Xmx64m or something to the jvm
18:52dnolenThe-Kenny: yeah I've set that doesn't seem to do any good.
18:52Chousukemx is max heap and ms is minimum heap (initial allocation) I think
18:53carkhi found it pretty hard to change the startup of swank-clojure, eventually i set it to run a batch file, and create it on the fly before starting slime
18:53The-Kennydnolen: After taking a look, setting "swank-clojure-extra-vm-args" to some list should work. It's used in swank-clojure-project
18:53dnolenlein swank works fine, the proper JVM settings. it's just swank-clojure-project that's giving me a headache.
18:54Chousukeswank-clojure-project might be overriding your settings ;P
19:07tomoj,(class (rationalize 1))
19:07clojurebotjava.lang.Integer
19:18tomoj,(letfn [(ratio [x y] (clojure.lang.Ratio. (bigint x) (bigint y)))] (= (ratio 0 1) (ratio 0 2)))
19:18clojurebotfalse
19:18tomoj:D
19:19tomojhmm, that is strange
19:21tomojthe identity on clojure.lang.Ratio under addition is not unique...
19:22_ato,(= 0/1 0/2)
19:22clojurebottrue
19:22_ato,(class 0/1)
19:22clojurebotjava.lang.Integer
19:22_atoah
19:23_ato,(= 1/3 9/3)
19:23clojurebotfalse
19:23_ato,(= 1/3 3/9)
19:23clojurebottrue
19:23tomoj_ato: those Ratios aren't accessible with / or with the x/y syntax, it seems
19:23tomojjust an oddity of the java class
19:24_atoah
19:24_atoyeah
19:24_atothe constructor just sets the numerator and denominator, it doesn't do any normalisation
19:24tomojchallenge: create a lazy seq of all rational numbers in as few lines as possible
19:24tomojthis is what I decided to do instead of real work
19:24tomojbut I could only get it with 34 ugly lines
19:24tomojhttps://gist.github.com/f26c30ababa4437404ab
19:25tomoj(I left out 0)
19:25tomoj(and the negatives...)
19:25_ato,(bigint (/ 1000000000000000000000000000 3))
19:25clojurebotjava.lang.ExceptionInInitializerError
19:45slyphonargh
19:46slyphoncan you publish multiple jars as part of a single pom.xml
19:46slyphon?
19:46technomancyslyphon: I think there's a plugin to do that
19:46slyphonyeah?
19:46technomancythe dog poop mailing, I mean
19:46slyphonhahahahaha
19:46slyphonwow, leiningen is the answer to *everything*!
19:47slyphoni'm trying to package up the redstone-xmlrpc lib, and i'm finding myself full of hate
19:49carkhtechnomancy: may i take a minute of your time ?
19:50Licenser_ato: clojurebot does not like big nubers
19:57technomancycarkh: sure; for something quick
19:58carkhok quickly then : i think you'e maintaining clojure-mode right now, is that correct ?
19:59carkhi've been adding a hook to my .emcs to delete trailing white spaces from my saved files
19:59carkhand it looks like this removes commas from clojure files when saving
19:59technomancyyeah, that's a bug; not sure how to get it to preserve commas inside strings and comments
19:59carkhmy guess is that clojure-mode somehow tells emacs that commas are white space as they are for clojure
19:59technomancydeleting trailing whitespace in a hook is pretty dangerous though
20:00technomancywell dangerous is a strong word
20:00technomancybut having changes applied to a file without your active involvement is iffy
20:00slyphonyeah
20:00slyphon"WTF happened?!"
20:01carkhwell i just wanted to make you aware of that, looks like you already know about it
20:03technomancyyeah, thanks
21:30defnHey all
21:30doseqHey.
21:30defnI have some thoughts on how I might achieve this but I thought I'd ask people smarter than me first:
21:31defnGiven: (some really long sexp (with nested (forms)))
21:31defnHow would you go about intelligently indenting that
21:31defnprogramatically, I mean
21:32defnregex? a parser? is there some easy logic I'm missing?
21:34carkhby using clojure.contrib.pprint maybe ?
21:34defncarkh: huh, didn't even consider that
21:34defnthat will print long sexps nicely?
21:34carkhit never is as nice as hand-crafted, but it does the job, yes
21:35defncarkh: im very grateful for the suggestion -- this looks like a "good enough" way to go for the time being
21:35defnthank you
21:35carkh=)
21:45Licenserhi defn how is walton going?
21:45defncarkh: were you thinking pprint-simple-code-list?
21:46defncarkh: was wondering if you had a pprint/* fn in mind
21:47RaynesLicenser: I added some new functions last night. Got A through C from the Clojure API. I'm getting there, slowly but surely. :p
21:47Licenserhi raek :)
21:47Licensererm Raynes narf, silly tab compleatiion. And yes i saw it, great work!
21:47carkh,(clojure.contrib.pprint/pprint '(:a "blahblah"))
21:47clojurebot(:a "blahblah")
21:48RaynesHehe.
21:53tomojRaynes: what adding do you have to do?
21:53tomojI thought it was supposed to be automatic
21:54Raynestomoj: clj-sandbox, not walton
21:54Licenserpoint of clj-snadbox is not being automatic ;)
21:54tomojoh, I misread something someone said
21:54tomojhave to go through and whitelist them?
21:54RaynesIndeed.
21:55RaynesMy goal is to go through the entire clojure core API.
21:55RaynesNot that difficult.
21:55RaynesJust lazy. :p
21:55tomojsounds like a lot of work to me
21:55tomojwould be cool if they were grouped
21:56tomojI mean presumably the whitelist will be configurable, right?
21:56tomojso you could group them into related sets and enable/disable certain chunks of clojure
21:56_atotomoj: http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox/safe_fns.clj
21:57tomojawesome
21:58Licenser*snickers*
21:58slyphonhrm, is there some debugging hook on the server side for swank? evaluating a function consistently just aborts, but there's no error in the logs or on stdout or anything
21:59defn(inc Licenser)
21:59Licensesgreat now I've a silly name
21:59slyphonhah!
22:00slyphonLicenses: cleva!
22:00LicensesI'm just glad that he didn't do something lie (sqrt defn)
22:00slyphonhahaha
22:00Licensesthatd'b e a pain!
22:00slyphonsrsly
22:00slyphonfirst you'd have to figure out what Locale he was in
22:01Licensesnah I go with ASCII
22:01slyphon:)
22:01Licensesso for defn it'd not eben be that hard I'ts only 4 byte
22:02Licenseson the other hand it is more a logical problem then a mathematical one
22:02Licensessince I would expect to work over the letters a-z and A-Z not over their number representations in the charset
22:02slyphonsure, just make it complicated
22:02Licensesnah it's not so complicated it is as complicated as binary
22:03Licensesjust a different base
22:03defncleva?
22:03slyphon"clever"
22:03slyphonbut with a colloquial twang
22:03defnah
22:03defnsorry im lagging a bit
22:03slyphonheh
22:05Licenseshmm so base 51
22:06defnthe best base I think
22:06defnbetter than 47, anyway
22:06carkhthe most natural for licenser incrementation
22:06defnincrimination or incrementation?
22:07carkhfor basic incrimination we can go with all good base 47
22:07carkhwe might get more digits that way =P
22:08RaynesIs there a function just for discarding output? Like, a function that takes anything and returns nil?
22:09hiredman,((constantly nil) 1 2 3 4)
22:09clojurebotnil
22:09RaynesThank you.
22:10tomoj51?
22:10tomojyour alphabet has 25.5 letters in it?
22:11hiredmanj is barely even a letter
22:11tomojoh, I see
22:12tomojwait, nevermind, I don't see
22:12hiredmanhttp://en.wikipedia.org/wiki/J a johnny come lately to the alphabet
22:12tomojbase n has n different symbols
22:12tomojno?
22:13_ato,(let [bb (java.nio.ByteBuffer/wrap (.getBytes "defn")), i (int (Math/sqrt (.getInt bb)))] (.clear bb)(.putInt bb i)(String. (.array bb) 2 2))
22:13clojurebot"�Q"
22:13defnhow to convert "(1 2 3)" to '(1 2 3)?
22:13hiredman
22:14defnhiredman: silly questiopn?
22:14_ato,(doc read-string)
22:14clojurebot"([s]); Reads one object from the string s"
22:14defnquestion*
22:14hiredmanare you sure you want '(1 2 3)?
22:14hiredman_ato: well he would have to cons 'quote on afterwards
22:14defn(1 2 3), i suppose
22:15defnthe ultimate destination would be the quoted form
22:15defnbut the intermediary step i guess is what i was looking for
22:15_ato,(= (read-string "(1 2 3)") '(1 2 3))
22:15clojurebottrue
22:15hiredman'(1 2 3) is an illusion
22:15defn_ato: thanks much
22:15hiredman,(macroexpand ''(1 2 3))
22:15clojurebot(quote (1 2 3))
22:15_ato,(read-string "'(1 2 3)")
22:15clojurebot(quote (1 2 3))
22:15hiredmanwell
22:15hiredman,''(1 2 3)
22:15clojurebot(quote (1 2 3))
22:25dcnstrctI can't figure it out... last night swank-clojure-project was respecting my (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/myproj/whatever.js")
22:25dcnstrctbut tonight it stopped working
22:25dcnstrctand no code has changed I simply restarte emacs
22:26dcnstrct,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")
22:29_atodcnstrct: the path shouldn't start with src/ unless you have this file under myproj/src/src/myproj/whatever
22:30dcnstrctwow that was it
22:30dcnstrctmaybe last night I started swank-clojure-project in the wrong directory or something
22:30dcnstrctwho knows... but that works.. thanks
22:30tomojI think you can put them in resources/ too?
22:30dcnstrctthats probably a much better idea actually.. keep it tidy
22:31tomojI still don't really understand how to stick stuff in there and give http access to it without security problems
22:33dcnstrct (GET "/loading.gif" (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/bots/pva/loading.gif"))
22:33dcnstrctI don't care if hackers steal my loading indicator gif
22:35hiredmanclojurebot: ping?
22:36hiredman:(
22:36hiredmanclojurebot: ping?
22:36clojurebotPONG!
22:37dcnstrctI wonder if I broke him with that command earlier
22:37dcnstrct,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")
22:37clojurebotnil
22:40hiredmanI was monkeying with internals
22:45ct__Jennifer Aniston likes Clojure: http://java.ociweb.com/mark/clojure/ (Sound Clip #1 at the bottom)
23:04defnheh
23:04defnthe inspiration for me buying getclojure.org/com
23:04defngetclojure.org:8080/examples/function
23:14dgreenspcan I type-hint the return value of a defmethod?
23:16dgreensptype-hinting the name of a defn works, right? what's the mechanism behind that?
23:16dgreenspand yes, I do need the speed :P
23:17Apage43no reason why it wouldn't work, i think.
23:25dgreenspoh, except having different type hints for different defmethods in the multimethod isn't really helpful at compile-time...
23:29trptcolindefn: that's pretty sweet
23:33_atodysinger: look at the :prompt option of clojure.main/repl
23:34_atoor in fact :need-prompt
23:37dysinger_ato: thanks
23:59slyphoni'm confused about the "implicit this"
23:59slyphonin proxy methods