#clojure logs

2009-11-04

00:00PuzzlerI think he's saying he likes it so far, but finds it intimidating to get started and wishes it were easier to jump in.
00:00G0SUBPuzzler: hmm, I am sure you are right.
00:01tomojhmm
00:01tomojI can barely remember what it was like for clojure to feel intimidating
00:02G0SUB(ns foo (:use [clojure.contrib.str-utils :only (str-join)]) vs. (ns foo (:use [clojure.contrib.str-utils :only [str-join]])
00:02somnium,(take 50 (clojure.contrib.seq-utils/shuffle (take 100 (iterate inc 1))))
00:02clojurebot(78 58 85 53 60 83 45 50 56 20 31 92 62 10 57 30 80 43 6 18 97 96 55 72 8 88 12 17 7 19 26 42 64 67 46 39 21 54 27 4 47 84 93 1 87 100 25 81 33 59)
00:03G0SUBboth of them work, why is the first preferred over the second?
00:04G0SUBwhy use a list instead of a vector as an arg to :only?
00:04somniumG0SUB: not an answer, but (ns foo (use bar)) is also valid
00:04tomojwho says the first is preferred?
00:04somniumthe macro doesn't seem to care as long as it get some kind of string and some kind of seq in the right places
00:05tomojI think I like the first because it helps make the list of symbols look different than the vector wrapping the libspec
00:05tomojbut really it is absolutely only a stylistic matter
00:10hiredmanugh
00:15tomojwhat's an efficient way to take a seq like '([a b] [c d] [e f]) and get '(a c e) and '(b d f)
00:16somnium,(map first '([a b] [c d]))
00:16clojurebot(a c)
00:16tomojsure
00:16tomojbut then we have to crawl the seq twice
00:17somniumah, you probably need to reduce then, but only one return val
00:17somniumis [[a c e] [b d f]] ok?
00:18tomojwell I could see how to do that with a reduce
00:18tomojbut I'd rather have a pair of lazy seqs
00:20tomojhmm, I think I'm not thinking straight
00:20somniumnot sure I understand what return val is the goal
00:20tomojif you have a pair of lazy seqs as the return val, then they will crawl separately, and so you'll crawl the original seq twice
00:20somniumyou could use something mutable like an array and a doseq, but I don't think thats what youre after
00:22somniummaybe one lazy seq that conses onto n lists?
00:22somniumthat way you only crawl once
00:22somniumso returns [[lazy-a ...] [lazy-b ...]]
00:23tomojI don't see how to do it with one lazy seq
00:23tomojI'm being given a seq like [[key1, val1], [key2, val2], ...] and I want a lazy seq of keys and a lazy seq of vals
00:24somnium(map #(list (first %) (last %)) (...))
00:24somniumyou still have to split them out, but each node gets processed only once, closer?
00:24tomojthat's pretty much the identity
00:24somniumer
00:27tomoj,(map #(list (first %) (last %)) '([a b] [c d]))
00:27clojurebot((a b) (c d))
00:27somniumreduce isn't lazy is it...
00:28tomojnope
00:28tomojmaybe I'm talking nonsense
00:29somniumcan you do it with lazy-seq and cons somehow?
00:29tomojseems like it might be impossible to split a seq of [[key, val], ..] into two lazy seqs of (key, ..) and (val, ..)
00:29tomojI mean, without having each lazy seq crawl the seq on its own
00:30tomojmaybe having each lazy seq crawl the seq on its own is OK
00:30somnium(nth keyseq n) would have to get (nth valseq n) if they crawl together?
00:32tomojhmm
00:32tomojyou know you may be right
00:32tomojif you close over a lazy-seq of the keyval pairs
00:33tomojand have each of the lazy seqs keep a reference to that
00:35tomojI am utterly confused
00:35somniumI'm guessing laziness is key? if they both close over it will it ever get GCed?
00:36somniumI need to try out the new branch, been frustrated with performance of gen-class vs. java
00:36tomojwell i was thinking you could return a pair of lazy-seqs
00:36tomojbut they both reference the same lazy-seq in the background through the closure
00:38tomojwell
00:38tomojthen they both will crawl it separately anyway I guess
00:40somniumcould you lazily reduce onto two lists? something like (cons n (reduce #(...) (take n key-vals)))?
00:41somniumer, the first n should be a list with the transformed lists, and you cons on them as needed with reduce,
00:42somniumtomoj: its been a nice break from my problem domain, what's it for, out of curiosity?
00:43tomojwell
00:44tomojcouchdb sends a list like [[key, val], ..] to the view server
00:44tomojbut the javascript view server calls reduce functions with a list of keys and a list of vals as parameters
00:47tomojof course I don't have to make my clojure reduce functions act like javascript reduce functions, hmm
01:55kjacsHello, I am trying to run the Norvig Spelling Corrector example and I'm running into issues with (or). What should (or () () '(1 2 3)) eval to? The example assumes '(1 2 3) but I am getting ().
01:56arbschtkjacs: that is CL code. in clojure, () is not NIL.
01:57arbscht,(or () true)
01:57clojurebot()
01:57arbscht,(or nil true)
01:57clojurebottrue
01:57arbscht,(nil? ())
01:57clojurebotfalse
01:58kjacshrm, is the example (http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Norvig_Spelling_Corrector) incorrect or am I doing something wrong?
01:59noidi,(not (not ()))
01:59clojurebottrue
01:59arbschtkjacs: I think that code may be obsolete. () used to be nil in clojure
01:59kjacsah ok
02:07kjacsarbscht: thanks for your help. I found my problem. The example I posted actually works. I was using the example on (http://en.wikibooks.org/wiki/Learning_Clojure). The working example wraps the for loop in a seq returning nil and not ().
02:17tomojI think the idiomatic way is to call seq in the test
02:18kjacstomoj: ah, so (or (seq (fn1)) (seq (fn2))) ?
02:28tomojI guess
02:28tomojI mean, if you use seq in the test it will work no matter what sequential thing is passed in
02:29tomojif you put it in the functions which generate the seq, then your test will only be guaranteed to work when it takes the results of those functions as input
03:34tomojwhat should the type be for into-array when making an array of arrays of doubles?
03:36tomojoh, it can figure it out on its own
03:45hiredmandamn
03:45hiredmanyou cannot call clojure.xml/parse on appengine
03:46hiredmantomoj: Double/TYPE
03:46tomojthe type of an array of doubles is Double/TYPE?
03:46hiredmannot really, but it is what you put in the type slot
03:47hiredman,(make-array Double/TYPE 1)
03:47clojurebot#<double[] [D@1021e58>
03:47tomojbut that's an array of doubles
03:47tomojI'm making an array of array of doubles
03:47hiredmanOh
03:47hiredmanuse into-array :P
03:48tomoj(into-array (map #(into-array Double/TYPE %) ...)) works
03:48hiredmanwell there you go
03:48hiredmanif clojure.xml/parse doesn't work, I guess I'll switch to json
03:48hiredmanhmm
03:49hiredmanI must be doing something wrong
03:49hiredman,(doc clojure.xml/parse)
03:49clojurebot"([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"
03:51hiredmanthere we go
03:52hiredmanI was passing it a string that was not a url, which caused it to do something appengine did not like
04:21hiredman,(doc merge-with)
04:21clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
04:49hiredman~hiredman
04:49clojurebothiredman is an evil genius.
04:49hiredman~hiredman
04:49clojurebothiredman is slightly retarded
04:49hiredmantheres the one
05:36stephenj#clojure
05:37stephenj(+ 1 2)
05:37clojurebot3
05:37stephenj~*ns*
05:37clojurebotNo entiendo
05:37stephenj*ns*
05:41tomojwhy did clojurebot eval that?
05:41tomoj(+ 1 2)
05:41clojurebot3
05:41tomojweird..
05:42hiredmanI have got a facebook app up and running on appengine in clojure
05:42hiredman(+ 2 3)
05:42clojurebot*suffusion of yellow*
05:43hiredmanthat was painful
05:43hiredmantook me aroudn five hours
05:44hiredmanfor so little
05:44hiredmanhttp://apps.facebook.com/agegraph/
05:45CalJuniorSo facebookers are either 24, 28 or 43 (or don't know their age) :-)
05:46CalJuniorright, I guess I have very few friends on facebook
05:47CalJuniorhiredman: how did you go about it. where was the pain?
05:47hiredmanmine are mostly unkown
05:47hiredmanwhich is annoying because I made the app because I wanted to know
05:47hiredmanCalJunior: the facebook api seems to be very php centric
05:48CalJuniornow you know they don't want you to know. there's information in that.
05:49hiredmanthe range is 14 to 64 with a hump at around 20 for the known ages
05:49CalJuniorAny pain in getting Clojure to play nice with GAE?
05:49hiredmannot too much
05:50hiredmanI wrote an appengine helper ant thing a while back, I did have to rip the multipart mime stuff out of compojure
05:50hiredmanI should feed this stuff back into appengine-helper sometime
05:51hiredmanhttp://github.com/hiredman/appengine-helper
05:52hiredmanand appengine-helper needs a deploy target
05:55CalJuniorthanks for the link.
05:56hiredman*cough* it hasn't had much testing
06:01hiredmannow that I've finished that, it's 3am and I'm all keyed up
06:17stephenj(+ 1 1)
06:17clojurebot2
06:17ordnungswidrig(+ 1)
06:17clojurebot1
06:17ordnungswidrig()
06:17ordnungswidrigclojurebot: when do you eval?
06:17clojureboteval is evil
06:19hiredmanclojurebot: how much wood would a wood chuck chuck if a wood chuck could chuck wood?
06:21hiredmanclojurebot: well?
06:21clojurebotNo entiendo
06:24hoeckmaybe clojurebot is confused when to treat `,' as whitespace
06:24hiredmanI doubt that
06:50AWizzArd_Is there an easy way to take a subarray of an array?
06:52AWizzArd,(into-array Byte/TYPE [10 20 30])
06:52clojurebotjava.lang.IllegalArgumentException: argument type mismatch
06:52tomoj,(into-array Byte/TYPE (map byte [10 20 30]))
06:52clojurebot#<byte[] [B@1a59727>
06:53hiredmanyou could use byte buffers to do it
06:53hiredman(I think)
06:53AWizzArdoki, I will have a look, thx
07:04cemerickrhickey: would you prefer early deftype/class feedback here or on the list?
07:06avitalHi. Just installed clojure-mode using ELPA and I can't seem to use clojure-contrib. I am trying to eval (use 'clojure.contrib.json.read) and I get a FileNotFoundException. Anything from clojure core works. It was my understanding that clojure-mode should support clojure-contrib immediately. I searched google and couldn't find any record of such an issue. Anyone have an idea?
07:11liwpavital: make sure that clojure-contrib has been installed
07:11liwpI can't remmeber is the clojure-mode installer installs it or not
07:12avitalliwp: In src/ (the directory clojure-mode puts all the installation stuff) there is a clojure-contrib directory. Where else should I check?
07:12liwpavital: hmm, check that it's on your class path
07:13liwptry this in the repl: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
07:13liwpyou should see clojure-contrib in the output
07:13tomojdid you use clojure-install?
07:13avitalHmm. it's there
07:13avitaltomoj: Yes
07:14tomojand you added the config they told you to add?
07:14liwpavital: then check that it's been built
07:14avitalLet me check the actual file it points to.
07:14avitaltomoj: I added (clojure-slime-config)
07:14tomojI guess if your src/ is in the default place that should work
07:15avitalIt points to a JAR that exists: ~/src/clojure-contrib/clojure-contrib.jar
07:15avitalA friend just also did clojure-install and gets the same error.
07:16tomojC-h v swank-clojure-classpath
07:16liwpavital: try running the repl from the command line using both the clojure.jar and clojure-contrib.jar that were installed by clojure-mode
07:16tomojthe correct path to clojure-contrib.jar is there?
07:17avitaltomoj: It's there and I checked - the file is really there.
07:17avitalliwp: Good idea, one minute.
07:18liwpFYI: my swank-clojure-classpath points to both the src and classes dirs in contrib, but not to the jar
07:18tomojdoes clojure-install still install old stuff?
07:18tomojmaybe it got the 1.0 branch and that doesn't have json stuff? I dunno
07:20liwpavital: try also loading some other contrib stuff, maybe it's an issue with the json lib, like tomoj suggested
07:21avitalHmm.
07:21avitaljava -cp ../clojure-contrib/clojure-contrib.jar -jar clojure.jar
07:21avitalI still don't have clojure.contrib.json.read
07:21liwpavital: the (use...) form works for me, but I'm not using the clojure-mode install
07:21avitalI also tried clojure.contrib.monads
07:21avitalAlso fails
07:21tomojjar -tf .../clojure-contrib.jar and see if json stuff is in there
07:21liwpavital: try putting both jars in the -cp option
07:22avitaltomoj: json is there
07:22hiredman-jar and -cp are mutually exclusive , btw
07:23liwpavital: are the clojure and contrib directories git checkouts? maybe you can try moving to HEAD if they are checkouts of the 1.0 tag or something...
07:23avitalliwp: Still doesn't work.
07:23hiredmanif you use -jar java silently ignores -cp
07:23avitalliwp: They are git checkouts, I think they are the 1.0 tag indeed.
07:24avitalhiredman: I tried with just -cp on both and specifying clojure.main as the class to run.
07:24avitalhiredman: still doesn't work
07:24avitalliwp: But I see clojure.contrib.json.read is there...
07:24tomojlike java -cp .../clojure.jar:.../clojure-contrib.jar clojure.main ?
07:25avitalavital@avital-laptop-2:~/src/clojure$ java -cp ../clojure-contrib/clojure-contrib.jar:clojure.jar clojure.main Clojure 1.0.0--SNAPSHOT user=> (use 'clojure.contrib.json.read) java.io.FileNotFoundException: Could not locate clojure/test__init.class or clojure/test.clj on classpath: (read.clj:0)
07:25hiredmanoh
07:25hiredmanyou have an old version of clojure and a new version of contrib maybe
07:25avitalOh I just notices it's not json.read that it can't find!
07:26tomojwhy would clojure-install check out mismatched versions?
07:26hiredman*shrug*
07:26hiredmanI'm not an emacs user
07:26tomojunless there's some reason you want to be on 1.0, check out master on both repos and rebuild
07:27hiredmanclean and rebuild
07:28tomojdefault target cleans for me
07:28avitaloh wow i rebuilt clojure and now when i rebuild clojure-contrib i get errors
07:28avitallet me try switching to head
07:29tomojisn't switching to head like walking to here?
07:32avitalI think they are on head. Is it possible that clojure-contrib is currently broken? Or did someone just say they tested it and it works?
07:32avital(when I run ant -Dclojure.jar=../clojure/clojure.jar in clojure-contrib I get errors)
07:33avital[btw thanks for all the help!]
07:33tomojhow did you get them to be "on head" ?
07:34avitalI just looked at .git/config and it seems that they are already on head (how would you say that other than 'on head'?)
07:34avital[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git://github.com/richhickey/clojure-contrib.git [branch "master"] remote = origin merge = refs/heads/master
07:34tomoj.git/config is irrelevant
07:34avitaloh ok
07:34liwpavital: what does git branch -a say?
07:34tomojI believe HEAD is whereever you currently are
07:34tomojdo git checkout master
07:35tomojperhaps also git pull, though you should already have the latest
07:37avitaloh wow clojure wasn't on head. now that it is clojure-contrib doesn't have compilation errors!
07:37avitallet me try json.read again
07:38liwpavital: you should check if your contrib checkout is on clojure-1.0-compatible or on master
07:38avitalliwp: it was and is on master
07:38liwpavital: ok
07:38avitalOH WOW IT WORKS NOW WOW OW WO WO WO OW OW OW OW
07:38avitalWOWOW
07:38avitalwOWOWOWO
07:38avitalTHANKS
07:39avitalok
07:39liwpavital: that definitely won't work then if you had a 1.0 clojure
07:39liwpnp
07:39avitalto whom to i send the bug report about clojure-install?
07:39avitalor a patch
07:47liwpavital: I think technomancy (Phil Hagelberg?) is the maintainer these days
07:50patricius_is there some clever way to reset the Clojure REPL without restarting clojure (and java potentially)?
07:50avitalliwp: Ok thanks, I'll send him a message on GitHub
07:51noidipatricius_, why do you need to reset it completely?
07:51patricius_just to ensure that no agents are running and that all previous definitions have gone away... maybe that is a complete non-issue?
07:53tomojpatricius_: certainly not a non-issue
07:53tomojdeveloping on the repl can hide bugs that won't show up until you restart
07:54tomojfrom moving/renaming/deleting functions
07:55patricius_tomoj: yeah... that was what I was thinking
07:55patricius_so the best thing to do is just restarting the REPL?
07:56tomojthat's what I do
07:56patricius_ok
07:56patricius_cool
07:56tomojI think there could be a clever way to crawl through and unbind everything
07:56tomojbut I don't know of anything clever to do about agents
07:56patricius_that's allright
07:57patricius_I am asking because I have started using a SLIME-like thing for Vim, and I didn't want to have to restart clojure all the time to be sure that things would work right
07:57tomojI tend to restart the repl often anyway since I work on a bunch of different things and use swank-clojure-project to get a repl for each different thing
07:57patricius_and by the way, this SLIME-like thing works really well and is MUCH easier to setup than VimClojure in my opinion
07:57patricius_oh ok
07:58tomojwhat's this SLIME-like thing called?
07:58patricius_slime.vim :)
07:59patricius_it essentially just sends stuff to a screen session, so you don't run the REPL inside vim
07:59patricius_but for me that doesn't matter
08:39dabdThe ant build script does not include clj source files in clojure.jar so 'clojure.contrib.repl-utils/source' doesn't work. What can I include the sources? thx
08:39dabdSorry I meant 'How can I include the sources?' thx
08:50chouserI usually just include the src dir in my classpath. Sorry that doesn't answer your question.
08:54rhickeyin fact, I thought they were left there specifically for tools
08:54dabdwell I am using enclojure and I get this error: http://paste.lisp.org/+1X9T
08:55chousersure enough -- clojure.jar and clojure-slim.jar both seem to have the .clj files
08:55rhickeycan't find clojure.contrib.repl-utils
08:56chouserdabd: you do need to 'require' a namespace before you use it
08:57chouserthis is unlike Java classes that can be used without previous ceremony as long as you fully-qualify the class name.
08:57cemerickdabd: right, what chouser said: (require 'clojure.contrib.repl-utils), then (clojure.contrib.repl-utils/source reduce)
08:58dabdok it works now. thanks
08:59rhickeyor maybe (require '[clojure.contrib.repl-utils :as repl]) ... (repl/source reduce)
08:59chouserI'm going to have to find a way to subdivide the daily #clojure logs. total average daily traffic is definitely on an upward trend.
09:00cemerickdabd: in a real app, you'd put such requires, etc., in an ns declaration at the top of your source file, aliasing the namespace as rhickey did just now
09:00dabdok I understand
09:00dabdthanks
09:00chouserrhickey: do you have any thoughts about default namespace aliases that would somehow still present a clear link between the usage of the alias and the actual namespace providing it?
09:01rhickeychouser: in favor of default aliases, unclear about what you mean by clear link
09:03chouserI mean if (uses com.foo.bar) (cfb/do-it) works, it's not at all obvious that cfb is the same as com.foo.bar.
09:04rhickeychouser: seems a general problem of nicknames, smaller, more likely to collide, less descriptive
09:05rhickeydo you have ideas?
09:05chouserthe explicit :as avoids the problem now, but I'd also like default aliases.
09:05chousernot good ideas, no.
09:05cemerickseems like c.f.bar is reasonable for com.foo.bar
09:05cemerickassuming the namespace components are longer than that :-)
09:06rhickeycemerick: that will drive people to very short namespace names
09:06rhickeyfor the last segment I mean
09:07cemerickyeah. I almost uniformly just alias the last component of the ns name, but that's obviously not a general approach.
09:07chousergenerating the default alias is interesting though
09:07cemerickI'm not entirely sure default aliases are necessary, anyway.
09:08chouserone benefit of default aliases is that it would encourage everyone to use the same alias for common namespaces, which would have benefits across the board.
09:09cemerickit only matters within each namespace -- do I care what you alias seq-utils to in your ns?
09:09chousercemerick: if you're reading a snippet of my code, yes.
09:09chouserif I alias it the same as you do, you won't even have to go look at the 'ns' block to know what's going on.
09:10rhickey(just musing here) - could do - not an exact classname ?, then is it an unambiguous shortening of a referenced ns?
09:11rhickeyc.c.repl enough for repl utils
09:11cemerick:as is pretty darn easy, and idiomatic usage is, too. If auto aliasing could work well and be generally applicable, then we might as well make all namespaces one level deep.
09:11rhickeyor even repl
09:11chouserlike the last component? bar for com.foo.bar? or more general -- ah. hm.
09:12rhickeydoesn't give you consistency
09:12chouserwhy does that remind me of VMS?
09:12rhickeybut need not be declared nick, no conflicts possible
09:14rhickeyany feedback on deftype/class/reify?
09:14chousership it
09:14rhickeyheh
09:15cemerickrhickey: I've got a bunch...want it here or on list?
09:15rhickeythat's another issue, whither 1.1?
09:15rhickeycemerick: either, short version here would be a good start, before I move deep into protocols
09:16rhickeyI think we need to get a 1.1. out before pulling new into master
09:16chouserah, interesting.
09:17rhickeyonly master gets the workout needed for pre-release
09:18fogus_cemerick: If it's all the same, feedback is more easily consumed outside of IRC
09:19rhickeyoh yes, not trying to discourage that, please post to group also
09:20rhickeyjust, we're both sitting here...
09:21fogus_Understood. My IRC connection is perilous... so I would hate to miss something. :)
09:23ordnungswidrigfogus_: there is a irc log, isn't it :->
09:24cemerickrhickey: I'll do a quick rundown here, and post if anything significant comes out of it. I'm recording a podcast at the moment. :-)
09:25chouserhaha!
09:37tknudsen /home/tknudsen/Desktop/Working/enclojure/build.xml:2: Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
09:38tknudsenCause: The name is undefined.
09:38tknudsenpeeps, any ideas?
09:39fogus_ordnungswidrig: Yes, on chouser's site... but there is a lot of noise to filter through.
09:43chouserthat would be a brilliant way to split up each day -- a list of threads at the top of the page.
09:46fogus_chouser: I like that idea... it would make the IRC logs an invaluable resource. (more so than they are already)
09:49cemerickrhickey: so, my first question: was it intentional to make all non-primitive args into defclass ctors Object?
09:51rhickeythere isn't yet the plumbing under the hood to distinguish locals of non-primitive types, but eventually I'd like to enforce via explicit types for construction and storage
09:53cemerickrhickey: FWIW, I'd be very happy with two ctors: one typed, and one untyped. The reason being, I'd like to be able to drop IDerefs into those ctors as desired, and I'd make the associated .field getters unpack those IDerefs as necessary. Perhaps stuff like that should go into a layer on top of defclass, but that's one aspect of our typical usage.
09:55rhickeycemerick: I don't get that, you couldn't put the IDeref into a field of the type of the thing it held
09:56rhickeywhat is the type of the field?
09:56cemerickrhickey: to be clear, we wouldn't be accessing fields anyway -- we have a set of interfaces that declare getter methods (without the "get" part) for each slot, and those are typed.
09:56cemerickSo, we might end up just typing everything as Object.
09:56rhickeyok, then I don't see the typed/untyped ctor use case
09:57cemerickrhickey: That's for the impl of those interfaces for use by our Java-using customers :-)
09:57rhickeyI wonder about a defstatic for factories etc. Exposing ctors is always a problem
09:58cemerickYeah, that's a route we've experimented with using genclass, which seems to work very well.
09:59rhickeydefstatic could be a great target for some higher-level 'package my Clojure up for Java' thing
09:59cemerickright
09:59cemerickanyway, the types on the ctor are irrelevant compared to my #2: please oh please provide a ctor that defaults metadata and expando maps to nil.
10:00cemerickadding two nils or ", null, null" in java to every defstruct ctor invocation is unpleasant :-)
10:00chousercemerick: I'm pretty sure that's planned just not done yet.
10:01rhickeycemerick: I hear you on that, always trips me up and an asymmetry with deftype factory fns
10:01cemerickThat's great.
10:01chouseroh, maybe I'm confusing with the factory fns.
10:01rhickeyright now just a side effect of the ctor-generating code being on the Java side and completely ignorant of metadata etc
10:02rhickeythe __ stuff is a bit precious, but I am already leveraging that in generating lookup thunks (I don't gen for __meta and __extmap)
10:03rhickeychouser: right, factory fns have 2 arities right now, ctors only one
10:03rhickeyvery convenient to sat (deftype Foo [a b c]) ... (Foo 1 2 3)
10:03cemerickso next up is: it's worth noting in the docs that arity overloads in method impls are broken out in the new regime, which is different from typical fns
10:04AWizzArdDoes .read of an InputStream block until the data is available?
10:05rhickeycemerick: ah, is noted here: https://www.assembla.com/wiki/show/clojure/Datatypes
10:05rhickey"If a method is overloaded in an interface, multiple independent method definitions must be supplied."
10:05cemerickah, I only skimmed reify, went straight to deftype/class
10:07cemerickmy #4 is: all methods on defclasses are declared as throwing Exception. This is really, *really* painful on the Java side, and incongruent with the interfaces the defclasses are implementing.
10:08chouser:-(
10:09rhickeycemerick: that's a bug, see //todo don't hardwire this
10:09cemerickNice, very good to hear.
10:10cemerickrhickey: finally, why specify interfaces after fields? That seems totally backwards to me (and putting the shorter vector after the longer one, which doesn't help readability).
10:11rhickeycemerick: because I hope for many use cases with no interfaces or methods at all
10:11rhickeysimple struct-like things extended via protocols
10:12cemerickOK, I can get along with that. :-)
10:12cemerickrhickey: that's all I've got for now. I've dumped most usages of our PSM macros overboard, and all our tests are green. :-)
10:13rhickeygreat! and perf?
10:13rhickeyI've got:
10:13rhickeyinterface methods should have interface exception types, not hardwired
10:13rhickeyctor without meta and extmap
10:13rhickeytyped non-primitive fields
10:14cemerickyup, that's all of it
10:15cemerickonly a slight bump in perf (maybe 5%?), but the hottest usage of the PSM macros hasn't yet been replaced, because it's particularly gnarly. I'm hoping to cut that knot this morning.
10:16cemerickI'm really looking forward to dumping that code, though. That'll be a big load off.
10:17cemerickProducing a couple of *simple* macros for autogenerating accessors and bean-compliant getters, etc., will be super-easy, I'm looking forward to that.
10:18cemerickI had stopped adding to our PSM macros because they became far too complicated to touch :-( gen-class is a beast!
10:19liwpcemerick: what's PSM?
10:20chouserPersistentStructMap
10:20liwpthank you
10:30cemerickusing (.methodName) in reify, et al. was a great move
10:33cemerickrhickey: it would be convenient if (defclass Foo ...) were to emit an implicit (import 'my.ns.Foo)
10:50manby-aceHas anyone done any work getting slime / swank going with ClojureCLR?
10:51liwpmanby-ace: I think swank-clojure supports only the JVM implementation of clojure
10:52liwpso you'd need a clojureclr implementation of swank, and I haven't heard of one
10:52manby-acellwp: cheers, just wondering if that might have already been started. I'll commence hacking then :-)
10:52liwpmanby-ace: carry on
10:53liwpmanby-ace: I should add that I haven't really been following the ClojureCLR world at all, so there might be an impl, but I just haven't heard about it
11:01cemerickrhickey: just FYI, I just replaced the Java class that is instantiated and accessed the most in our main project (a simple rectangle struct) with defclass, and perf is identical.
11:02cemerickI think that's the only part of our data model that was still in Java.
11:05rhickeycool
11:08danlarkinawesome!
11:08arohnercemerick: was it in java because you needed the performance?
11:08cemerickarohner: yes. We were taking a 10-30% hit on perf if we used the gen-class version of the struct.
11:08cemerick(depending on the dataset benchmarked)
11:09arohnergreat
11:12cemerickreify should be quite a bit faster than proxy all around, correct?
11:12rhickeycemerick: oh yeah
11:13cemerickOK. I'm trying to prioritize the porting :-)
11:13cemerickbasically: turn over everything!
11:13rhickeycemerick: matching exception types is up
11:16cemerickrhickey: excellent, thank you
11:16rhickeythanks for the feedback
11:17cemerickrhickey: thank you very much for the wonderful tools! :-D
11:18cemerickwhat does this indicate: Mismatched return type: containedBy, expected: java.util.Collection, had: java.lang.Object
11:19cemerickFWIW, containedBy is defined by an interface, as a return type of Collection
11:19rhickeycemerick: is it overloaded?
11:19rhickeyor, derived from another interface with covariant return type?
11:19cemerickrhickey: no -- there are other methods on that interface that are overloaded, but not containedBy
11:20rhickeyare you supplying type hints?
11:20cemericknot on any returned values, etc.
11:20rhickeyat all on containedBy?
11:21rhickeyi.e. on the signature
11:22cemerickrhickey: Yes, I had a type hint on the single argument. Removing it eliminated the exception. The type hint was correct, FWIW.
11:22cemerickObviously not needed in reify, but should it cause an exception?
11:22rhickeycemerick: once you type hint anything you must get all the hints right, leaving off the return hint defaults to Object
11:22cemerickah-ha
11:23cemerickeven if the method isn't overloaded?
11:23rhickeyyes
11:23rhickeywhy hint at all then?
11:23cemerickwell, I had to with proxy :-)
11:24rhickeythat was the old days
11:24cemericka lot of stuff is going away with the porting
11:24cemerickyeah
11:24cemerickI'd update the docs to indicate that any type hinting requires complete hinting. Right now, my read of them is that they say that only incomplete hints on overloaded methods will cause problems.
11:26rhickeycemerick: its doesn't actually require complete hinting, just correct hinting, i.e. default of Object ok if Object - clarifying now
11:26fradiavaloHi guys, I am having some trouble with re-matches..not sure why (re-matches #"ab+" "abc") returns nil, where as (re-matches #"[-+]?[0-9]+/[0-9]+" "22/7") returns "22/7"
11:28rhickey"if you supply any hints at all, no inference is done, so all hints (or default of Object) must be correct, for both arguments and return type"
11:28cemerickyeah, that's better :-)
11:29cemerickanything involving JIT is tough to peg, but my impression so far is that perf is plateauing a lot faster now (i.e. less warm-up to get JIT'ed code).
11:31fradiavalough, I figured it out, I had a buggy regex. Sorry for the noise.
12:31rhickeycemerick: fields-only ctor is up
12:44hiredmanclojurebot: max people?
12:44clojurebotmax people is 255
12:44hiredmanclojurebot: really?
12:44clojurebotHuh?
12:46cemerickrhickey: gorgeous, thank you.
12:47cemerickrhickey: is there any perf penalty associated with the default IPersistentMap impl?
12:47cemerickon deftype/class, that is
12:56chouseroptional interfaces list could come before a required fields list. ...is that too magical?
13:03AWizzArdhiredman: no, it's not true
13:03AWizzArdsomeone cheated and changed that var
13:05cemerickchouser: I suggested that earlier, but I think rhickey is expecting a lot of types unassociated with interfaces
13:05chousersure, it can still be optional
13:06hiredmanclojurebot: max people is 180ish
13:06clojurebotIk begrijp
13:06cemerickI think it would read better with interfaces first (I like to have shorter forms before longer ones, etc), but it's fundamentally unimportant to me.
13:06chouserI saw you suggest changing the order, I'm just saying I don't see why the interfaces list being optional mean is has to come later.
13:06cemerickah
13:06hiredman,(Integer/parseInt "180ish")
13:06clojurebotjava.lang.NumberFormatException: For input string: "180ish"
13:06hiredmannuts
13:06chouser,(read-string "180ish")
13:06clojurebotjava.lang.RuntimeException: java.lang.NumberFormatException: Invalid number: 180ish
13:07chouser,(read-string "180 ...ish")
13:07clojurebot180
13:07rsynnottheh
13:07hiredman,(Integer/valueOf "180ish")
13:07clojurebotjava.lang.NumberFormatException: For input string: "180ish"
13:08hiredmanclojurebot: max people?
13:08clojurebotmax people is 255
13:09hiredmanhaha
13:11AWizzArdclojurebot: max people is 188
13:11clojurebot'Sea, mhuise.
13:12AWizzArd~max people
13:12clojurebotmax people is 188
14:16ordnungswidrigtyping with my is still very hard...
14:17Chousuketyping with your?
14:17ordnungswidrigargh, my alphagrip i mean
14:17ordnungswidrigbgb
14:18ordnungswidrig...but fun!
14:22patrkrisA question I want to ask to ensure that I understand Clojure correctly: It doesn't make much sense to have a reference (be that a var, a ref or an agent) to an object from Java-world, since that object can mutate, and thus we cannot get a consistent "snapshot" of that object's state/value?
14:27chouserpatrkris: you're thinking about it correctly, but the answer may depend. For example if you can treat that java object as if it were immutable (copy on write, for example) it might be useful to keep in a reference object.
14:28chouserOr if the object is immutable despite coming from Java-world, like java.lang.String.
14:28patrkrischouser: yeah ok, I see your point
14:29chouserbut yes, if it's a big ol' regular Java application object with pile of getters and setters and no sane way to make copies ... Clojure can't do much to help you with the concurrency nightmare that will ensue.
14:29chousermaybe you can put it in an agent and promise not to use the mutators directly (even though nothing is actually stopping you) and *maybe* that'll be better than a lock.
14:34patrkrisyeah, it's not something I plan on trying :)
14:34chouser:-) good
14:36patrkrisIf i establish a root-binding for a var called A, and in an agent's action say (def A "someothervalue"), that will establish a new root binding, changing the value for all threads?
14:36chouseryes. don't do that either. :-)
14:36chouserusing 'def' anywhere other than the top level of a .clj file is at least a yellow flag if not red.
14:37patrkrisgood... just adding to my understanding :)
14:37chouser(loop [] ... (def x ...)) ; do not want!
14:37ordnungswidrigre
14:38chouserthe change is atomic via lock on the var, so you're never going to see a half-updated var, but that's as far as the safety goes.
14:38Chousukea slightly better way to redef vars is to use alter-var-root! I suppose
14:38chouseralter-var-root is slightly more idiomatic, but I'm not sure I've ever seen it used.
14:39ordnungswidrigwhat is the idiom for a changed variable x? x_ x+ x1 x_ ??
14:40The-KennyI remember there was a convention in haskell for this... I would use it in clojure too.
14:40ordnungswidrigThe-Kenny: i think in haskell it's x' but this is not allowed in clojure
14:41ordnungswidrigI've seen x, x+, x++ but I don't like it.
14:41The-Kennyordnungswidrig: Oh yes, that was the convention.
14:41djorkis cond not tail-recursive?
14:42Chousukewhat do you mean?
14:42The-KennyI would prefer x_ from the list you've mentioned.
14:42chouserdjork: use :else for the default condition
14:42djorkyes but I mean the cond macro itself seems like it may not use tail-call
14:42chouserThe-Kenny: what do you mean a changed variable? you can re-use the same name in a series of bindings in a let
14:42The-Kennydjork: As far as I know, there is no tail-recursion in the jvm.
14:43djorkyeah but there is in Clojure
14:43Chousukedjork: if cond itself is in the tail position, then all the branches are in tail position as well
14:43Chousukedjork: it just expands to a series of ifs
14:43djorkit doesn't seem to be
14:43patrkristhere isn't, and rhickey has been explicit about clojure not using tail-call optimization
14:43The-Kennychouser: I think you want to highlight ordnungswidrig ;)
14:43chouserdjork: each value of a cond form is a tail position iff the cond itself is in a tail position.
14:43chouserordnungswidrig: what The-Kenny said. ;-)
14:44djorkoh, so recur in the tail position is not tail call optimization?
14:44djorkI thought it was
14:44djorkit avoids blowing the stack
14:44djorkright?
14:44ordnungswidrighuh?
14:44chouserordnungswidrig: what do you mean a changed variable? you can re-use the same name in a series of bindings in a let
14:44Chousukedjork: TCO and recur are different things.
14:44patrkrisdjork: sorry, i probably misunderstood then
14:44chouserpatrkris: you're correct
14:44ordnungswidrigChousuke: really? that'd be both nice and weired
14:45chouserdjork: you're probably correct but you might be using the wrong words.
14:45Chousukedjork: but recur *is* a tail call. it's just to to an arbitrary function.
14:45twbraydjork: recur achieves the same effect as a recursive call to the function it's in when it's in tail position and TCO is applied.
14:45The-Kennyordnungswidrig: (let [a 42] (let [a (inc a)] a)) is valid, as far as I know
14:45The-Kenny(and it will return 43)
14:45ordnungswidrig,(let [a 1 a (inc a) a (inc a)] a)
14:45clojurebot3
14:45ordnungswidrigah.
14:46djorkrecur is manual tail call optimization
14:46chouser,(-> 1 inc inc)
14:46clojurebot3
14:46chouserdjork: yes
14:46djorkk
14:46Chousukean easy way to determine is some expression is in tail position: try replacing it with a suitable recur and see if you get an exception :P
14:46djorkyes :)
14:46djorkbut let me try to test my assumptions here...
14:46Chousukeit's easy
14:46chouserwell, manual tail self-call optimization
14:46Chousuke,(fn foo [] (foo))
14:46clojurebot#<sandbox$eval__3597$foo__3599 sandbox$eval__3597$foo__3599@8c3770>
14:47Chousuke,((fn foo [] (foo)))
14:47clojurebotjava.lang.StackOverflowError
14:47Chousuke,((fn foo [] (recur)))
14:47ordnungswidrigchouser: that makes me wonder why the compiler does not offer an option for it.
14:47clojurebotExecution Timed Out
14:47ordnungswidrigChousuke: for automatic tail self-call optimization. Or is it a runtime exception that'll occur?
14:47ordnungswidrigs/Chousuke/chouser/
14:47rhickeycemerick: no perf penalty on default IPersistentMap impl
14:48cemerickrhickey: OK, good to know.
14:48ordnungswidrigis flip in contrib?
14:48chouserordnungswidrig: the compiler could replace some self-calls with 'recur' automatically, but recur does not act the same as a self call (different stack impact) so it'd be up to the programmer to correctly understand the meaning the compiler would assign in each case.
14:49ordnungswidrigchouser: that's why clojure does no optimization? The provide clear semantics, right?
14:49cemerickrhickey: is this 'default implementation' injection something that will be opened up eventually. Magic markers like the IPM interface are handy, but...magical. :-)
14:49chouserordnungswidrig: rhickey has correctly determined this is undesirable. :-) 'recur' is clear, specific, and what it can and can't do is easy to understand.
14:50rhickeycemerick: how that will work is still TBD
14:50rhickeycemerick: would you rather defstruct2 that had map impl?
14:52rhickeywe also had chouser's keywords-as-triggers (def Foo [a b c] [:map IThis IThat] ...)
14:52cemerickrhickey: I would think that deftype + default IPM impl would simply replace defstruct *shrug*
14:52chousercemerick: excellent blog post.
14:53cemerickchouser: ah, thanks. I'm glad I didn't get anything obviously wrong.
14:53cemerickI tripped over the lazy-seq binding capture issue on Monday, after a solid 3 hrs of debugging, so I figured I'd really boil the fundamentals into my head through writing.
14:54Chousukerhickey: I suppose keywords would at least be more portable if the interface names ever change, like in port to a new platform or if they get refined or something
14:54Chousuke+a
14:54chouserit's interesting (to me anyway) to trace the potential problems to any combination of closure and dynamic binding
14:55cemerickrhickey: well, I don't really see :map there as anything like IThis or IThat. The latter just adds an interface, the former actually injects implementations. The two are totally separate beasts in my head.
14:55rhickeycemerick: presuming deftype won't have IPM as default (it won't, because making your types map when they are not otherwise collections is a big deal that will eventually bite you once you have more protocols in play), something that *did* have it by default might qualify for another name. I'd love to replace defstruct with defstruct on deftype but it has a few capabilities that don't work well
14:56rhickeyone problem is that anything like that will need 2 version (type and class)
14:56cemerickI think it's worth thinking about whether lazy-seq and friends should automatically capture the bindings of the current thread-local. I'm sure that's something that's been mulled over; I'm not sure I have an opinion at the moment.
14:56cemerickrhickey: well, there's always the option of simply eliminating defstruct.
14:57chouserlazy-seqs and high-order functions all use closures, and we think of closures in terms of their lexical scope, but once they're getting passed around their dynamic scope can be who-knows-what (other thread, outside the (binding ...), on a different terracotta server, etc.)
14:57rhickeycemerick: you will run interference on that? :)
14:57cemerickI suppose some people like the error-on-dissoc
14:58cemerickrhickey: are people really that attached to it, and its slowness and inflexibility? ;-)
14:58djorkI actually like recur over optimizing for tail calls, as it is more explicit and I think it makes for better reading.
14:58rhickeycemerick: I'm sure they will switch to deftype, but forcing them to is another story
14:59cemerickFWIW, if the magic behind IPM injection were more generalized, then we could have an IPersistentStruct (or whatever) that injected an impl that errors on dissoc'ing a core slot.
14:59rhickeycemerick: but people have been using defstruct without any type tags other than convention - once they have them they'll think twice about being IPM
14:59chouserdjork: yes, me too
14:59KjellskiHiho =)
14:59Chousukecemerick: but what if your lazy-seq-function does something like (defn make-lazy-seq [...] (let [foo (do-something-with *var*)] (when blah (lazy-seq (cons (operate-on foo) (make-lazy-seq ...)))?
14:59djorkI'm just trying to understand the source of cond
14:59djorkthe code
14:59technomancyI've started seeing errors like "java.lang.NoSuchMethodError: clojure.lang.RestFn: method <init>()V not found"; I may have screwed my build up (using git master). any idea what kind of problem would cause an exception like that?
14:59Chousukecemerick: if the var access were inside lazy-seq, something could be done, but...
14:59djorkI should be macroexpand'ing it
15:00rhickeycemerick: yes, certainly, and many other auto-implementors , just haven't generalized it yet
15:00cemericktechnomancy: you have to rebuild any sources built with older clojure versions...any classfiles are sorta hosed with HEAD.
15:00Raynestechnomancy: That's the exact error I receive in Slime when I use the experimental Clojure branch.
15:00technomancycemerick: ah... actually the stack trace looks like it's coming from loading contrib; didn't think to double-check that.
15:00technomancythanks.
15:00cemerickChousuke: Yeah, I have no suggestions about how to actually go about it.
15:01technomancyRaynes: you mean the maven branch of swank-clojure?
15:01Raynestechnomancy: Not sure. The swank-clojure that was installed by clojure-install about a week ago.
15:01cemerickrhickey: I think my only point is that, if there were such a generalization, then people could compose whatever set of impls and therefore semantics on top of deftype without having all these siloed def-* sitting around.
15:02rhickeycemerick: I'm not diasgreeing
15:02rhickeyhave you got a generalized mechanism?
15:02cemerickrhickey: I know, just clarifying my position, if only to myself. :-)
15:02technomancyRaynes: should work better on the maven branch; if you still run into problems could you report them on http://groups.google.com/group/swank-clojure ?
15:02RaynesSure thing. I'll note that. I have to leave right now, but I'll try that out later.
15:02rhickeycemerick: it's really quite complex, as any set of such auto-impls won;t necessarily compose
15:03rhickeyand the presumptions made might also conflict
15:03Chousukecemerick: though I think there is a ticket on assembla about providing a function wrapper that captures the dynamic environment and re-establishes it when the function gets called
15:03rhickeycemerick: so overall, I don't think injection should be emphasized
15:04cemerickrhickey: Yeah, I know. I presume we wade straight into the maw of trait-like issues. My talk about having a generalized mechanism is pretty much hand-waving, hoping you'll pull another rabbit out of your hat.
15:04drewrwhat's the safest way to do (read-string ":foo")?
15:04rhickeyand tempted by chouser's suggestion to leave it out
15:04djorkdrewr: what's wrong with the way you're doing it
15:04Chousukedrewr: bind *read-eval* to false first.
15:05cemerickChousuke: yeah, I saw that some time ago, but didn't really grok what was going on there at the time
15:05rhickeycemerick: for now, I'm standing pat until protocols are inplace
15:05cemerickSounds good to me. I'm in a happy place. :-)
15:06drewrChousuke: ah, I didn't see that arbitrary sexps had to be in #=()
15:06drewrwait no, that's not correct
15:06drewrthey're just not evaled after reading
15:06patrkrisis using release-pending-sends bad practice?
15:07Chousukedrewr: nothing is evaled by default when reading, except if you use the #= reader macro.
15:07Chousukedrewr: but setting *read-eval* to false disables that.
15:08ordnungswidrigstill didn't find a "flip"
15:08drewr,(binding [*read-eval* false] (read-string "(+ 1 1)"))
15:08Chousukeflip? as in, a function to reverse argument order?
15:08clojurebot(+ 1 1)
15:08drewr,(binding [*read-eval* true] (read-string "(+ 1 1)"))
15:08clojurebot(+ 1 1)
15:09Chousukedrewr: there's no difference in that case.
15:09drewr,(binding [*read-eval* true] (read-string "#=(+ 1 1)"))
15:09clojurebot2
15:09drewrthat's what I meant :-)
15:09ordnungswidrigChousuke: yes ((flip f) a b) is (f b a)
15:09Chousukeordnungswidrig: there's flip in contrib I think
15:10Chousuke,`flip
15:10clojurebotsandbox/flip
15:10Chousuke(doc flip)
15:10clojurebotIt's greek to me.
15:10Chousukehm, apparently not.
15:10KjellskiWhat is the best way to sum the values of a map?
15:10ordnungswidrigflip is from hiredman's odds-and-ends as it seems
15:10ordnungswidrighttp://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj
15:11hiredmanklafter (comp (partial reduce +) values)
15:11chouser#(f %2 %1)
15:12hiredmanflip works for than two args
15:12chouserdoes it reverse them?
15:12ordnungswidrighiredman: I need it just for two
15:12chouseror put the last one first?
15:12chouseror the first one last?
15:12hiredmanchouser: it reverse the order of all the args
15:12ordnungswidrigor swap to last and the first
15:12ordnungswidrigwhat would haskell do?
15:13hiredman(fn [fn] (fn [& args] (apply fn (reverse args))))
15:13hiredmaner
15:13hiredman(fn [fn-] (fn [& args] (apply fn- (reverse args))))
15:13hiredmanthe pointfree lib on github has a fn that just flips the first two args
15:13ChousukeKjellski: (apply + (vals themap)) :P
15:14hiredmanright
15:14hiredmanvals not values
15:14Chousukeyou take that pointfree thing too far sometimes.
15:14hiredman,((comp (partial reduce +) vals) {:a 1 :b 2})
15:14clojurebot3
15:14KjellskiChousuke : once again... sometimes it just hurts how easy things are... but, rewireing is on the go... thanks!
15:15ordnungswidrighiredman: what is then the "official" source for a decent flip? Your functional.clj?
15:15hiredmanordnungswidrig: I dunno that there is one, if you need one you might ask rhickey about adding one to core, when I asked he said he had never needed one, and I realized I never used it outside of golfing
15:16ordnungswidrighmm
15:17ordnungswidrighiredman: I have a function that takes to args and I want to partial it but I need to fix the second arg so (partial (flip f) a) would be a perfect fit. I realize that (fn [b] (f a b)) would work also.
15:18ordnungswidrighiredman: so you and rhickey might be right
15:18hiredmanwell no, I still want flip, I just am unable to argue with rhickey about it :P
15:19Kjellskidjork: Do you remember the bacteria thing? Maybe there is a much smarter way, but finally I´ve got it...
15:19ordnungswidrighiredman: but then partial could be dropped too. Dear develier: "usage of partial is considered golfing"
15:19djorkoh boy :)
15:19ordnungswidrigs/develier/developer/
15:19djorkKjellski: still having fun with Clojure though?
15:19djorkI have been doing Project Euler
15:19djorka few problems here and there
15:19djorkwill be firing up LWJGL soon
15:19djorkreal work gets in the way too often
15:19Kjellskidjork : for sure... I´ll use that as my general purpose in the master studies...
15:21djorkcoolness
15:21rhickeyordnungswidrig: Haskell would balk at variable arity
15:22Kjellskidjork: what is LWJGL ? And btw: http://pastebin.com/m351fa2d ...
15:22Kjellskidjork : If you´ve got time to review my code and tell me it´s just shit... ^^
15:22djorkLightweight Java Game Library
15:23Kjellskidjork : something in the direction of PyGame?
15:24ordnungswidrigmixing destructurizing binding forms and simple ones in a single let can be confusing. lots brackets and unusual indenting
15:26djorkKjellski: it's lower level than that
15:27djorkbut yeah kind of
15:27djorkin fact, I think it could be a great way to do multimedia apps
15:27djorkgames of course
15:27Kjellskidjork : okay, I would try it for fun if it´s showable...
15:28djorkit's someone else's project
15:28djorkbut a clojure wrapper might be in the pipeline from me
15:30KjellskiI´ve asked some time ago I think, but is someone arround that has a lazy-seq implementation of PI digits?
15:31Chousukehm.
15:32ChousukeThe idea of a very lazy seq just popped into my mind for some reason.
15:33Chousukebasically, it's so lazy that the computer refuses to do any works and the programmer has to add the items.
15:33ordnungswidrigwhy does slime-edit-definition doesn't work. Is it a known limitation of swank-clojure=
15:33Chousukework*
15:33ordnungswidrigs/=/?/
15:34djorkKjellski: destructuring will help your code a bit
15:34djorkfor instance, if you have a population count vector with the population by age in each slot of the vector...
15:34djork(defn day [[day-1 day-2 day-3 day-4]] [(+ day-1 day-2) day-1 day-2 day-3])
15:34djorkthat replaces your live-day
15:34djorkexcept it takes a vector
15:35Chousuke(defn day [{:keys day-1 day-2 day-3 day-4}] ...)
15:35Chousukemap destructuring!
15:36KjellskiChousuke : huh? What would that produce? a vec with a map that contains only keys?
15:37Chousukeno, it's the argument list of the function. :)
15:37chouser(import 'java.util.concurrent.TimeUnit)
15:37chouser,(import 'java.util.concurrent.TimeUnit)
15:37clojurebotjava.util.concurrent.TimeUnit
15:37twbrayHave a program that sends off a bunch of I/O intensive functions with send-off, they grind away and something reports a NPE with the helpful label (NO_SOURCE_FILE:0). What are some digging tools to find out what's blowing up?
15:37chouser,(let [deref-timeout (fn [p t u & [f]] (if (.await (.d ((proxy-mappings p) "invoke")) t u) @p f))] (deref-timeout (promise) 2 TimeUnit/SECONDS :not-delivered))
15:37Chousukeit takes a single map with the keys :day-1, :day-2 etc. and destructures them into the variables day-1, day-2 ...
15:37clojurebot:not-delivered
15:37Kjellskidjork : Thanks a lot, that never came in my mind...
15:38djorkthis is quite a quick solution compared to building the actual populations :)
15:39chousercemerick: I believe you've asked for that.
15:39Kjellskidjork : It´s not that I don´t have a solution for that, but this will blow your heap, until it´s pretty memory intense to build up a vec that contains 1,000,000,000,000 items...
15:40KjellskiChousuke : thanks for the explanation, I´ll try that version too.
15:40cemerickchouser: ah, the agent error handling stuff?
15:40chousercemerick: no sorry, the deref-timeout. That one only works on 'promise' before the 'new' branch.
15:40cemerickoh, oh, right
15:41chouserprobably 'await-promise' would be a better name
15:41djork,((fn [[first second]] (println first) (println second)) ["foo" "bar"])
15:41clojurebotfoo bar
15:41chouserand of course nobody should use it because it depends on several internal details of promise. :-P
15:41Chousukeyou could possibly build a lazy seq of the days. (defn foo [prev-day today] (lazy-seq (cons today (foo today (+ today prev-day)))
15:42cemerickchouser: timeouts aren't really a concern for me. My pet request would be an available? predicate for delays.
15:42chousertimeout of zero
15:42chouserhm, I think. I should check.
15:42Chousuke,(letfn [(foo [prev-day today] (lazy-seq (cons today (foo today (+ prev-day today)))))] (take 5 (foo 0 1)))
15:42clojurebot(1 1 2 3 5)
15:43cemerickSuper-easy to add, of course, just haven't gotten around to it.
15:43Chousuke,(letfn [(foo [prev-day today] (lazy-seq (cons today (foo today (+ prev-day today)))))] (take 2 (partition 5 1 (foo 0 1))))
15:43clojurebot((1 1 2 3 5) (1 2 3 5 8))
15:43cemerickchouser: the issue is, in certain cases, I don't want the delay to be realized at all.
15:44KjellskiChousuke : *reading*, *thinking*
15:44chouserohhh. yeah, that's different.
15:44hiredmanif you deref the delay in a future you can check to see if the future is done, I believe
15:45hiredmanhttp://java.sun.com/javase/6/docs/api/java/util/concurrent/Future.html#isDone%28%29
15:45Chousukethere was also a cleverer way to form the fibonacci sequence...
15:46hiredmana haskell way, if I recall
15:49Chousuke(let [fibos (concat [0 1] (map + fibos (drop 1 fibos))] (take 5 fibos)); something like this?
15:49Chousuke,(let [fibos (concat [0 1] (map + fibos (drop 1 fibos))] (take 5 fibos));let's see :P
15:49clojurebotUnmatched delimiter: ]
15:49Chousukegah.
15:49Chousuke,(let [fibos (concat [0 1] (map + fibos (drop 1 fibos)))] (take 5 fibos))
15:49clojurebotjava.lang.Exception: Unable to resolve symbol: fibos in this context
15:49Chousukemeh.
15:49hiredmanfibs = 0 : 1 : zipWith (+) fibs (tail fibs)
15:52djorkhmm
15:54chouser,(let [fibos (atom nil)] (reset! fibos (lazy-cat [0 1] (map + @fibos (rest @fibos)))) (take 10 @fibos))
15:54clojurebot(0 1 1 2 3 5 8 13 21 34)
15:55chouserThat's Chousuke's solution, poorly rendered to be clojurebot-compatible.
15:55Chousukeheh.
15:55djorkouch
15:55Chousukelazy-cat still amuses me.
15:56djorklazy-cat is lazy
15:56ChousukeI can't help but think of felines.
16:09djorkhttp://media.bigoo.ws/content/image/funny/funny_259.jpg
16:10djorkas an easter-egg in the graphical version of a repl, lazy-cat should be replaced with a tiny version of that image
16:15annealerif somebody would help me, that would be fabulous. im trying to programatically call a macro. the name is in a string, like "GET". i would like to somehow call that macro. i cant figure it out. eval complains it cant find it in the current namespace
16:16hiredman:(
16:16hiredmanwhy would you programatically call a macro?
16:17annealerthat's a good question
16:17annealerso
16:17djorkbecause you can't pass the value of a macro, I presume
16:17annealerthe web framework compojure defines some handy macros
16:17annealerlike GET, POST, PUT, DELETE
16:17chouser(defmacro foo [] "foo") (eval (read-string "(foo)")) ...works for me.
16:17hiredmanannealer: I'm pretty sure it defines them as macros for a reason
16:17annealeri am new to clojure, so i'm more than happy to be convinced this is the Wrong Thing
16:17chouseroh.
16:17chouserThis is the Wrong Thing.
16:18chouser:-)
16:18hiredmanmacros happen before runtime, and "programatically" calling stuff is certainlly a runtime thing
16:18annealerso this is bad mojo and i should not be doing it, essentially?
16:18hiredmanso calling macro's programatically is a red flag
16:18chouserannealer: well, tell us what you're trying to do
16:18arohnerannealer: you want to programmatically generate several routes?
16:18annealerarohner: precisely
16:18annealeri know i can do it with 'compile-route'
16:18annealeri was just wondering if using the macros was wrong or right
16:18chouserah... you want to write a macro yourself then.
16:18arohneryou can also specify your own regex
16:19chouser'eval' is definitely not right in this case.
16:19arohnerjust (GET #"/")
16:19annealerarohner: im doing rails-style resource routing, essentially. so i wanted a call to "resources" to actually use those macros. so i guess i should make a resources macro?
16:20annealeror just use the compile-route function the macro uses under the scenes?
16:20chouserboth those options sound more sensible than using 'eval'
16:20annealer(p.s. thanks for being the most helpful programming language irc channel i've stumbled into for a while)
16:20annealeraces
16:20Licenserhmm can someone help me what this: Exception in thread "main" java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.PersistentStructMap$Def means?
16:20annealeri'll go the non-hilariously-bad route then
16:20chouserannealer: :-)
16:21Licenserah found it
16:21arohnerin one case, I generated the regex
16:21arohneri.e.
16:21arohner(GET (my-regex-returning-fn) ...)
16:22arohner(defn my-regex-returning-fn [] (regex (str-join "|" "js" "swf" "css")))
16:22arohnererr (str-join "|" ["js "swf" "css"]))
16:26arohnerI can paste the whole thing if you're interested
16:27chouserarohner: is that not working because GET doesn't evaluate the route form?
16:27arohnerthat was pseudo-code
16:27arohnermy production one works
16:33ordnungswidrighow did the idion go to check for list containment using some?
16:34arohner,(doc some)
16:34clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
16:34ordnungswidrigthanks
16:35chouser,(some #{:a} [:a :b])
16:35clojurebot:a
16:35djorkhuh
16:37lpetit,(some #{nil} [:a :b])
16:37clojurebotnil
16:37lpetit,(some #{nil} [nil :a])
16:37clojurebotnil
16:39chouser,(some nil? [nil :a])
16:39clojurebottrue
16:39chouser,(some nil? [:a :b])
16:39clojurebotnil
16:40lpetit,(some #{false} [true true])
16:40clojurebotnil
16:40lpetit,(some #{false} [true false])
16:40clojurebotnil
16:41lpetitone better has to know what is placed in the set
16:41djorkwow seriously... NetBeans mpkg failed to install in OS X?
16:41chouseryes, collections that may contain false or nil have to be treated somewhat more carefully
16:43djorkhuh, I had to quit my repl
16:43chousercddr`: reader shortcut for (meta ...)
16:43cddr`chouser: thanks
16:44chouser,' ^foo
16:44clojurebot(clojure.core/meta foo)
17:01patrkriswhat is the easiest way to get a random element from a vector?
17:01Kjellski,(apply str (partition 1 3 "123456789"))
17:01clojurebot"clojure.lang.LazySeq@50clojure.lang.LazySeq@53clojure.lang.LazySeq@56"
17:01KjellskiSorry...
17:02hiredman,(apply pr-str (partition 1 3 "123456789"))
17:02clojurebot"(\\1) (\\4) (\\7)"
17:02hiredman,(apply str (map pr-str (partition 1 3 "123456789")))
17:02clojurebot"(\\1)(\\4)(\\7)"
17:02chouser,(clojure.contrib.seq-utils/rand-elt '(a b c d e))
17:02clojurebote
17:03hiredman(doc rend-elt)
17:03clojurebotHuh?
17:03chouser,(clojure.contrib.seq-utils/rand-elt '(a b c d e))
17:03clojurebote
17:03chouser,(clojure.contrib.seq-utils/rand-elt '(a b c d e))
17:03hiredman(doc rand-elt)
17:03clojurebotc
17:03clojurebot"clojure.contrib.seq-utils/rand-elt;[[s]]; Return a random element of this seq"
17:03hiredmanelement
17:03chouserseq
17:03hiredmanelt => element
17:03chouser,(clojure.contrib.seq-utils/rand-elt {1 2 3 4 5 6})
17:03clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
17:03patrkrist
17:03patrkristhanks
17:04Kjellskihiredman : how can I put the numbers itself into a str?
17:04Kjellskihiredman : without all the other stuff?
17:05hiredman,(map first (partition 1 3 "123456789"))
17:05clojurebot(\1 \4 \7)
17:05hiredman,(apply str (map first (partition 1 3 "123456789")))
17:05clojurebot"147"
17:05Kjellskihiredman : ty
17:05hiredmanI dunno if I would use partition for that
17:05hiredmanbut, I guess
17:06chouser,(apply str (take-nth 3 "123456789"))
17:06clojurebot"147"
17:09Kjellskichouser : is that more efficient? or just sugar?
17:10hiredmanshould be more efficient
17:11hiredmanpartion cuts the seq up into a seq of seqs, and then you have to map first over each seq
17:12chouserless code and less processing -- what's not to like? :-)
17:13Kjellskihiredman: perfect. So I´ll use that... is there a oneliner to "spit" a string into a file?
17:13chouserwhen we have fully hyperlinked api docs, there should definitely be cross references between take-nth and partition.
17:13KjellskiI mean with no "extra-using" or so?
17:14Kjellskichouser : /signed
17:14hiredman,(doc spit)
17:14clojurebot"clojure.contrib.duck-streams/spit;[[f content]]; Opposite of slurp. Opens f with writer, writes content, then closes f."
17:15Kjellskihiredman : I´m sometimes just banging my head against my table. But maybe, sometime in some future, my questions will take another stage...
17:17hiredmanit will take a use of duck-streams to use spit
17:17hiredman,(with-open [f (-> filename File. FileWriter.)] (.write f some-string))
17:17clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: FileWriter
17:19djorkKjellski: what are you trying to do there?
17:20djork(with the partition and string)
17:20Kjellskitaking every 20000th digit of the 1500000th fib number...
17:20Kjellski@ djork
17:20djorkhah wow
17:21hiredmanyeah, you want take-nth
17:21djorkis that a Project Euler problem?
17:21Kjellskidjork : nope, hacker.org ... for me that´s more fun because it´s not _only_ math...
17:21djorkyeah, interesting
17:22Kjellskidjork : trying be learn more in practical usage... ^^ and this problem was solved much more fast than the bac thing...
17:23Kjellskidjork : 1161269686625383 is the answer...
17:23djorkheh don't give it away :)
17:24Kjellskidjork: huh, sorry... just for prooving correct answers... if you don´t want to play the whole puzzles to that challenge...
17:24Kjellskidjork : on hacker.org not all challenges are accessible...
17:25djorkah
17:26djorkhttp://sixrevisions.com/resources/10-puzzle-websites-to-sharpen-your-programming-skills/
17:31KjellskiNice page, so far pretty good if someday my challenges are beaten on hacker.org... =)
17:33ordnungswidrigpushed my first project to github. ok, more the beginnings of a project :-) Please have a look at compojure-rest. I'd welcome feedback.
17:34Kjellskidjork: Uhh... now, bigger fib says: take the log of the 150,000,000th fib number and round to two digits...
17:34Kjellskiordnungswidrig : link?
17:35ordnungswidrighttp://github.com/ordnungswidrig/compojure-rest
17:36Kjellskithanks
17:37ordnungswidrigKjellski: that fib challenge sounds tough
17:39Kjellskiordnungswidrig: I don´t think so at all... doesn´t that calculation go linear? So just more computation before going to log that?
17:41djorkassuming you can take the log of a number that big in clojure
17:41KjellskiUh, got me?
17:41Kjellski*grin*
17:42ordnungswidrignope.
17:42djork,(Math/log (read-string "1293871924879182379182739817294879871948723948719283759814739487239487918274987912734"))
17:42clojurebot193.67478702654344
17:43ordnungswidrigbut the 150.000.000th fib will be a little longer ;-)
17:43ordnungswidrigI don't see how to chop the log on this one.
17:44Kjellskidjork : actually the other one was 20000 times the number of digits I posted as the answer... ^^
17:44djorkoh awesome :)
17:44ordnungswidrigKjellski: you actually feed the whole number to clojure?
17:44Kjellskiordnungswidrig : nope, I´m cheating here, using the great lazy-seq-fibo from stuarts book ...
17:45Kjellskiordnungswidrig : but just feeding it feels a lot more "cheating" for me...
17:45ordnungswidrigKjellski: which creates a lazy seq of ?
17:45Kjellskiordnungswidrig : the fibonaccy sequence...?
17:46djorkhmm this is kind of cool
17:46ordnungswidrigKjellski: but so you actually calculated the 150.000.000th fib?!
17:46djork,(BigInteger/probablePrime 128)
17:46clojurebotjava.lang.IllegalArgumentException: No matching method: probablePrime
17:46djorkhuh
17:46djorkoh
17:47djork,(BigInteger/probablePrime 128 (Random.))
17:47clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: Random
17:47djorkoh
17:47Kjellskiordnungswidrig : nope, I did that for the 1500,000th one...
17:48djork,(BigInteger/probablePrime 128 (java.util.Random.))
17:48clojurebot283136236335513942374424665513338827589
17:48ordnungswidrigKjellski: that sounds more reasonable
17:48djork,(BigInteger/probablePrime 128 (java.util.Random.))
17:48clojurebot247135970708632709525958798945080490857
17:48djorkverry interesting
17:49Kjellskidjork : what is that doing there?
17:49ordnungswidrigKjellski: there is a non-recursive expresion for the fibs one could use.
17:49djork,(.nextProbablePrime (bigint 1234))
17:49clojurebot1237
17:49djork,(.nextProbablePrime (bigint 1237))
17:49clojurebot1249
17:50djorkhmm, interesting implications there
17:50djorksaves me a lot of work :)
17:50Kjellskidjork : what does that "probable" mean for real?
17:50djorkdunno
17:50chouser"not divisible by 2"
17:50Kjellski*laughing*
17:50djork"The probability that the number returned by this method is composite does not exceed 2-100."
17:50djork2^-100
17:51djorkso pretty probable
17:51djorknot sure what method they are using
17:51djorkbut it would probably speed up creating lists of primes
17:51djorknow who said the Java class library sucks :)
17:51KjellskiThis is going to be a quote chouser ... can´t get over it...
17:54Kjellskichouser: http://bash.org/?907358 needs to be moderated...
17:55chouserwow. bash.org
17:55ordnungswidrigdjork: gnu classpath uses rabin-miller
17:59KjellskiSo, good night then... cya
18:03ordnungswidriggood night be me, too.
18:14esjguys, if I have sequence, and I want to 'modify' the last element, is it efficient/idiomatic to go: (conj (drop-last seq) new-element), or is there a better way ?
18:16hiredman:(
18:17hiredmanthats not something a seq will be good at
18:18esjyeah, that's kinda why I brought it up
18:20esjI'm trying to do a cumulative sum of a sequence, with the twist that I want each the summed sequence to add up to a threshold, and then roll to the next element. IE, if my threshold is 10, I want the elements of the returned sequence to be the cumulative sum since the last element, until that reaches 10, then I want a new element.
18:20esjUgh, that sounds ugly.
18:21esjits like, I'm packing boxes, and the first sequence contains elements with mass, and the second sequence is boxes, packed with those elements, such that no box weighs more than some threshold
18:22esjbut growing the 'box' sequence from the first sequence is proving painful.
18:42_atoesj: should the numbers be less than n or the first value that is over 10?
18:50_atoactually.. I guess it won't work if the output should be less than 10 and theres an input greater than 10
18:50_atoso lets assume the other way
18:52esjyeah, lets assume that for now
18:53esjits not super critical in the application, i'm more concerned about how I build this sequence sensibly
18:54esjat the moment I'm reducing along the first sequence, and either amending the last element of the 2nd sequence, or conjing to it, based on the total weight of the bax
18:54esjs/bax/box/
18:58_atohttp://gist.github.com/226530
18:58_atoI just did it with recursion and lazy-seq, I couldn't think of a nice way to do it with higher-level functions
18:59esj*reading*
19:01esjyeah, I get it
19:05esjso, here's an equally daft question, but why, if it is efficient to add to the end
19:05esjof a vector (for arguments sake) is removing and the adding to it not ?
19:06esjor, is it because we're dealing with general sequences that we don't want to make such assumptions ?
19:09Chousukesome kind of a "partial reduce" could be useful.
19:10_atoerr.. I don't get what you mean, it should be reasonably efficient, it's going to have to copy the whole last node though (clojure vectors are implemented as 32-way trees)
19:10_atobut you could get around that with transients
19:11_atoChousuke: yeah, something like reduce-while, that performs a test and returns [reduced-value remaining-seq] when the test fails
19:12bradfordwhen i eval exprs in a remore repl using contrib.server-socket, the text going to the output stream for the remore process can be valid exprs, or string repreentations fo java objects or exceptions. the latter can not be read with (read %). what is the best strategy for reading input from the strem from the remote repl?
19:12esjsadly everything I say is badly distorted by misunderstanding. What I mean is, my solution was to reduce the first sequence, and do the binding to the last element of the growing 'reduced' sequence with the (conj (drop-last seq) new), which was said to be bad ? Why so ?
19:14Chousukedrop-last of a sequence needs to walk the entire sequence.
19:14Chousukeso that it can find the end.
19:14Chousukeand drop it :P
19:15_atoso eg if your seq is really large, you might run out of memory
19:15_atobut with a vector it should be fine
19:15Chousukea vector is not a sequence though.
19:15Chousuke(doc drop-last)
19:15clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
19:15Chousukeah, hm, it's lazy. never mind :)
19:15_atoah true
19:15_atohehe
19:15Chousukebutlast is the slow function.
19:16Chousuke(doc butlast)
19:16clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
19:17Chousuke_ato: btw, instead of (if (nil? (seq s)) ...) I think it'd be more idiomatic to just use (if-not (seq s) ...)
19:18_atoChousuke: ah yeah true
19:18Chousukeand (cons n nil) is probably better as (list n)
19:18Chousukeor just [n]
19:19Chousukehmm
19:19Chousuke(cons 1 [2])
19:19Chousuke,(cons 1 [2])
19:19clojurebot(1 2)
19:19_ato,(next (cons 1 [2]))
19:19clojurebot(2)
19:19esjChousuke: yikes, that makes in n! complex, nastiness :)
19:20Chousuke(doc cons)
19:20clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
19:20esjso there is no way to kill the end of the sequence in O(1) ?
19:20Chousukewell, drop-last is lazy so you get the sequence in O(1)
19:21Chousukebut if you walk to the end it also needs to realise the n items you're dropping.
19:21Chousuke(otherwise it won't know the seq has ended)
19:22esjsorry, I misread you (its pretty late for me now)
19:23Chousukebut if you have a (drop-last 20000 some-source) where some-source has 40k items, and then only process the first 10000, it's going to realise only the first 30000
19:24Chousukethough in that case just processing (take 10000 some-source) would be more efficient.
19:24Chousukebut I guess sometimes you might not know how much you need to process, but still want to make sure some stuff at the end is excluded...
19:26_atoesj: I think with the way you're using it, it should be fine. The main difference between your way and mine (if I'm understanding yours correctly) is mine is lazy and yours is eager. Either might be better depending on what you want to do with the result
19:35esjok, here is what it looks like
19:35esjhttp://pastie.org/684209
19:36esji know i could avoid the '() by checking (empty? .)
19:39_atoI think the problem there is going to be (last product)
19:40_atothat's going to be O(length(product))
19:40Chousukeesj: http://gist.github.com/226553
19:40esj_ato: yeah, coz its going to have to walk the length of the growing sequence each time
19:41Chousukethat's probably not perfect though :P
19:42esjChousuke: that's really nice !
19:42esjI was led astray by insisting on using a reduce
19:43_atoChousuke: neat idea
19:43esjmuch to learn... thanks for the help.
19:44Chousukewell, the condensator is basically reduce (it reduces to reduce!) if the predicate is always true
19:44Chousukethough it also needs to check if coll actually has any items left.
19:46Chousukesleep for me.
19:46Chousukegood night. :)
19:46esjanother good idea. good night !
20:21notallamawould parcomp be a better name for juxt? i noticed that the docstring says "name subject to change".
21:36hiredmanhttp://gist.github.com/226651
21:36hiredmangar
21:36hiredmanhttp://gist.github.com/226651 <-- appegine + facebook app
22:48djorkman, I feel like this is cheating
22:48djork(take 10 (fn [] (iterate #(.nextProbablePrime %) (bigint 3))))
22:48djork,(take 10 ((fn [] (iterate #(.nextProbablePrime %) (bigint 3)))))
22:48clojurebot(3 5 7 11 13 17 19 23 29 31)
22:49djork,(nth ((fn [] (iterate #(.nextProbablePrime %) (bigint 1)))) 1000)
22:49clojurebot7919
22:49hiredman~cheating
22:49clojurebotI don't understand.
22:49hiredmanclojurebot: clojure?
22:49clojurebotclojure is the best way to learn java
22:49hiredmanclojurebot: clojure?
22:49clojurebotclojure is not scheme
22:49hiredman:|
22:49hiredmanclojurebot: clojure?
22:49clojurebotclojure is a language to use if you want to up your game
22:50hiredmanclojurebot: clojure?
22:50clojurebot"[Clojure ...] feels like a general-purpose language beamed back from the near future."
22:50hiredmansomewhere in there it says clojure is cheating
22:50djorkhah
22:51hiredmanclojurebot: clojure?
22:51clojurebotclojure > scheme
22:51djorkclojure?
22:51hiredmanclojurebot: clojure?
22:51djorkoh
22:51clojurebotclojure is like life: you make trade-offs
22:51djorkI trust you
22:51hiredmanclojurebot: clojure?
22:51clojurebotclojure > scheme
22:51hiredmanok
22:51hiredmanhmmm
22:57solussdis there an alternative to (get-in coll [...]) that returns nil instead of a null pointer exception if the index is out of range?
22:58solussdim mapping it to a bunch of indices
23:00chouserget-in doesn't throw NPE for me.
23:03solussdyoure right- i'm derefing a nil returned by get-in
23:03solussdthanks
23:04djorkwhat's the best way to get a Java null
23:04solussdis there a != in clojure?
23:04chousernil is null
23:04solussde.g. #(!= nill %)
23:05notallamanot=
23:05chouser,(not= nil 5)
23:05clojurebottrue
23:05chouser,(nil? nil)
23:05clojurebottrue
23:08chouser~deftype
23:08clojurebotdeftype is see datatype
23:09chouser~datatype
23:09clojurebotdatatype is see datatypes
23:09chouser~datatypes
23:09clojurebothttp://www.assembla.com/wiki/show/clojure/Datatypes
23:09chouserclojurebot: thanks! have a botsnack
23:09clojurebotthanks; that was delicious. (nom nom nom)
23:09fatelang~..
23:10gilbertleunghi
23:11gilbertleungi'm extending a class called "com.wowza.wms.module.ModuleBase" which has a protected static method called "getLogger"
23:11chousergilbertleung: was it you that asked on the google group?
23:12gilbertleungyah
23:12fatelangIs it possible to .. inside a doto or otherwise call a method of a returned object? Something like (doto f (.. .method-of-f (method-of-returned-object args)) ...)
23:13gilbertleungto summarize, my question is: how can I call the parent's static method from a child instance?
23:13chousergilbertleung: I'm not sure, but I think it may be impossible without writing some .java.
23:13chousergilbertleung: did you try using gen-class's exposes-methods?
23:14gilbertleungchouser: nope, i didn't know there was such a thing
23:14gilbertleungchouser: lemme read up on in the docs
23:14chousergilbertleung: well, it's worth a try, but I'm afraid it may only work on instance methods.
23:15hiredmanchouser: he could use wallhack!
23:15gilbertleunghiredman: what's that?
23:15chousergilbertleung: listen to hiredman
23:16chouserit's ugly but you've got to do what you've got to do.
23:16hiredmangilbertleung: lemme find some code
23:16gilbertleunghiredman: aite
23:16chouserfatelang: did you try that? seems like it might work.
23:17hiredmanhttp://gist.github.com/226726 wallhack-method
23:18hiredman(wallhack-method some.class.Name :someMethod [Types Method Takes] nil arg1 arg2)
23:18hiredmannil is for a static method, the object instance for a non-static method
23:22gilbertleunghiredman: could you clarify what would be passed into [Types Method Takes] ?
23:23fatelangchouser: What I tried and it error is at http://paste.lisp.org/+1XAR.
23:27arohnerare there built in function for doing map and filter on maps?
23:27arohneri.e. map/filter on the keys/values of a map?
23:27arohnerI feel like I'm missing something for writing my own
23:29tomojI wish we had those too
23:30arohnerok, I'm not crazy. I already have map-keys, map-values
23:30arohnerI'm writing filter-keys right now
23:30arohnerI'll write a patch
23:30tomojas it is you can (into {} (for [[k v] the-map] ...))
23:30arohneryeah, that's too verbose for me
23:30tomojI don't think you can do anything much faster than that, realy
23:31tomojunless the map function is the identity in most places
23:31arohnerI'm not looking for speed, just less typing and more readability
23:31tomojwhat does map-keys do when two keys in the original map get mapped to the same key in the result?
23:32arohnerwhat do you want it to do? :-)
23:32arohnerright now it does whatever (apply hash-map seq) does
23:34tomojwould be unpredictable if the original hash-map is unordered
23:34tomojguess if you're going to map keys to the same thing you deserve what you get
23:35arohneryeah
23:35arohnerdon't do that :-)
23:37gilbertleunghiredman: anyways, thanks alot; i'll play round with it soon when my hands are not tied
23:40arohnerhah: http://groups.google.com/group/clojure-dev/browse_thread/thread/4b20e40d83095c67#
23:40hiredmangilbertleung: it;s a vector of classes
23:40hiredmanif the method takes a string it would be [String]
23:42_ato,(clojure.contrib.generic.functor/fmap inc {:a 1, :b 2})
23:42clojurebot{:a 2, :b 3}
23:42gilbertleunghiredman: great. Thanks alot!
23:46_atoarohner: before writing your patch, check out: http://groups.google.com/group/clojure-dev/browse_thread/thread/4b20e40d83095c67#
23:47arohner_ato: yeah, I just linked to it
23:47arohnerI visited the dev group to post about writing my patch, and saw that
23:47_atoah oops, missed that :)
23:48arohnernot that it would really save me effort. I already have the fns written, because I need them now :-)
23:48_atoyeah, I meant more in the sense that there was some discussion going on about it