#clojure logs

2010-10-23

00:01amalloyi think someone's translated a fair amount of the little schemer into clojure
00:02amalloyhttp://stackoverflow.com/questions/2933051/clojure-for-a-lisp-illiterate looks like a relevant reference for you, too
00:04yousefah, yes that is one of the first links i found. the first book looks good but requires a bit of java experience from the preview text i saw
00:07pdkright now i dunno if there's really any teaching materials assuming no prior experience with either
00:08pdkif anything actual texts like ansi common lisp probably explain the unique lisp stuff better and you're gonna dip into the java standard library often enough to make knowing some classes there + how they all plug together and communicate important details
00:09yousefpdk: i see. well i will definitely go with amalloy's suggestion with learning scheme first.
00:10yousefanyhow thanks again
01:38vibrantmorning
01:39yayitsweivibrant: good morning
01:51notsonerdysunnycan somebody clarify the difference between send and send-off ..? I the documents weren't very helpfull..
01:53amalloynotsonerdysunny: they use different thread pools
01:54amalloyi don't use them much, but i seem to recall send is for operations that are "fast" (it uses a limited thread pool), and send-off is for possibly-blocking operations (it uses a new thread)
01:57notsonerdysunnyamalloy: every agent runs on its own thread and send runs the funciton on the same thread as the agent but send-off runs on a new thread ... Do I understand you?
01:58amalloyeach agent has at most one thread, but my understanding is that if you have more than one agent they share a limited number of threads between them
02:28defnhola
02:28amalloymorning
02:29amalloyhow's the conj?
02:29defnchouser: aloha
02:29defnawesome.
02:29defni think i may be the last person to go to bed
02:29amalloythe clock is a strong argument in favor of that possibility
02:29defn:D
02:30defnspent like 3 hours talking with chouser and cemerick on editor support and cinc
02:30amalloycinc?
02:30defnclojure in clojure
02:30amalloyexcellent. make it so
02:30cemerickdefn: I don't think chouser's actually been in here at all -- that's probably just his client at home keeping the log up to date :-)
02:31defn:
02:31amalloyyeah, he hasn't said a word all day
02:31defn:D
02:31defnalexyk is snoring like crazy
02:31amalloyhaha
02:31defnsomeone shoul talk to him about obstructive sleep apnea
02:31defnshould*
02:31amalloytoo bad you didn't get me to come. i sleep quiet and travel with earplugs :P
02:32defncemerick: really great talking to you tonight
02:32cemericklikewise :-)
02:32defnthis conference is pure unadulterated "win"
02:32amalloyoh snap, defn was wrong again. cemerick's still up
02:33cemerickI've got a talk tomorrow :-P
02:33defnyeah i was the last to leave the bar
02:33defnbut not irc, appareantly
02:33defnapparently*
02:33cemerickNo rest for those-that-don't-want-to-bomb
02:33amalloycemerick: up late, or up early?
02:33cemerickheh, late
02:33amalloygood. i don't need to call a mental hospital for you, then
02:33defncemerick: you'll do great. im sure of it.
02:33cemerickwe shall see
02:34cemerickI really want to do a live demo. I might try to beg a mifi thing off someone.
02:34defncemerick: if you need wifi have a tethering setp
02:34defn(first clojure-conj), PW: d34db33f01
02:35cemerickdude, you're gonna get such an overage now... ;-)
02:35defnim grandfathered into "unlimited"
02:36defnive been putting 10GB a month on it -- my bill is big enough they wont bother me :)
02:37defnamalloy: quick, get a plane ticket and come!
02:38amalloydefn: i'm actually there already, i'm just not telling anyone who i am. if you see a creepy-looking guy watching through a window, that'll be me
02:38defnanyway, i should probably retire for the evening...after i read more of chouser's finger tree source, then some of Zach's penumbra, then some CDT by gjahad
02:39defnive ot my work cut out for me for like..the next 10 years
02:39amalloyhey defn, can you explain finger trees? i glanced at the source but didn't really get the idea
02:39defnyou can add to the front and back of a sequence efficiently
02:40defnmake them countable in log n time
02:40defnsplit them and add to the middle similarly
02:40amalloyweird, log countable?
02:40defnit's a really cool functional datastructure
02:41defnbranches hold their count, and then as you walk back to the root they all add up to give the full count
02:41defnif that makes sense...
02:41amalloydefn: almost
02:42amalloyit implies you start a walk from somewhere other than the root, and i don't quite follow that
02:42defnyou still walk from the root, there are a few branches from root, i think the rule is <4
02:43defnleft and right are just off the root
02:43defnim too tired to attempt this but they're not very hard to grok
02:43amalloyhaha
02:43amalloyokay
02:43defnchouser's talk will explain all soon enough
02:43defn:D
02:44defnamalloy: ill draw you a diagram tomorrow during the conj :)
02:44defngnight all
02:44amalloyheh. just hold it up against the window for me
02:44amalloynight
02:48amalloycemerick: your talk is on IDEs, right? maybe CCW? i can't quite keep track of everyone's projects
02:48cemerickamalloy: no; Laurent's talk was on ccw, that's his baby
02:49cemerickI help a little :-)
02:49cemerickhttp://first.clojure-conj.org/speakers#emerick
02:49amalloyah! that's a more interesting topic for me
02:51amalloyi'm not super-interested in web apps, but they're much better for showing off
05:20_ulisesmorning
05:40lypanovdoes anyone want clojure on llvm or no one cares?
05:40esji know you do :)
05:40lypanovfor: 1, against: 8 rotated
05:54jszakmeisterlypanov: that would be interesting
05:54ChousukeYeah.
05:55jszakmeisterEspecially if you could integrate C++ libraries and such
05:58tufflaxWhy can't I do (map Integer/parseInt '("1" "2")) but I can do (Integer/parseInt "2")? Error: Unable to find static field: parseInt in class java.lang.Integer
05:58tufflax,(map Integer/parseInt '("1" "2"))
05:58clojurebotjava.lang.Exception: Unable to find static field: parseInt in class java.lang.Integer
06:02mrBliss(map #(Integer/parseInt %) '("1" "2"))
06:02mrBliss,(map #(Integer/parseInt %) '("1" "2"))
06:02clojurebot(1 2)
06:02tufflaxOk, but why doesn't it work? :P
06:02tufflax...the way I did it.
06:02mrBlissbecause it's a java method
06:03tufflaxuhu...
06:03mrBlissa clojure function is a first order function
06:03lypanovjszakmeister: yup. that would be the idea.
06:03lypanovokay 3 votes and a possible vote.
06:03lypanovesj: you?
06:04jszakmeisterlypanov: are you thinking of writing something?
06:04lypanovjszakmeister: yeah. lost my job and don't want to get another straight away
06:04lypanov(first time i get to choose that, so taking the option)
06:04lypanovso i have 1 month to spend on it
06:05lypanovdoubt i'll even succeed. i have zero experience with clojure other than knowing its great.
06:05lypanovand zero experience with llm.
06:05lypanov(see, i can't even spell it)
06:05jszakmeisterlypanov: sorry to hear about the job loss... tough times. glad you can take some time off though
06:05jszakmeisterGotta start somewhere, right?
06:05esjlypanov: i'm not qualified to comment really. It would be interesting, but I think the jvm is going to continue to be just fine. (or maybe i'm just a turkey ignorant of thanksgiving ?)
06:05lypanovi started a ruby rewrite a few years back (in ruby) using my own tinyjit.
06:06lypanovso have enough experience with the theory
06:06lypanov(tinyjit was a threaded interpreter)
06:06lypanov(maybe i should have called it something other than tinyjit)
06:06esjlypanov: impressive
06:07jszakmeisterlypanov: neat. I've always wanted to do compiler work, but I don't have the formal base (I'm not a CS major)
06:07lypanovit was incomplete crashy and shit.
06:07lypanovi blew up my brain in the process.
06:07jszakmeister:-)
06:07lypanovbut it was fast at adding numbers!
06:07esjlol\
06:07lypanovjszakmeister: i am but from a crap uni so i don't count it anyway. but yay letters.
06:08lypanovi have more experience from life than i got in all the years at uni.
06:08lypanovanyway, bootstrapping sounds like fun.
06:09lypanovthx guys. this project gets 3 more points.
06:09lypanovthe others are all still on zero.
06:09lypanovits competing with: finishing an existing cocoa/clojure binding.
06:09lypanov: rewriting basic vim subset in clojure and a few plugins also
06:09lypanov: <insane project i'll never do>
07:02kryftRegarding some code on page 153 (p 149 in the pdf) of Joy of Clojure: (defn xseq [t] (when t (concat (xseq (:L t)) [(:val t)] (xseq (:R t)))))
07:03kryftShouldn't you use recur or something here?
07:03Chousukeyou can't.
07:04Chousukerecur only works for tail recursion
07:04kryftOh right, it's not in tail position.
07:04ChousukeI think using lazy-cat might be better there though.
07:06kryftChousuke: Now that I think about it, I guess this kind of recursion wouldn't generally be a problem anyway, as the depth will only be around log N
07:08kryftChousuke: Ie. even if you could do some fancy optimization, it would be unnecessary.
07:10kryftWell, that was an unusually useful stupid question.
07:11kryftI should make an effort to flaunt my ignorance in all areas of life. :)
07:16sempahhello, what is the meaning for *var*
07:16sempahI know I read it before, but i dont get it
07:17sempahsomething like a global var?
07:19jarpiainsempah: it's a naming convention for vars that are intended to be dynamically bound with (binding ...)
07:20sempahok thanks
07:20sempahsaw it any book before, but couldnt remember
07:46sempahwill be a var defined with "let" only be executed if it is used in a later context?
07:47sempahif I assign: let ... result (...) the whole function will be executed very fast
07:47sempahif I add a print result at the end it is very slow
07:47sempahis this called lazy? :)
07:54Chousukethe let binding is always executed
07:54Chousukebut it might be bound to a lazy seq
07:54_uliseschouser: even if you do let [ x (map f coll)] ?
07:54Chousukeyes
07:54Chousukethe lazy seq is created
07:54_ulisesI mean, the realisation of map won't be until you actually use x, right?
07:54_ulisesright, that
07:54Chousukeright.
07:55sempahohh this isnt good for me ;)
07:55Chousukethey're safe, just be mindful of dynamic binding
07:55sempahwanted to compare some functions
07:55Chousukeadd a doall?
07:56sempahwondering the giant difference ^^
07:56Chousuketo force the seq
07:56sempahdoall? -.-
07:56_ulisesor dorun
07:56Chousukeit forces the whole seq instantly
07:56sempah,doc doall
07:56clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/doc
07:56_ulises,(doc dorun)
07:56clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
07:56_ulises,(doc doall)
07:56clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
07:56sempahahh the missing parantheses :P
07:57_ulisesif you're dealing with large data dorun might be better
07:57_ulisesas it doesn't keep a ref. to the head, etc.
07:57sempahlarge is realtive :)
07:57_ulisesindeed
07:57sempahbut i will try both functions
07:57sempahthx for the advise
08:01_ulisessure, np.
08:02_ulisesI'm shocked my comments were actually useful :D
08:06_ulisesis there any way I can bypass the fetching of the DTD from w3 when using 'parse' to parse XML?
08:06_ulisesalternatively, are there other/better options to clojure.xml?
08:28kryftChousuke: "Be mindful of dynamic binding" sounds very profound.
09:00sempahwhat is a proper way to compile a clojure file? (without tools like leinigen)
09:01esjsempah: (compile ...)
09:02hiredmanI am prepared to be provoked
09:03esjbut just google about for AOT and you'll see all the ins and outs
09:05sempah-.-
09:30sempah,(println "ä")
09:30clojurebot
09:31sempahis there a change to work with german umlauts?
09:31sempahchance*
09:32Chousukethat should work just fine
09:32mike5160hi all.
09:32Chousukecheck your encoding.
09:32sempah<sempah> ,(println "ä")
09:32sempah<clojurebot> �
09:32Chousuke,(println "ä")
09:32clojurebotä
09:33sempahstrange
09:33Chousukeyou're using ISO Latin-something I guess
09:33ChousukeIt's 2010, use UTF-8 :P
09:34sempahI use the default one
09:34sempahso why isnt it utf8 :)
09:34Chousukeno idea.
09:34Chousukecrappy client? :P
09:34mike5160i m trying to use the vijual-1.0.0-dd-mm...jar file in the command line repl. I do (use '(vijual)) and then as per github vijual instructions i do a (require 'vijual :reload) but when i try to use any function from the library it just says... Unable to resolve symbol... draw-tree any ideas?
09:35mike5160do i need to use the (load 'vijual ) function?
09:36sempahhmm eclipse encoding says utf8
09:36Chousukehmh
09:42kryft,(println "ä")
09:42clojurebot
09:42kryftOh right, I have recode on.
09:42ChousukeI still have it on, but only for incoming stuff.
09:42Chousukeoutwards I send UTF-8
09:43Chousukeif someone complains, well, screw them :P
10:00mike5160allright i will try again later. i want to get this vijual library to work.
10:00mike5160later
10:26TheAnimalwhere do I put files for my namespaces so it will be reachable in repl with require macro?
10:28esjTheAnimal: if maven: ./src/main/clojure/my/namespace
10:29esjif you file is say my.namespace.cleverstuff
10:29esjand pom.xml is in .
10:29TheAnimalnot using maven
10:29TheAnimalI use clojurebox
10:29TheAnimalnow I've made a file irc.clj
10:30TheAnimalit has ns spur.irc
10:30TheAnimalhow do I reach it from repl
10:30TheAnimalaside from changing my ns to spur.irc
10:31esjprobably put the file in ./src
10:31esjsorry, put into ./src/spur
10:32esjthen (require 'spur.irc)
10:32esj(never used clojurebox, but guestimating)
10:33TheAnimalthe only problem then...is that I don't know that . is
10:33TheAnimalthat is, I don't know where's the base folder
10:34TheAnimalI can load and compile files from anywhere on the drive
10:35esjOK, then I have no idea :)
10:35esj. is usually where the project project.clj or pom.xml lives
10:36esji dunno how clojurebox constructs its classpath
10:50tonylmorning
11:04defngut morning
11:05tonyli guess everybody is at the conj
11:10TheAnimalyou know what's sucks? unlike in java, the order the functions are defined in a file matters
11:10sempahhow can I cast a int to char or rather print a special ascii char?
11:10TheAnimalfeels like C all over again
11:10sempahsomething like 216.toChar
11:11sempah,(print (char 215))
11:11clojurebot×
11:26TheAnimal,(print (char 3))
11:30mrBlissTheAnimal: you can declare functions before you define them: (declare the-fn)
11:32TheAnimali know
11:32TheAnimalthat's C-like
11:35fliebelHey, how are things at Clojure Conj? Wish I was there...
11:40raeksempah: casting an int to a char means gettin the char with that code point number. be aware of that bytes and chars aren't the same thing, and there are more than oneschemes of translating between the two (that is what encodings are about)
11:41raek*more than one scheme
11:41technomancyfliebel: pretty sweet actually
11:44TheAnimalis there a version of cond
11:45TheAnimalthat would save the result of the predicate into a variable to be used in the expression that follows
11:45fliebelTheAnimal: You mean something like cond-let? (made up the name)
11:46TheAnimalyeah
11:46TheAnimalfor instance
11:46TheAnimalI have a funcation fun1 that returs a map or nil
11:46TheAnimalI would like to have
11:46TheAnimal(cond (fun1 x y) (fun2 :pred y z))
11:47TheAnimalwhere :pred is the result of (fun1 x y)
11:47raekTheAnimal: condp has a special :>> feature, which does something like that
11:47TheAnimalnot exactly
11:47TheAnimalit uses a predicate with arity of 2
11:50fliebelAfter seeing the slides from cgrand about the macro stuff, I am doubting about a macro I'm making. The macro takes a string of an expression in another language and returns the Clojure code for that. Is this a good use of macro, or should I go for an fn with eval?
11:52raeksounds like a legitimate use case of macros to me...
11:52fliebelgood :) I think so to, but just to be sure....
11:54fliebelI'm currently just regexing them into shape, but is there a way to ns-quallify the symbols for good style? Like ` would do. but without `
11:54TheAnimalisn't that kind of macro insanely complex?
11:54TheAnimalyou can't regex computer languages
11:54iveyDoes the repl have a symbol for "return value from last form evaluated"?
11:54fliebelTheAnimal: Nah, I'm merely converting prefix to infix and CamelCase to dashes.
11:54fliebelivey: *1
11:55iveythanks
11:55raekreminds me of incanter's infix macro...
11:55fliebelTheAnimal: You can, if you don't really parse them, but only convert styles.
12:30yayitsweigood morning!
12:34sempahgood evening ;)
12:53kumarshantanucan anybody tell me how is binary data represented in Clojure? sequence of Byte?
13:26pauldoohi
13:26Scriptorhey pauldoo
13:26pauldooI have a clojure multimethod, where the dispatch function is outputting two values
13:27pauldooin my defmethods.. can I do partial matching? e.g. (defmethod foobar [_ 6] [a b] ...)
13:27pauldooto match any cases where the 2nd output of the dispatch function is 6, regardless of the first output
13:31pauldooI've tried [_ 6] syntax, and also [:default 6], but neither of these work.. is there another way?
13:53_na_ka_na_hello all, is there a way to create a sorted-set which takes a comparable ?
13:54_na_ka_na_oh i mean comparator
13:54_na_ka_na_,(doc sorted-set-by)
13:54clojurebot"([comparator & keys]); Returns a new sorted set with supplied keys, using the supplied comparator."
13:55Upper, (doc rest)
13:55clojurebot"([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."
14:02AnotherLomono1toot
14:05jewelis there a built-in data-structure that supports BST operations with order-statistics?
14:12amalloyjewel: order-statistics?
14:26KirinDaveSo quiet around here with the conj draining everyone.
14:28amalloyKirinDave: just look at twitter and pretend they're all on #clojure
14:28kumarshantanuKirinDave: maybe clojurebot can be hooked up with #clojureconj tweetes to kill the quiet here :-)
14:28KirinDaveHa
14:28KirinDaveI am jealous.
14:28KirinDaveSo very jealous.
14:28KirinDaveBut I am going to do some more work on clothesline.
14:28KirinDaveI am going to public-ize it with some known issues, I want to get it out this weekend while the clojure-web-hype is high.
14:28KirinDaveI wish I could have seen cgrand's dsl != macro talk so I know wtf it means
14:29kumarshantanuconj is turning out to be better than expected from the tweets i read
14:55LauJensenKirinDave: He's presented the code from a lab we did in Brussels, you can get a ticket for Conj Labs London if you want to see it again :)
14:56LauJensens/presented/presenting/
14:56sexpbot<LauJensen> KirinDave: He's presenting the code from a lab we did in Brussels, you can get a ticket for Conj Labs London if you want to see it again :)
15:15KirinDaveLauJensen: Yeah, London. easy. ;)
15:16amalloyLauJensen: you sure it's not presented? they're in a different time zone, which is almost like time travel
15:16LauJensenThe talk has already been done AFAIK, if thats what you mean
15:17cpoconnoAny folk here have enclojure running on netbeans 6.9.1?
15:17cpoconnoOr netbeans period?
15:19TheAnimalI'm having a weird problems invoking methods
15:20TheAnimalfor instance I have a fn that returns another fn, in my case identity
15:20TheAnimalthen I invoke returned fn like this
15:20TheAnimal((get-handler-fn) "AA")
15:20TheAnimalget-handler-fn returns identity fn
15:21TheAnimalI get nil
15:21TheAnimalinstead of "AA"
15:21DeranderHow do you folks handle java docs in emacs?
15:22TheAnimal(identity "ff")
15:22TheAnimal"ff"
15:22TheAnimal(:handler-proc (first input-handlers))
15:22TheAnimalidentity
15:22TheAnimal((:handler-proc (first input-handlers)) "ff")
15:22TheAnimalnil
15:22TheAnimalwhat the hell is this?
15:23TheAnimalbug in the compiler?
15:24hoeck,('identity "ff")
15:24clojurebotnil
15:24hoeckTheAnimal: looks like you got a symbol back from input-handlers
15:24TheAnimalwhy did you quote identity?
15:24hoeckand not the function identity
15:24qbg,identity
15:24hoeck,identity
15:24clojurebot#<core$identity clojure.core$identity@18eb7b8>
15:24clojurebot#<core$identity clojure.core$identity@18eb7b8>
15:24TheAnimalwtd
15:24TheAnimalwtf
15:24qbgThat is how the function would print
15:24TheAnimalhow did that happen
15:24TheAnimalI see
15:25TheAnimalI don't understand the difference
15:25amalloy,[identity 'identity]
15:25clojurebot[#<core$identity clojure.core$identity@18eb7b8> identity]
15:25TheAnimalI can see that
15:25TheAnimalbut I can't see why it returns symbol
15:25TheAnimal(def input-handlers '({:handler-proc identity :listeners #{}}))
15:26qbgYou are quoting the entire thing, so nothing is being evaluated in it
15:26hiredmanfyi, clojurebot is currently running from the the significantly changed newworld branch of clojurebot
15:26TheAnimaloh
15:26qbg(def input-handlers [{:handler-proc identity :listeners #{}}])
15:26qbgThat would be what you want
15:26hiredmanwhich baring problems will become the master
15:26amalloyTheAnimal: if you want a list whose subelements are evaluated, either use [vectors] or (list stuff)
15:27LauJensenhiredman: anything in particular we need to be mindful of ?
15:27TheAnimalok works now
15:27TheAnimalthanks
15:27TheAnimalI need to learn how to make my clojure code more readable
15:28TheAnimalit's only 77 lines and already I'm getting lost
15:28amalloyTheAnimal: well, some of that is being familiar with the language. but if you make a gist or a paste i'm sure someone can give you tips
15:28TheAnimalgotta come up with some sort of naming convention
15:29TheAnimalright now functions, variables and datastructures all seems the same
15:32romain_pHi everyone, some beginner help?
15:33romain_puser=> (split-with consonant "This was nice")
15:33qbgromain_p: Go ahead
15:33romain_p[(\T \h) (\i \s \space \w \a \s \space \n \i \c \e)]
15:34romain_pI'd like to make the second element of the returned sequence into a string, ie get "is was nice"
15:34qbgOnly the second?
15:34KirinDaveromain_p: Apply str.
15:34romain_p(and then catenate the first one after the second one)
15:34KirinDave,(apply str '(\a \b \c))
15:34clojurebot"abc"
15:34romain_pKirinDave: OK, I was missing the apply
15:34KirinDave:)
15:34KirinDaveA common question
15:34romain_pthx
15:35qbg,(apply str (apply concat (reverse (split-with consonant "This was nice"))))
15:35clojurebotjava.lang.Exception: Unable to resolve symbol: consonant in this context
15:36qbg,(apply str (apply concat (reverse [(\T \h) (\i \s \space \w \a \s \space \n \i \c \e)])))
15:36clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn
15:36qbg,(apply str (apply concat (reverse '[(\T \h) (\i \s \space \w \a \s \space \n \i \c \e)])))
15:36clojurebot"is was niceTh"
15:37romain_pqbg: thanks
15:38_ulisesis there any way to tell parse to not try and download the DTD from w3c?
15:38_ulises.e.g use a locally cached version or simply ignore it
15:39_ulisesI'm referring to clojure.xml/parse by the way :)
15:40hiredmanyes, you can google it, I did the other week and it's fairly easy to find
15:45_uliseshrm, I did some googling but I could only find a solution where it involved using lots of java
15:45_ulisesthanks anyway :)
15:51hiredmanupshot of the new clojurebot version, if something causes an exception in it's internal processing the exception will show up on irc, which is kind of neat
15:58Upper, (apply str (reverse "adaven nevada"))
15:58clojurebot"adaven nevada"
16:09DeranderUpper: looks like reverse is broken
16:09Derander...
16:09amalloy,(vals [1 2])
16:09clojurebotjava.lang.Integer cannot be cast to java.util.Map$Entry
16:09Upperlooks like
16:10amalloyhiredman: nice. that caused an "i don't understand before", i think
16:11amalloys/ before"/" before/
16:11sexpbot<amalloy> hiredman: nice. that caused an "i don't understand" before, i think
16:25TheAnimal4sup
16:28TheAnimall
16:29Upper, (->> (iterate inc 0) (map #(* % %)) (str inc " ") (take 20))
16:29clojurebotExecution Timed Out
16:31Upperi'd like to show inc value in each iterate
16:31amalloythat's weird. i don't see what should be making that time out
16:32amalloyUpper: take a look at juxt. you can use that to sorta apply two different functions to the same argument
16:32amalloy,((juxt identity #(* % %)) 6)
16:32clojurebot[6 36]
16:33Upperhmm alright.
16:38hiredmanamalloy: making a str out of an infinite seq
16:38amalloyhiredman: oh, of course. thanks
16:39KirinDaveI have a defrecord defined in clothesline.protocol.test-helpers, named TestResult
16:40KirinDaveBut when we try and access it from scala
16:40hiredmanclothesline.protocol.test_helpers.TestResult?
16:40clojurebotTitim gan éirí ort.
16:40KirinDavehiredman: scala> import clothesline.protocol.test_helpers.TestResult
16:40KirinDave<console>:5: error: value test_helpers is not a member of package clothesline.protocol
16:40KirinDave import clothesline.protocol.test_helpers.TestResult
16:40amalloyraek: you can see my latest juxt ninjitsu in my patch for sexpbot: http://tinyurl.com/23fgwps
16:42raeknice.
16:43amalloybtw, do you think the use of reduce there is idiomatic? it feels kinda like trickery and i ought to be using a plain (loop)
16:44hiredmanKirinDave: check the generated class files
16:45KirinDaveI dunno why I never use juxt. :\
16:47amalloyKirinDave: maybe raek and i will send some juxt missionaries at you
16:47KirinDaveLol.
16:47LauJensenamalloy: wasnt that the code somebody blogged about recently, in relation to a talk in here?
16:47LauJensenseems oddly familiar
16:47amalloyLauJensen: it's possible, but i don't follow any blogs
16:48LauJensennot even.... MINE?! :)
16:48amalloyand that *specific* code i wrote at 1:30 this morning, so it probably hasn't made the blogrolls yet :P
16:50KirinDaveamalloy: Given the culture, it seems like any reduce use is gleefully embraced.
17:03amalloyanyone know when/where the presentations will be available?
18:43_na_ka_na_hello, can someone tell me why the following behave as they do:
18:43_na_ka_na_,(= (sorted-set :a) (set [:a]))
18:43clojurebottrue
18:44_na_ka_na_,(= (sorted-set-by (constantly 1) :a) (set [:a]))
18:44clojurebotfalse
18:58_na_ka_na_, (= (set [:a]) (sorted-set-by (constantly 1) :a))
18:58clojurebottrue
18:58_na_ka_na_even wierder!
19:05arbschtfor anyone interested, the seven-day Lisp Game Dev Competition for October 2010 has just begun. you can submit your entry at any time until 31 Oct: http://lispgames.ath.cx/index.php/2010_October_Lisp_Game_Dev_Competition
19:14amalloy_na_ka_na_: a sorted-set uses its comparator to look up items
19:14amalloysince (constantly 1) says every element is greater than every other element, you can't be too surprised that it can't find the items you ask it to look for
19:15amalloy,(let [s #{:a}, ss (sorted-set-by (constantly 1) :a)] [(some ss s) (some s ss)])
19:16amalloyclojurebot: ping?
19:16amalloy->(let [s #{:a}, ss (sorted-set-by (constantly 1) :a)] [(some ss s) (some s ss)])
19:16sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/sorted-set-by)
19:20clojurebot[nil :a]
19:20clojurebotPONG!
19:20_na_ka_na_amalloy: thanks for the explanation, got it!
19:22_na_ka_na_amalloy: i wrongly assumed = with collections just chks something like (= (set (seq %1)) (set (seq %2)))
19:22_na_ka_na_is there some function like that?
19:23amalloy_na_ka_na_: that wouldn't really work in general because of lazy seqs. if it worked that way, this would be impossible:
19:23amalloy,(= (range) [1])
19:23clojurebotfalse
19:24amalloy(because (set (range)) would never complete)
19:26_na_ka_na_amalloy: you would check equality of counts first?
19:27amalloy,(count (range))
19:27clojurebotExecution Timed Out
19:27_na_ka_na_and for lazy seqs you'll do one by one
19:27amalloyhow do you know what seqs are lazy?
19:29_na_ka_na_i think it must have some way of knowing that as following works:
19:29_na_ka_na_, (= (range) (map inc (range)))
19:29clojurebotfalse
19:30opqdonutthe = just compares element by element
19:30opqdonutand map is lazy
19:30amalloyyep
19:31_na_ka_na_hmm ya it makes sense
19:31amalloy,(= (sorted-set-by < 1 2) (sorted-set-by > 1 2))
19:31clojurebottrue
19:33_na_ka_na_but i think its un-intuitive that (= x y) != (= y x)
19:33opqdonutyou've violated the contract of sorted-set-by
19:33amalloythat's only the case because you're abusing sets by giving them a comparator that doesn't satisfy the comparator contract
19:34_na_ka_na_hmm .. what's the contract of sorted-set-by ?
19:34_na_ka_na_, (doc sorted-set-by)
19:34clojurebot"([comparator & keys]); Returns a new sorted set with supplied keys, using the supplied comparator."
19:34amalloyhttp://download.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html
19:34_na_ka_na_is there any documentation i can refer to?
19:36_na_ka_na_thanks! I'll read up to understand, I think we should have some reference to Comparator contract for non Java people
19:37amalloyit couldn't hurt, i agree, but it seems kinda unsurprising that (compare a b) should never have the same sign as (compare b a)
19:47amalloydo we have a convenient function to conj/cons an item to a list unless the item is nil?
19:52amalloyin my current use case it's no problem to filter out the nils later, but that feels silly
20:04Deranderamalloy: I'm actually wondering the same thing
20:14_na_ka_na_is there any way in which I can avoid getting 'has joined
20:14_na_ka_na_ and 'has quit' messages?
20:15_na_ka_na_I'm using XChat
20:22amalloy_na_ka_na_: http://tinyurl.com/38cofyq :)
20:24_na_ka_na_amalloy: :)
20:24_na_ka_na_i tried going through settings then gave up
20:26Upper_na_ka_na_: I though you got sad
20:27_na_ka_na_Upper: actually I did! how did you figure?!
20:28Upperyou're gone
20:29_na_ka_na_Upper: naa I needed to re-join in order for the command (to disable join/leave msgs) to take effect
20:31_na_ka_na_I was using webchat.freenode earlier but couldn't figure a way to disable join/leave msgs in that, so I downloaded XChat and couldn't find a way in this either
20:40_na_ka_na_alright time for bed
21:20rdeshpandehi all
21:21rdeshpandei'm a vim user, but am learning clojure and happy to learn a new tool if it is the best tool for writing clojure. will vimclojure suit me, or should i try an IDE/emacs?
21:21rdeshpande(i've seen a handful of posts about this but most are quite dated, so wanted to get a more up to date opinion)
21:21iveyI've got some XML I'm getting from Google Reader with clj-http.client, but xml/parse is choking: "Invalid byte 2 of 2-byte UTF-8 sequence."
21:23iveynevermind, I just needed to tell getBytes to use UTF8
21:24iveyrdeshpande: I haven't used any of the vim tools for clojure, but I can't imagine using it without Emacs. Purely personal opinion.
21:25mister_roboto__rdeshpande: i'm a vi user for many many years too and never learned emacs. however, i have used clojure for a little while now in eclipse and the counterclockwise plugin there works well
21:26mister_roboto__rdeshpande: i tried eclipse just becuase i've also used that for java for a long time and it's second nature. didn't want to fight too many battles at the same time (learning clojure and emacs)
21:44rdeshpandeah, makes sense
21:46mister_roboto__rdeshpande: does vimclojure have some kind of integration wtih a repl? i haven't tried it
21:49amalloyrdeshpande: i'm a longtime eclipse user, but i tried CCW when it was still in its infancy; at the time it wasn't very good, and tbh i'm very happy with emacs (having no prior loyalties to vi/emacs). but CCW is supposed to have improved since then
21:51amalloythat said, i know there are vim users who are happy with vimclojure
21:51rdeshpandemister_roboto__: apparently there is nailgun and lein-nailgun which should give some integration
21:51rdeshpandemister_roboto__: but i have yet to get it to work (still thrashing around as a newbie) :P
21:53jackdempseyi'm using vimclojure. mostly happy, except it seems to be slow, perhaps more so the longer i use it
21:53jackdempseyi noticed lag before when typing ( or )
22:02pjb3,(defn foo [] "foo")
22:02clojurebotDENIED
22:03pjb3If you did define a function like that
22:03pjb3you can call it with (foo)
22:03pjb3but (#'foo) also works
22:03pjb3why?
22:03clojurebothttp://clojure.org/rationale
22:06amalloy,(class #'inc)
22:06clojurebotclojure.lang.Var
22:06amalloy,(supers (class inc))
22:06clojurebot#{clojure.lang.AFunction clojure.lang.IMeta clojure.lang.IObj clojure.lang.IFn java.util.Comparator java.io.Serializable clojure.lang.Fn java.lang.Object java.util.concurrent.Callable clojure.lang.AF...
22:06amalloypjb3: Vars are callable as functions, and when called they just pass it on to whatever they refer to
22:07pjb3amalloy: cool, thanks
22:12jackdempseyhey pjb3 how you doin man
22:12pjb3jackdempsey: awesome, just got back from clojureconj, how about you? Your on the left coast I hear?
22:13jackdempseypjb3: nice, yeah i wanted to go to that but just moved to SF and couldn't really fly away right then
22:13jackdempseyfinally looking into clojure more these days. very interesting, though i'm experiencing a bit of the normal early stage hiccups
22:13pjb3Sure, talks were really good, so were all the people
22:13jackdempseymore about java and tools than the language itself
22:13jackdempseynice, yeah met some of the fine folks at relevance recently. did they record any talks?
22:14jackdempseywould love to see them if so
22:14pjb3Yeah, there are recorded
22:14pjb3supposedly going to be online
22:14jackdempseyawesome
22:14jackdempseyhave you gone through their labrepl exercises at all?
22:14pjb3no
22:15jackdempseycool, just trying them out to start with. good stuff so far, but i think something's broken, and i know shit about maven :-D
22:15pjb3ah, bummer, maven can be a PITA
22:16jackdempseyyeah, it's one of those "trying to get compojure working, so i run lein deps and boom goes the dynamite" fun things. but no worries, i'm sure it'll work out
22:16pjb3yeah, I'm pumped to do more stuff with clojure after the conference
22:16NafaiI should go through labrepl to get back up to speed with clojure
22:16pjb3I'll have to time find to do that
22:16pjb3what about you, thinking of using clojure for something or just playing around?
22:17jackdempseyeh, more interested in learning it given i think Rich is right and want to be prepared for the situation when i really need it
22:17jackdempseyas opposed to cursing around in ruby :-)
22:17jackdempseyplus i like how it stretches my mind
22:17jackdempseyi never did much with lisp or java so it's kinda perfect in that way
22:17pjb3yeah, I'm going to figure out how to do web dev in clojure for real
22:18pjb3So eventually I can build stuff in clojure instead of Rails
22:18jackdempseyseems for backend service stuff it's certainly a great choice. hard to tell how great it is on the actual generating html / front side stuff at the moment
22:18jackdempseyall will come in time i'm sure
22:18rdeshpandepjb3: i'm in the same boat!
22:19rdeshpandepjb3: just started with it today though
22:19pjb3I'm gonna give enlive a spin for templating for now
22:19pjb3but we need better templating options I think
22:19jackdempseyyeah i'm curious how that will place out in practice. great idea i think
22:19rdeshpandea friend of mine and i are sitting here running through project euler problems in clojure
22:19pjb3rdeshpande: cool
22:19jackdempseyrdeshpande: are you able to run lein deps in labrepl now and have it work?
22:19jackdempseyit's blowing up for me
22:19pjb3I was just writing a sort of frameworky/router thing
22:20jackdempseycomplaining about org.apache.maven:super-pom:jar:2.0 missing etc
22:20jackdempseynice
22:20pjb3then realized it's almost exactly the same as compojure
22:20jackdempseyah
22:20pjb3I hadn't even looked at compjure
22:20rdeshpandejackdempsey: just saw your reference to it and setting it up now
22:20pjb3was using GET and POST for the routes just like compojure, thought that was funny that I independently arrived at the same idea
22:20jackdempseyhehe
22:21jackdempseygreat minds think alike?
22:21jackdempseyrdeshpande: cool
22:21pjb3Mine is awesome though because it's just functions, no macros :)
22:21jackdempseyhehe
22:21jackdempseyit's things like that that i'm still learning to grok
22:21pjb3that's why I asked about the calling a var trick
22:21jackdempseyah
22:22pjb3I need to have that work or resort to a macro
22:22pjb3and then I did it and it worked
22:22jackdempseyis using macros bad for some reason?
22:22pjb3and I was like
22:22jackdempseyhaha
22:22jackdempseyyeah
22:22pjb3but it makes sense, vars are callable, like maps and keywords are callable
22:22pjb3I love that
22:22rdeshpandepjb3: what are your thoughts so far coming from the ruby world?
22:23pjb3rdeshpande: I think the way state is managed in clojure is a huge win
22:23pjb3that's my biggest complaint with ruby
22:24jackdempseypjb3: yea very cool design (callable )
22:24pjb3larger apps seem to devolved into a mess of instance_var_set, alias_method_chain nonsense that is hard to follow
22:24rdeshpandemethod_missing
22:24pjb3yeah
22:24pjb3unnecessary meta programming
22:24rdeshpandei hate seeing code that defines methods at runtime using strings with "def foo.#{something}"
22:24jackdempseyyep, state and concurrency features are really forward thinking
22:24rdeshpandevery hard to debug
22:24pjb3I liked that that was a big topic of conversation at "the conj", as it was called
22:24pjb3was about how to avoid using macros (metaprogramming)
22:25pjb3when you can use functions instead
22:25jackdempseypjb3: so if you have a sec, i'd love to hear a summary of that. being fairly new to lisp, i don't really have much history/background knowledge to get why that is important
22:25pjb3Christophe Grand and Stuart Sierra both gave great talks on that
22:25rdeshpandebtw any chance you guys are in the NYC area?
22:25jackdempseyi'm still trying to clarify in my head reader macros vs code macros etc
22:25jackdempseyrdeshpande: just moved to SF
22:25amalloyheh. i've been using clojure since june, and so far i've had the chance to help out three different people with macros on #clojure
22:25TeXnomancymacros are like second-amendment rights. you hope you never have to use them, but when you do you'd be in a world of hurt without them
22:26pjb3rdeshpande: Baltimore
22:26rdeshpandeah ok, cool
22:26amalloyin each case, the answer was "Use fewer macros"
22:26jackdempseytechnomancy: haha nice
22:26pjb3jackdempsey: first, reader macros are syntax stuff
22:26pjb3#'foo
22:26amalloyjackdempsey: i moved to SF in june. how long have you been here?
22:26pjb3ends up being
22:26pjb3(var foo)
22:26jackdempseyand that's the actual code/data that gets interpreted
22:26pjb3You don't get to make your own reader macros, only Rich does :)
22:26jackdempseyamalloy: a few days? :-)
22:27jackdempseyyeah, i remember reading that. i think that was smart of him
22:27amalloyhaha, well hello then. whereabouts?
22:27pjb3right, even '(1 2 3) is just (list 1 2 3)
22:27amalloypjb3: no, it's (quote (1 2 3))
22:27jackdempseytechnomancy: hey sir, mind a lein question? i can't tell if this is labrepl blowing up or what, but running lein deps seems to bork on their project now
22:27pjb3amalloy: er, right
22:27pjb3,(macroexpand ''(1 2 3))
22:27clojurebot(quote (1 2 3))
22:28pjb3whereas macros that you write basically take the raw code/data and re-write them before they get executed
22:28jackdempseycool, so just things to make it easier to type, whereas code macros are substituted at compile-time?
22:28pjb3and you get to write those
22:28jackdempseyamalloy: thx! living out in brisbane just south of the city
22:29pjb3right, they run a compile time, the convert the data before it actually gets evaled
22:29technomancyjackdempsey: sure; let's see a gist?
22:29jackdempseypjb3: so i guess the dumb question is: why are they any different than just functions? because of the compile time nature and they can be evaled before things are actually run?
22:29amalloyjackdempsey: they don't evaluate their arguments, and they expand at compile time. that's about it
22:30jackdempseytechnomancy: http://gist.github.com/643005 i used to be on clojure 1.3 but some updates/upgrades seem to have me back on 1.2
22:30pjb3Also, macros are hard to compose with other code because they can't be used as higher order functions
22:30jackdempseynot sure why it's trying to use beta1 tho
22:31jackdempseyso comparing them to ruby's metaprogramming is a decent analogy of sorts? (cept compile-time etc)
22:31amalloydunno. not a rubyist
22:31pjb3yes
22:31jackdempseyhehe ya sry was for paul
22:31jackdempseycool
22:31pjb3so it has the same drawbacks as ruby metaprogramming
22:31jackdempseyseems 'tricks' that lead to complexity are
22:31jackdempseyyeah exatly
22:31pjb3it's hard to follow/debug
22:31jackdempseywith a c even
22:31jackdempseyk
22:31jackdempseybut sometimes really nice/useful
22:31jackdempseyso use sparingly. cool.
22:31pjb3if can be done with regular methods, it's just better
22:31pjb3right
22:32pjb3basically, only use a macro if you really have to
22:32jackdempseyyea
22:32pjb3maybe to have a little syntactic suger
22:32jackdempseyk
22:32pjb3but when you do, make sure there are underlying functions that people can call directly
22:32jackdempseyas far as philosophies go, would you say clojure's more perl or python (tmtowtdi or basically 1 correct way)
22:33pjb3so that they can skip the sugar if they want to compose with other functions
22:33jackdempseyyea, makes sense
22:33pjb3hard to say on the tmtowtdi/1 way thing
22:34jackdempseyreason i ask is that there seems to be a billion ways to do most things......but i'm sure some are better ideas than others......so any guiding principles?
22:34pjb3maybe it's sort of like ruby in that sense
22:34jackdempseyyea
22:34jackdempseyprefer functions to macros
22:34pjb3jackdempsey: are there a billion ways to do things? like what?
22:34rdeshpandetmtowtdi is a reason im trying to move away from ruby
22:34rdeshpandei like python's PEPs
22:34jackdempseywell, just going through the labrepl bit, there're so many ways it seems to do some simple functions
22:35pjb3well, clojure syntactically is more regular that ruby for sure
22:35jackdempseycreate a range and filter out nubmers you don't want them add them.......or programmtically come up with numbers in an additive way, and so on
22:35pjb3you don't have the {} vs. do end
22:35pjb3use parens or not
22:35pjb3jackdempsey: that's true, but I think that's just the way functional programming is
22:36jackdempseypjb3: i keep toying with the idea of taking whitespace idea from python/haml and using it to build something with even less (). they're still not very comfortable to me yet. guessing htat changes with time
22:36jackdempseypjb3: ah true, good clarification
22:38pjb3jackdempsey: don't let the parens both you, they just melt away after a while
22:38jackdempseyheh k
22:38pjb3and the parens are what make macros possible
22:38jackdempseytechnomancy: does that gist make any sense? i can't see why it's trying to go after beta1 when 1.2 final seems to be out
22:38jackdempseyi'm making my way through stu halloway's book. have you read the one by sierra?
22:39pjb3jackdempsey: I'm reading sierra's one now, I think it's much better than stu's so far
22:39jackdempseycool
22:39pjb3but don't tell stu I that ;)
22:39jackdempseyhahaha
22:39jackdempseythis has been a good intro but i'm kind of hungering for something deeper
22:39jackdempseyamalloy: anything cool going on around here with clojure?
22:40amalloyum, KirinDave is around here somewhere, but i haven't actually met any clojurians yet
22:40technomancyjackdempsey: hard to say; no reason beta1 makes sense any more
22:40amalloythere's a monthly meetup group called baclojure
22:40jackdempseygotcha
22:40amalloyplanning to go to my first one next month
22:41jackdempseytechnomancy: i ultimately just want to run the compojure exercises but when i do (use 'compojure) it bombs. trying to figure out if it's just me doing something stupid or a dep isn't loaded
22:41jackdempseyamalloy: nice, will look that up
22:41jackdempseywow, 300 people in the group. cool
22:42technomancyjackdempsey: network's crap here or I'd check out labrepl myself
22:43jackdempseytechnomancy: haha yeah i'm on a neighbors unsecured wireless till comcrapst can set me up
22:45jackdempseypjb3: so the sierra book won't be a waste after reading a bit on the net and stu's book? (bit pricey, just don't want to waste the $)
22:46amalloyjackdempsey: Joy of Clojure is a good one. i haven't read the others, but it's supposed to be a good "second book"
22:47jackdempseycool
22:47jackdempseythx
22:47amalloyand i liked it as a first book, but with prior experience in java and a little CL
23:28zakwilsonI'm doing a bunch of map lookups in a very inner loop. The keys are strings, and the maps are smallish (generally no more than a couple thousand entries). Can this be made faster?
23:29dashhmm. i'm trying to understand the implementation of 'assoc' in PersistentHashMap and there are some branches which don't appear to ever be taken. is there some test coverage i can look at to figure out if i'm just missing stuff? :)
23:31dash(In particular I don't see how HashCollisionNode.assoc's branch where the hashes are unequal can occur)
23:31amalloyzakwilson: make the keys into keywords if possible
23:31zakwilsonamalloy: you'd think, but that's actually slower
23:33amalloyzakwilson: how many times do you look up a given key, on average?
23:34amalloydash: eclipse will detect branches which are impossible. it doesn't understand everything, but it's pretty good
23:34zakwilsonamalloy: I haven't actually measured that. If you're hinting at memoization, it's not the answer here. There are 30,000 maps being looked at here.
23:35amalloyno, i'm not. my point is if you look up each key 10 times it's worth converting from string to keyword before you loop; if most keys never get looked up at all, leave them as strings
23:36amalloy(this is a guess. i don't know much about the internals involved here)
23:38zakwilsonamalloy: with all the keys as keywords, it's slower. Sometimes most of the keys get looked up, sometimes they don't. Either way, it was slower with all of the keys as keywords.
23:38amalloyhuh
23:39dashamalloy: across method calls? :)
23:39zakwilsonSomebody provided an explanation once. Keywords are also slow to read.
23:43dashaha
23:43dashi figured out how it gets there. :)