#clojure logs

2011-11-01

00:08eggsbyhow could I rewrite this in clojure? http://pastie.org/2791611
00:09eggsbyI'm trying to work through the little schemer using clojure :|
00:11brehauteggsby: im not exactly sure what the equivalent is in clojure, it seems that theres a bit of conceptual mismatch
00:12eggsbyjust my luck :)
00:12yacin(not (coll? x))
00:12yacinwould probably be sufficient
00:12brehautyacin: good thought
00:12yacinatom? in that context means not null and not a list made with cons
00:13brehaut(def scalar? (complement coll?))
00:13eggsbyhmm ya that seems like such a loose definition yacin
00:13hiredmancoll? checks for IPersistantCollection
00:13hiredmanso most java collections fail
00:15eggsbyhmm. Maybe I should work my way through scheme before moving to clojure :) Seems there's a bit of impedance mismatch between them
00:15eggsbyI figured a lisp would be a lisp :(
00:16brehauteggsby: depends what your motivation for learning scheme and / or clojure is, but why not just go straight to clojure?
00:16hiredmanwell, really a lot of lisp related literature just tasks lists and cons cells, but common lisp and scheme both have other datastructures
00:16hiredmanno idea how pair? would deal with a vector in scheme
00:16eggsbybrehaut: I just picked up this book 'the little schemer', my motivations are just to understand recursion/functional programming better
00:16yacinpair? checks for stuff made with cons
00:17hiredmanthey are more in your face in clojure because there is a literal syntax for them and used everywhere
00:17eggsbyI have some friends who use clojure and love it, so I figured it'd be a nice lisp to try. I was going to try to adapt the book to clojure
00:17hiredmanyacin: there is a cons in clojure, but it doesn't create cons cells
00:17hiredmanso you cannot use it to create pairs
00:17yacini'm aware
00:18hiredmanso there are no pairs
00:18hiredmanso (def pair? (constantly false))
00:18eggsbyI saw the strangeloop talk by rich hickey, "simple made easy", was a big vote of confidence for the language to me
00:18technomancycouldn't you count a MapEntry as a pair?
00:19hiredmandepends how fast and loose you want to be
00:19hiredmanhttps://github.com/hiredman/tuples <- you could call a Tuple2 a pair
00:19brehauthiredman: im curious, does clojure.lang.Cons count as a cons cell?
00:19hiredmannot in the same sense as cons in scheme or cl
00:20hiredmanc.l.Cons is always proper
00:20hiredmanso it is always a list
00:20hiredman(seq really)
00:20brehauthiredman: by proper do you mean that it cant be used as a dotted pair?
00:20hiredmanyes
00:21brehautaha. thanks
00:23hiredmanIPersistantList is a classical linked list under the covers, but the links are not exposed
00:52jayunit100i want to calculate the same thing "n" times.... is there a good function template for that [consider an iterative algorithm , like newtons method, for example]
00:52technomancy(doc iterate)
00:52clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
00:53jayunit100excellent !
00:53jayunit100i always knew iterate wa good fur sumthin
00:54TheBusbyif you call something like (macro foo), the macro will receive "foo" as the argument. How can I do (macro foo) where the macro will receive the value bound to "foo"?
00:57TheBusbywithout modifying the macro being called.
01:13gtrak``what's foo?
01:13TheBusby(def foo 5)
01:14TheBusbyI think I'm trying to find the value of a symbol passed to a macro
01:14gtrak``the value of the symbol?
01:14gtrak``,'foo
01:14clojurebotfoo
01:14gtrak``like that?
01:15gtrak``,(str 'foo)
01:15clojurebot"foo"
01:15gtrak``(class 'foo)
01:15gtrak``,(class 'foo)
01:15clojurebotclojure.lang.Symbol
01:15gtrak``there you have it
01:18gtrak``(eval 'foo)
01:19gtrak``,(eval 'foo)
01:19clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
01:25mangeMacros are run at compile time, so in what environment do you want the value of the symbol? The run time environment doesn't exist yet.
01:28TheBusbyahh,
01:30TheBusbygtrak``: Thank you, that was it! So the only way to get the value of a symbol is with eval.
02:20michaelr525hey
02:33TheBusbyhey?
02:33clojurebothey is for horses
02:34RaynesGrass is sheaper.
02:34RaynesCheaper*
02:35michaelr525grass is cheaper to grow @ home
02:41TheBusbyatleast there is an alternative spelling, not like "sake"
02:47michaelr525what's wrong with sake?
04:01minsawhat would be clojure equivalent of the following list comprehension in haskell:
04:01minsarightTriangles = [ (a, b, c) | c <- [1..10], b <- [1..10], c <- [1..10], a^2 + b^2 == c^2, a+b+c == 24]
04:03opqdonutrewrite that comprehension using map and filter, then you can straightforwardly translate it to clojure
04:04opqdonutthe other option is ##(for [a (range 1 10) b (range 1 10) c (range 1 10) :when (= (* c c) (+ (* a a) (* b b))) :when (= 24 (+ a b c))] [a b c])
04:04lazybot⇒ ()
04:04minsaok.
04:04opqdonutoh, did I typo something there?
04:05opqdonutright,
04:05opqdonut##(for [a (range 1 11) b (range 1 11) c (range 1 11) :when (= (* c c) (+ (* a a) (* b b))) :when (= 24 (+ a b c))] [a b c])
04:05lazybot⇒ ([6 8 10] [8 6 10])
04:08minsaopqdonut, thnx a lot.
04:11opqdonutminsa, np
08:58jweisstried to google for the meaning of this error (migrating to clojure 1.3), but found no answers: "Caused by: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V"
09:01opqdonutwow
09:09llasramjweiss: I think I might have run into that before, but my memory isn't fully jogged... More context?
09:11jweissllasram: http://paste.lisp.org/display/125616
09:11jweissi get the exception on the first line of the defn
09:12jweissllasram: i saw a transcript of this channel where someone was discussing this error, they were saying NoSuchMethodError only occurs with AOT compiled code... but I don't think i have any
09:13llasramAh, that was it! I had stale AOT code sitting around. Sorry if that isn't helpful in your case
09:16jweissllasram: yup, that was the case for me as well, lein clean fixed it
09:16llasramAwesome!
09:16jweisswow, i stopped AOT compiling a long time ago, didn't realize those class files just sat around :)
09:18llasramThey do seem to hang... I think I saw a few days ago that technomancy wanted to figure out when people find the need `clean' and fix those situtations. Maybe a future release of leiningen will detect stale AOT class files (or do it better? not sure if it tries to today)
09:28jweissanother strange clojure-1.3 upgrade error is sudden inability to recognize java.io.Writer classname - now have to explicitly import?
09:31llasramHuh. It seems kind of random that <1.3 would randomly import a few java.io classes into your namespaces anyway. That may have been a bug?
09:33jweissllasram: IIRC in clojure 1.2 you didn't have to import java.lang and java.io
09:35fdaoud,(new String "test")
09:35clojurebot"test"
09:35fdaoud,(new File ".")
09:35clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: File, compiling:(NO_SOURCE_PATH:0)>
09:36Bronsa,*clojure-version*
09:36clojurebot{:major 1, :minor 3, :incremental 0, :qualifier nil}
09:36llasram##(File. ".")
09:36lazybotjava.lang.IllegalArgumentException: Unable to resolve classname: File
09:36llasram##(identity *clojure-version*)
09:36lazybot⇒ {:major 1, :minor 3, :incremental 0, :qualifier nil}
09:36fdaoudI get the same results in 1.2 repl
09:36llasramOh, lazybot got an upgrade
09:37jweisshm, i am not sure how this same code worked in 1.2 then
09:37llasramAnyway, like fdaoud I tried in a 1.2 local REPL. Writer is imported, but most of java.io is not
09:37fdaoudllasram how do you see that Writer is imported?
09:38llasramEr, I just type "Writer", and it evaluates to java.io.Writer instead of throwing an exception :-)
09:38jweissmy code is like this: (defmethod print-method :bz-blocker [o ^Writer w]
09:38jweiss (print-method (::source (meta o)) w))
09:38jweisscompiles fine in 1.2
09:38fdaoudllasram: maybe it's the lack of coffee on my part. I don't understand. "Writer" is just a string...?
09:39jweissno, symbol
09:39llasramYeah, sorry. No quotes
09:39llasram,(ns-resolve *ns* 'Writer)
09:39clojurebotnil
09:39fdaoudsheesh. where's my coffee?
09:39fdaoudwell just Writer gives me java.lang.Exception: Unable to resolve symbol: Writer in this context
09:40fdaoudString does give me java.lang.String
09:40fdaoudI'm on 1.2.0 to be precise
09:40jweissllasram: which version are you using?
09:41jweiss,Writer
09:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Writer in this context, compiling:(NO_SOURCE_PATH:0)>
09:41fdaoud,String
09:41clojurebotjava.lang.String
09:41jweiss,java.io.Writer
09:41clojurebotjava.io.Writer
09:41llasramInteresting. Must be a leiningen bug. `lein repl' pulls Writer into *ns*, but java ... clojure.main with clojure 1.2.1 does not
09:42llasramWait, no. Ok, *I* need more coffee
09:42llasramI've got 1.3 stuff in my lein init.clj. That was causing `lein repl' to bail out during init, leaving me in the `clojure.core' namespace. *That* namespaces has Writer imported
09:42llasramWheeeee
09:43fdaoudcool
09:43jweissi can tell you that when i ran my code with 1.2.0 i didn't need to specify java.io at all
09:48fdaoudin programming clojure book (definitely pre 1.3), it says classes outside of java.lang must be fully qualified or imported.
09:48jweisshm... i thought i read java.io was included, which is why i left it off. And it worked so i figured that was correct
09:48fdaoudmaybe that was 1.1 and something changed in 1.2?
09:49jweissnow i can't find any reference to java.io being imported by default
09:49jweissso i don't know why it ever worked
09:50jweisswell, easy fix at least, even if i can't explain why it suddenly broke
09:51fdaoudstrange
11:38fdaoudis there something more idiomatic than (not (nil? x))
11:39lucianfdaoud: x
11:39abedrafdaoud: are you looking to filter a collection or just test a single thing?
11:40abedrafdaoud: and are you explicitly looking for nil, or do empty collections and blank strings apply?
11:42fdaoudlucian: thanks, so simple that I missed it!
11:42fdaoudabedra: just test a single thing, but I am interested in what you have to say about filtering a collection, empty collections, and blank strings
11:42abedrafdaoud: you can filter nils out of a collection with (filter identity collection)
11:42fdaoudto filter, it would be keep?
11:42abedrabut there are lots of ways of doing that
11:42abedrayes
11:43abedrayou only get real values back, no nils
11:43abedra(filter identity [nil 1 nil 4 5 nil 6])
11:43abedra,(filter identity [nil 1 nil 4 5 nil 6])
11:43clojurebot(1 4 5 6)
11:43fdaouddifference between filter and keep seems to be for false values
11:44fdaoudi.e. false is returned with keep, filtered out with filter
11:44abedra,(doc filter)
11:44clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
11:44abedra,(doc keep)
11:44clojurebot"([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."
11:45fdaoud,[(keep identity [nil 1 false 2]) (filter identity [nil 1 false 2])]
11:45clojurebot[(1 false 2) (1 2)]
11:45abedrayep
11:45fdaoudnice, thanks
11:45abedranp
11:47abedrafdaoud: there's also remove
11:47abedra,(remove nil? [1 nil 2 false 4])
11:47clojurebot(1 2 false 4)
11:47fdaoud,(doc remove)
11:47clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-effects."
11:48abedrafdaoud: just like filter, takes a predicate, but removes on true
11:48fdaoud,(remove identity [nil 1 false 2])
11:48clojurebot(nil false)
11:48abedrait removes when the predicate is true
11:49abedraidentity returns false on nil and false
11:49fdaoudI see
11:49abedraso if you are looking to remove only nil values and still have things like false around, you can use remove nil? or keep identity
11:50abedrai prefer remove
11:51fdaoud,(let [coll [nil 1 false 2]] (= coll (mapcat #(% identity coll) [filter remove])))
11:51clojurebotfalse
11:52fdaoud,(let [coll [nil 1 false 2]] (= coll (mapcat #(% identity coll) [remove filter])))
11:52clojurebotfalse
11:53fdaoud,(let [coll #{nil 1 false 2}] (= coll (mapcat #(% identity coll) [filter remove])))
11:53clojurebotfalse
11:53fdaoud,(let [coll #{nil 1 false 2}] (= coll (set (mapcat #(% identity coll) [filter remove]))))
11:53clojurebottrue
11:55iris1Dear experts, how can I do a recursive definition of a seq in a let? Here is an example illustrating my problem: http://pastebin.com/RSc1Wekf It appears that in a let, the name being defined is not available (which is not the case in a def). Thank you!
12:05chouser_iris1: that's a tough one
12:06chouserI think I've done it, but I'm having trouble remembering how
12:10chouseriris1: one option is to use letfn which specifically allows expressions to refer to the local names being defined.
12:10chouser(letfn [(v1 [] (range 10)) (w1 [] (lazy-cat [0] (map + (v1) (w1))))] (w1))
12:11iris1Thank you, chouser! My best guess was to bung a defn in there but this is clearly better.
12:12ipostelnikwhy would you want to do something like this in the first place?
12:13chouseripostelnik: I'll let iris1 handle that one. :-)
12:15iris1In math notation, I have a sequence (f0, f1, f2, f3, ...) as an input. I want to use it to generate an output sequence (g0, g1, g2, g3, ...), where gi depends on g(i-1) and fi. Basically the fi are a sequence of observations about the world, and the gi are my representation of what the world looks like based on those observations. There is probably some fancy name for this, like folding or reducing (although I don't think it's exactly one
12:15iris1those two)
12:17chouseriris1: another option is to use a promise
12:17chouser,(take 20 (let [fib (promise)] (deliver fib (lazy-cat [1 1] (map + @fib (next @fib)))) @fib))
12:17clojurebot(1 1 2 3 5 ...)
12:17ipostelnikiris1, I think reductions is what you really want
12:17ipostelnik,(doc reductions)
12:17clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
12:19ipostelnik,(reductions + 0 (range 10))
12:19clojurebot(0 0 1 3 6 ...)
12:20iris1chouser: Thank you! I haven't really learned about promises yet. I am just learning Clojure, from a number of books including yours. Thank you for your help!
12:21iris1ipostelnik: Thank you! That's great. Reductions does look like what I need. It seems like I am going to need to zip f and g together first in order to introduce g into the calculation. I am going to give that a try.
12:21ipostelnikiris1, your fn will get called with g(i-1) and f(i)
12:22iris1ipostelnik: Ah yes, you are so right! Thanks & sorry for missing that point. Absolutely no need for zipping. This is awesome. (I'll still learn about promises as they look useful too.)
12:32phfi'm trying to move a lein/emacs based development environment from mac to a windows machine that doesn't have internet connection. is it enough to grab lein.bat, ~/.m2, ~/.lein and emacs?
12:33TimMcGood question. I wonder if any of the maven artifacts are arch-dependent.
12:34TimMcphf: Are you able to try it multiple times? THat is, do you have access to both machines at once?
12:35phfTimMc: yes, but i'd like to minimize the number of tries. (lotus 8, email and "split" are involved in the process :/)
12:35TimMcheh
12:36TimMcMaven will yell if it needs a dependency, and you can manually install those.
12:36phfi guess as long as nobody jumped in with "you also need X", i'm just going to go ahead and try it
12:36TimMcReport back either way!
12:36phfack
12:37technomancyllasram: clojure 1.2 let you have type hints to classes that didn't exist
12:37technomancynothing changed in what was imported automatically
12:51llasramtechnomancy: Oh, cool. That is useful to know.
13:11pcarrierhey
13:11pcarrierI'm trying to transform an array into a hash, and I'd like to avoid destructuring into symbols then creating the map...
13:12pcarrierfor example [a b c] becomes { :foo a :bar c }, with b being discarded
13:12dnolen,(object-array [1 2 3 4])
13:12pcarrieris there a clean way to do that?
13:12clojurebot#<Object[] [Ljava.lang.Object;@3589e6>
13:12dnolen(into {} (object-array [1 2 3 4]))
13:12dnolen,(into {} (object-array [1 2 3 4]))
13:12clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
13:12dnolenoops
13:13dnolen,(into {} (map vec (parition 2 (object-array [1 2 3 4]))))
13:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: parition in this context, compiling:(NO_SOURCE_PATH:0)>
13:13dnolen,(into {} (map vec (partition 2 (object-array [1 2 3 4]))))
13:13clojurebot{1 2, 3 4}
13:13dnolenfinally
13:13pcarrierdnolen: but that's not what I'm looking for...
13:14dnolenpcarrier: sorry missed a line of description.
13:14pcarrierI'd like to transform [a b c] into { :foo a :bar c }, by saying something like (mapify [ :foo 0 :bar 2 ] [a b c])
13:14ibdknoxhow do you know to ignore b?
13:14pcarrierassociative destructuring into a map, if I may abuse the word
13:14pcarrieribdknox: because 0 and 2 are indexes
13:14licenserbecause it is 2
13:15ibdknoxah I see
13:15pcarriersomething like (let {foo 0, bar 2} [a b c]]
13:15licenserpcalcado: do something like (reduce (fn [m [k v]] (assoc m k (nth v [a b c]))) {} {:foo 0 :bar 2})
13:15pcarrierbut instead of binding foo and bar, it returns { foo ... bar ... }
13:16licensernot guaranteed to work but along those lines is what solves your problem :)
13:16pcarrierI'm not sure if I make sense
13:16pcarrierI certainly hope I do :)
13:16pcarrier(I would use that to parse a message of which I don't control the structure with a regexp into a map)
13:17dnolen,(into {} (map (fn [[k i]] (vector k (nth (object-array '[a b c]) i))) (partition 2 [:foo 0 :bar 2])))
13:17clojurebot{:foo a, :bar c}
13:17ibdknox,(let [m {:foo 0 :bar 2} v '[a b c]] (into {} (map #(vector % (v (m %))) (keys m)))
13:17clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
13:17pcarrierI know how to do it in an ugly way with (let [{foo 0, bar 2} [a b c]] { :foo foo :bar bar })
13:18licenser,(reduce (fn [m [k v]] (assoc m k (nth v [a b c]))) {} {:foo 0 :bar 2})
13:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
13:18pcarrierdnolen: ok, it ends up being more verbose that my ugly approach... I'll guess I do with that :)
13:18licenser,(let [a [1 2 3] (reduce (fn [m [k v]] (assoc m k (nth v [a b c]))) {} {:foo 0 :bar 2}))
13:18clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
13:18ibdknox,(let [m {:foo 0 :bar 2} v '[a b c]] (into {} (map #(vector % (v (m %))) (keys m))))
13:18clojurebot{:foo a, :bar c}
13:19pcarrieribdknox: OK, I'll learn how this works :)
13:19pcarrieribdknox++
13:20technomancythe zipmap trick is pretty cumbersome
13:21ibdknoxyeah the zip-map version is longer
13:22sridibdknox: would you recommend anyone to use your socket.io server implementation, or use something else (if yes, what would that be?)?
13:22sridi realized that directly using websockets (via aleph) in my application doesn't work for basic auth
13:22ibdknoxsrid: using my socket.io server is not for the faint-hearted
13:23ibdknoxsrid: and how would it help solve an issue that cannot be solved with aleph?
13:24sridthe websockets standard doesn't seem to support any auth mechanism (eg: http basic auth).
13:24sridso maybe I should switch to long polling, flash or something else
13:24sridfor that, I need a server-side abstraction
13:25ibdknoxsrid: you probably shouldn't be using basic auth
13:25ibdknoxsrid: also, in the time it would take you to switch to a different mechanism, you could've easily written simple auth for your app
13:25sridwould anything else work with websockets? you mean like manually authorizing the passed-in user/pass via websocket channel?
13:26ibdknoxI assume you're serving a page, right?
13:26sridserving a page, and then "streaming" events (as they come in from many servers) to the just served-page via WS
13:26sridimagine a "multitail" web frontend
13:27sridthe page itself can be protected with basic auth. but WS data would still be exposed
13:27ibdknoxso serve a login page and then send the ring-session-id as the first thing down your socket
13:27ibdknoxstore the session ID's in an atom when a user logs in
13:28ibdknoxand problem solved
13:29sridwhat is ring-session-id?
13:30ibdknoxsrid: it's the id in the cookie that is set for ring-sessions, though really you can use anything. You could set your own cookie
13:31sridok, i'll try that. (cookies are not automatically sent to the server in 'request'? will check ...)
13:31seancorf`i had a bunch of folks try my "emacs on windows" post and everyone on windows 7 ran into the same problem: clojure-jack-in fails with an error about non-hex characters in a unicode escape sequence
13:32seancorf`i'm guessing that it's due to "c:\users\..." in strings because the "home" folder is buried under that folder
13:32seancorf`on win xp, it's "c:\documents and settings\..." so i didn't run into it
13:32seancorf`anyone using emacs on windows 7 have any suggestions?
13:32chouser%something%
13:33chouserheh -- of course I don't use emacs or windows
13:34chouserbut I was following some tutorial the other day and the path was wrong, but they had a % thingy that worked in both XP and 7
13:35chouserseancorfield`: maybe %homepath% ?
13:36seancorfieldit would help if i could figure out where in the elisp code the error was occurring
13:36seancorfieldit looks like the installation process for a package puts the path into the code?
13:37seancorfieldi just looked on my mac and found a lot of "~/..." paths in the code
13:37seancorfieldwould setting default-path in init.el (to some
13:38seancorfieldsimple path) help i wonder?
13:51Squee-DMorning
13:54pcarrierhow can I have nice and clean clojure backtraces in my processes?
13:55pcarrierI'm running threads, which breaks my clj-stacktrace attempt
14:17Raynestechnomancy: Looking good. The Heroku tryclj.com tweet just went out and the site is getting pounded, but still seems to be going strong.
14:17technomancystill on one dyno?
14:17RaynesYep.
14:18RaynesStill snappy.
14:18technomancyrocking
14:19RaynesEven people using it from iPads.
14:19technomancywhat'll they think of next.
14:19fdaoud<-- tried it from iPad
14:19RaynesI actually just updated the jquery-console. I guess it's supposed to have improvements in iOS now, so good thing.
14:20Raynesfdaoud: Did it work properly?
14:20RaynesI've used it from Android.
14:20RaynesWorks fine there.
14:20fdaoudcontext = reading clojure book on ipad, want to try stuff out, don't want to transit to computer
14:20fdaoudRaynes: yes sir
14:20RaynesGreat!
14:22abedratechnomancy: when do you get into our neck of the woods next week?
14:22technomancyabedra: should be Wednesday evening
14:22abedraok cool.
14:22abedratechnomancy: want to catch up with you on your plans for world domination at your new gig
14:23abedratechnomancy: and other general plotting and scheming
14:23Raynesabedra: Also, I may or may not decide you should stand up and talk about something during my talk. Haven't decided if I want payback for last year.
14:23abedraRaynes: :)
14:23technomancyabedra: sure; I should be at the game room thing handing out drink tickets the night before.
14:23abedraRaynes: I was just breaking you in for this year
14:23abedratechnomancy: cool!
14:24RaynesHeh. Breaking what, my neck? My legs were shaking so bad that I could hardly stand.
14:24abedra:)
14:24abedraRaynes: and now you're giving a talk
14:24ibdknoxwelcome to public speaking ;)
14:24RaynesI'm hoping that the preparation will prevent the whole vibrating legs fiasco this year.
14:25abedraRaynes: mine were too, but that's because I drank too much tequila the night before
14:25RaynesHeh
14:25ibdknoxlol
14:25Squee-DRaynes it wont. you gotta just trip on it :D
14:25abedraRaynes: you'll do great, just bring your passion and all will be right in the world
14:25chouserthe only thing I know that actually kills the nerves is standing up and doing it nervous several dozen times
14:26Squee-Dchouser totally
14:26abedra^^
14:26RaynesI really like my talk. I'm mostly paranoid that I wont be able to keep it all going for 40 minutes. I may have to improvise.
14:26ibdknoxTehe truth is that the worst that could happen is you look ill prepared. There's no question of intelligence here. So *shrug*
14:26Squee-Dchouser really enjoying the book btw
14:26chouseractually, abedra's right too -- being passionate about what you're saying helps tons
14:26chouserSquee-D: thanks!
14:27abedraIf you have time before hand, you can work out some of the excess nervous energy by working out
14:27abedrait really helps
14:27ibdknox+1
14:27RaynesI'm pretty passionate about sandboxing, I think. My most important projects depend on it, and amalloy_ and I have put a lot of work into clojail.
14:27Squee-DThats a good idea
14:27abedrajust hit the treadmill or stationary bike for 20-30 mins
14:27abedrait really helps clear you
14:27chouserSquee-D: did you see the movie of the commits that fogus posted? Demonstrates quite clearly how much you should be complimenting him not me. :-)
14:27RaynesI also think it is a sufficiently interesting subject. I just need to be a sufficiently interesting presenter.
14:28Squee-Dchouser no i did not. Fogus is not here to thank is he?
14:28chouserSquee-D: apparently not at the moment.
14:29Squee-DRaynes i dont know many presenters who can kill my interest in a topic. What makes a good presenter for me is that they bring an interesting topic to light
14:29RaynesHe is never here. At least, never here when I want to say something amusing to him.
14:29ibdknoxyeah, a good topic can mostly stand on its own
14:29ibdknoxthe key as was said is passion
14:29ibdknoxif you're excited, everyone else will be too
14:30RaynesI'll consider singing the talk.
14:30ibdknoxlo
14:30ibdknoxl
14:30RaynesMaybe even some dancing with amalloy_ and ninjudd.
14:30TimMcRaynes: Bring a kitten, everyone will love your talk.
14:30RaynesTimMc: There are *tons* of cats in my talk. :D
14:30RaynesAnd exactly one dog.
14:30TimMcGood, you'll be fine.
14:31Squee-DRaynes a great presenter will help me make cognitive leaps to understanding.. thats really hard for any presenter, but the lack of doesn't mean the presentation wont be compelling.
14:32Squee-Dfwiw, i think it's almost impossible to screw up with an interesting topic.
14:32Squee-Dabedra i'm going to try your suggestion before my next speaking gig
14:33Squee-DIf im dead exhausted i can probably polish it up as 'relaxed and considered'
14:33fdaoudabedra I do stationary bike 45 mins first thing in the morning, it really helps kick start the day
14:33Squee-DRaynes the dog comes to no harm i hope.
14:33ibdknoxIt's a well known "trick" for speakers
14:34abedraSquee-D: I was surprised by how much it helps calm the jitters
14:34Squee-Dabedra it makes a lot of sense
14:34abedraSquee-D: I picked the idea up from "Confessions of a Public Speaker"
14:34RaynesIf I don't start getting sleep at night, I'm not even going to wake up the morning of my talk. Problems solve themselves.
14:34ibdknoxabedra: Scott is a fun guy
14:35RaynesThe lack of sleep is only related to the actual writing of the talk (because I waited until the last minute) and not performing the talk. I just need a) less to do or b) more hours in a day.
14:35fbru02Raynes: I always underestimate the effort of giving a talk then i suffer at the end
14:35ibdknoxit's a lot of work
14:36ibdknoxand a lot of standing in front of a mirror :)
14:36fliebelRaynes: Why is there a dog in the talk?
14:36ibdknoxto eat the cats, of course.
14:37chouseruh oh, I don't stand in front of a mirror. Does it show?
14:37Raynesninjudd is convinced that I need to practice the talk with him and friends over skype. I'm convinced that I need to not practice at all and put all my effort into one good performance. I'm going with him, since he employs me. ;)
14:37Raynesfliebel: Because he's cute.
14:37ibdknoxchouser: it's just another trick
14:38chouserRaynes: oh, definitely practice, and do it out loud, even if nobody is listening.
14:38ibdknoxthat's part of what the mirror helps with, you're talking to somebody
14:38ibdknoxlol
14:38chouserah
14:38RaynesI've been doing complex slides out loud to myself to make sure they make sense.
14:38ibdknoxgotta go it all the way through
14:39RaynesI just don't like cameras with people on the other end. CCTV makes me *want* to rob stores, just to spite the owner who put it there.
14:39ibdknoxa good talk has a rhythm. Once you've internalized that by going through it a couple times, you'll find that it's much easier to just go with the flow on the actual day
14:39fliebelwhen is the conj? wil htere be video?
14:40dnolennext week!
14:41chouserwhew! must finish the talk...
14:41fliebeldnolen: And the logic guy will be there right? ooorh, can't we do it in Europe next time?
14:42gtrakwho's the logic guy?
14:42Rayneschouser: Tell me about it. ._.
14:42Raynesfliebel: Isn't the logic guy dnolen?
14:42fliebelgtrak: The one who write miniKanren, me thinks
14:42flognikrraynes: http://www.forbes.com/sites/jerryweissman/2011/10/26/vinod-khoslas-five-second-rule/
14:42chousergtrak: he wrote core.logic. He's really smart, and comes here sometimes
14:43RaynesGuess not.
14:43RaynesIt's that Australian fellow.
14:43chouseryes, I think we're all talking about dnolen
14:44fliebelI guess dnolen know best, but what I understand is that dnolen and ambrosebs based core.logic on miniKanre, and *that* guy is going to be there as well, I thought.
14:45Rayneschouser: I see a talk by Ambrose about logic programming.
14:45chouserfliebel: ah, I see -- I didn't understand you
14:45Raynesdnolen's talk is about predicate dispatch.
14:46fliebelfrom dosync: "I'm excited to hear William Byrd and Daniel Friedman describe the ideas behind cKanren at the Clojure/conj."
14:46ibdknoxdnolen's so famous now that I'll have to get a picture taken with him and get it autographed! :D
14:46RaynesI've already met him.
14:46Raynes:>
14:46ibdknoxsrsly?
14:46ibdknoxwhat was it like?
14:46RaynesHe has cool hair.
14:47ibdknoxhaha
14:47ibdknox(inc dnolen) :)
14:47lazybot⇒ 1
14:47dnolenfleibel: Dan Friedman is going to be there - big Scheme fellow who wrote some awesome books Little Schemer, Seasoned Schemer, Reasoned Schemer.
14:48dnolenas well as the classic text on creating programming languages - The Essentials of Programming Languages - on the Hickey bookshelf.
14:48jolylove those books, though I need another pass through Reasoned Schemer
14:49abedrajoly: we all do :)
14:50fliebeldnolen: oww, so many books I need to read.
14:50abedraI just took another pass through it recently
14:51dnolenfliebel: William Byrd as well who wrote the miniKanren dissertation.
14:53fliebeldnolen: But they are not on the lineup, so they're just attendants, right?
14:53hiredmanthere is the disj
14:54dnolenfliebel: they'll be unofficially presenting
14:54fliebelhiredman: disj?
14:54ejacksonhiredman: lol, that's for the unreformed ?
14:55fliebeldnolen: So, will there be a video of that?
14:55hiredmanconj : disj :: conf : unconf
14:55gtraklol
14:55dnolenfliebel: hmm, I dunno that would be *awesome* if there was.
14:56dnolenmaybe we can convince someone to bring their own video camera
14:56fliebeldnolen: If there isn't, just point your smartphone at them. (says the guy with a brick for a phone)
14:57hiredmanI think I brought my video camera to the first conj, but didn't use it
14:58oskarthI have a long string I want to display in a web form. How can I format the code nicely (ie no word wrap and correct indentation) without destroying the form text layout?
15:02ThreeCupsIs this a good way to initialize a vector with empty maps?
15:02ThreeCups(let [v (transient [])] (dotimes [i 10] (conj! v {})) (persistent! v))
15:02ibdknox,(vec (take 10 (constantly {})))
15:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__3656>
15:02ibdknox,(vec (take 10 (repeat {})))
15:02clojurebot[{} {} {} {} {} ...]
15:03joegallo,(vec (repeat 10 {}))
15:03clojurebot[{} {} {} {} {} ...]
15:03ThreeCupsibdknox: thanks! I had a feeling there was a better way
15:03ibdknoxhah
15:03ibdknoxdidn't know repeat took a number
15:03ibdknox,(doc repeat)
15:03clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
15:03ibdknoxcool
15:19iwilligin the old clojure contrib repl-utils there was this great function called `show`
15:19iwilligdoes any know if that is still around after the contrib revamp ?
15:19hiredmanit is not
15:19iwilligmmm ;(
15:19iwilligsad face
15:19iwilligokay thanks
15:20hiredmanthere is some similar stuff in clojure.reflect, and I think there was some interest in providing something like show based on clojure.reflect
15:20iwilligoh cool thanks hiredman
15:56technomancyif you're using slime, C-c S-i is a great replacement for show
16:01joegallooooh, pretty
16:01joegallofyi, I would write that as C-c I (that being an uppercase i)
16:02joegalloyour way sent me off to the internets in search of how to define a Super key
16:02joegallobut i'm pretty ignorant
16:06technomancyheh; super is lower-case s
16:15sridlein question: how to get the version in project.clj from within code?
16:16technomancysrid: (System/getenv "LEIN_VERSION") should do it
16:17sridthx
16:17sridi was about to check the env.
16:18sridtechnomancy: oh wait. that's lein's version, not my project's
16:19sridI don't see any other LEIN_* environment.
16:19technomancyoh, that's a System property
16:20technomancy(into {} (System/getProperties)) ; <- should be in there
16:20mtm_heh, I just got bit by 'clojure-jack-in's port selection policy (it just happened to pick a port that was already in use). Is there any elisp floating around to find an unused TCP port in some range?
16:20sridyup, "<name>.version"
16:21technomancymtm_: don't know off the top of my head but that would be great
16:21mtm_I'll dig into it
16:26simardhello, I'd like to have some feedback on this snippet of code: http://pastebin.com/kT1gaaZr
16:26simardspecifically, I'd like to know if the binding is a good idea, and if there is an alternative to it
16:26simard(line 21)
16:28simardthe thing is I'm using multimethods (transform-translate-type), but that method needs to be given a point (delta-xy), and the only way I could think of it was using a binding in the (transform-translate) call.
16:28ibdknoxjust add the point to the map you pass in?
16:28ibdknoxeven better
16:29ibdknoxjust pass the point in?
16:29simardyeah wait, there was a reason I had for not doing that.
16:29simardlet me see :P
16:31brehautsimard: i have no idea what this code is doing
16:32simardbrehaut: well, it transforms geometric objects.
16:32simardtranslation is all there is in that pastebin
16:33simardmore precisely, it transforms lists of objects, recursively. a transformable object is a map containing :x and :y keys
16:33ibdknoxthat binding shouldn't be there
16:33simardyeah
16:33simardibdknox: honestly I've been working on the solution for a good hour now and I .... forgot why I was doing it that way
16:34ibdknoxsimard: haha that's how it goes
16:34simardI seem to recall there was a good reason to that ... :)
16:36jayunit100how to count % chars in a string
16:36jayunit100to a map
16:36ibdknoxlol
16:36ibdknoxwho got Rio Grande to sponsor the Conj?
16:36srid,(frequencies "ab%sd%")
16:37clojurebot{\a 1, \b 1, \% 2, \s 1, \d 1}
16:37sridjayunit100: ^
16:37ibdknoxor the lower level version:
16:37svdberghi
16:37ibdknox,(count (filter #{\%} "some%st%ring"))
16:37clojurebot2
16:38svdbergany idea why doc or (clojure.repl/doc) stopped working in my slime?
16:38svdbergusing clone's of the latest slime/swank-clojure
16:38sridhappens to me too, sometimes
16:38svdbergand clojure 1.3
16:38svdbergit still works in a normal repl
16:39jayunit100something like [count [map [filter c] myString]] , where c is a given character
16:39jayunit100would give a count for an individual char.... but I want to do for all chars in the string, to get a map.
16:39svdbergsrid: any idea how I can fix it?
16:40jayunit100ABC->
16:40jayunit100{A 1, B 1, C 1}
16:40raek,(frequencies "ABC")
16:40clojurebot{\A 1, \B 1, \C 1}
16:41brehaut,(frequencies "hello, world")
16:41clojurebot{\space 1, \d 1, \e 1, \h 1, \, 1, ...}
16:41brehautibdknox: i was wondering that too
16:42ibdknoxbrehaut: 's pretty awesome
16:42fdaoud,(frequencies "kenneth")
16:42clojurebot{\k 1, \e 2, \n 2, \t 1, \h 1}
16:44brehautibdknox: it really is :)
16:45svdbergis there any way to check what ns are in scope? (from the repl)
16:48dnolensvdberg: what do you mean "in scope"
16:48jayunit100(frequencies "ABBBBACAKAAKAC")
16:48jayunit100,
16:48jayunit100,(frequencies "ABBBBACAKAAKAC")
16:48jayunit100hmm. how to get clojure bot to run it ?
16:48jayunit100#(frequencies "ABBBBACAKAAKAC")
16:48llasramsvdberg: What do you mean by "stopped working"?
16:48clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
16:48clojurebot{\A 6, \B 4, \C 2, \K 2}
16:48_uliseshi all, what's the preferred/most mature couchdb client?
16:49svdbergdnolen: I'm trying to find out why slime doesnt see "doc" and my lein repl does
16:49dnolensvdberg: doc is no longer loaded by default.
16:49ibdknox_ulises: https://github.com/ashafa/clutch
16:49_ulisesibdknox: thanks
16:50svdbergdnolen: even (clojure.repl/doc ..) doesnt work
16:50_ulisesibdknox: quick question; I've seen that one but it mentions the clojure view server. Is that a required dependency?
16:50brehaut_ulises: no
16:50_ulisesthanks
16:51dnolensvdberg: did you (require 'clojure.repl) ?
16:51svdbergdnolen: I'll ty
16:51svdbergtry*
16:51brehaut_ulises: ive just been using it as a client API on my site and it works fine
16:51svdbergdnolen: ah.. got it
16:52svdbergI guess lein repl does use it by default?
16:52jayunit100why is persistent! necessary ? I just did source frequencies to see how it worked
16:52dnolensvdberg: yes
16:52brehautjayunit100: does it use a transient map in the reduce?
16:53svdbergdnolen: hmm is there any way to automate it? doc and find-doc are very usefull in a slime repl
16:53jayunit100not sure :]
16:53dnolensvdberg: you can probably customize the slime repl to run some initial forms, I haven't looked into it.
16:53svdbergdnolen: thanks
16:53jayunit100yes
16:53jayunit100it does
16:54ibdknox,(source frequencies)
16:54clojurebotSource not found
16:54jayunit100@dnolen +1 your talk on macros on youtube
16:54brehautjayunit100: i think it does, as the initial accumulator. persistent! is required to get a persistent collection back from a transient. transients are a performance optimisation and shouldnt bleed out of a function
16:54jayunit100(defn frequencies
16:54jayunit100 "Returns a map from distinct items in coll to the number of times
16:54jayunit100 they appear."
16:54jayunit100 {:added "1.2"}
16:54dnolenjayunit100: it's an optimization, not strictly necessary.
16:54dnolenjayunit100: thx!
16:54jayunit100 [coll]
16:54jayunit100 (persistent!
16:54jayunit100 (reduce (fn [counts x]
16:54jayunit100 (assoc! counts x (inc (get counts x 0))))
16:54jayunit100 (transient {}) coll)))
16:54jayunit100nil
16:54jayunit100oh ok
17:00svdbergalrighty back to making presentation
17:00jayunit100does anybody understand this function ?
17:00jayunit100[[about to paste]]
17:01jayunit100(defn counts [words]
17:01jayunit100 (reduce
17:01jayunit100 (fn [map-so-far word]
17:01jayunit100 (assoc map-so-far word (inc (get map-so-far word 0))))
17:01jayunit100 {}
17:01jayunit100 words)) ;;what is the "get map-so-far word 0" part doing ?
17:01ibdknoxjayunit100: you should use gists or pastebin or something instead of pasting in here
17:01jayunit100oh ok
17:01jayunit100from now on.
17:02ibdknoxjayunit100: ##(doc get)
17:02lazybot⇒ "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
17:02ibdknox,(get {} :woot 0)
17:02clojurebot0
17:03ibdknox,(get {:woot "someval"} :woot 0)
17:03clojurebot"someval"
17:03jayunit100oh i see. you customize the default return in the last arg.
17:03ibdknoxyep
17:04iris1What's the idiomatic way to rebind *in* and *out* in Clojure? I tried to find this in the docs but have failed so far. My use case is that I want to write a program that communicates via stdin and stdout, but would like to bind *in* and *out* to files as well for testing purposes. Thank you!
17:05_ulisesiris1: perhaps using (binding [ ...] ...) ?
17:06iris1Yes I agree "binding" looks useful, would you mind giving some more detail? I think this is not just a special case of rebinding a var because I would also like the file to be automatically closed when I go out of scope.
17:06_ulisesiris1: I believe there's a macro to that extent, something along the lines of with-file or something, let me check
17:06ibdknox,(doc with-open)
17:06clojurebot"([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order."
17:06_uliseswith-open! that one
17:07ibdknoxso you'd do something like (with-open [my-file ...] (binding [*out* my-file] ...
17:09iris1ibdknox, _ulises: I see. Thank you!
17:10_ulisesiris1: didn't do much myself but you're welcome :)
17:20technomancyshould with-redefs be backported to 1.2 to ease with writing compatible code?
17:21ibdknox+1
17:22technomancyhow awful would it be for a library to define clojure.core/with-redefs if it wasn't already present?
17:22apexi200sx1anyone know any good books/websites for learning the basics of compiler design (non acedemic texts)
17:22ibdknoxapexi200sx1: that's inherently an academic subject :p
17:22apexi200sx1lol I know
17:23apexi200sx1:)
17:23_ulisesapexi200sx1: try this http://compilers.iecc.com/crenshaw/
17:24apexi200sx1See I knew a Lisp channel would have some input
17:24apexi200sx1:)
17:24gtrakmaybe a check if it's bound, then a custom version if it isn't?
17:26gtrakapexi200sx1, what kind of compiler you talking here?
17:28brehautapexi200sx1: http://stackoverflow.com/questions/1669/learning-to-write-a-compiler
17:28apexi200sx1gtrak: it is in fact a Python to Javascript compiler/translator
17:29apexi200sx1gtrak: I just wanted a basci grounding in what it is I am letting myself in for first
17:29brehautapexi200sx1: like http://pyjs.org/ ?
17:29apexi200sx1gtrak: i usually find having a good high level overview helps digesting
17:29apexi200sx1brehaut, yes I am on that channel now...
17:29apexi200sx1it is just very quiet
17:30gtrakI'm afraid a high-level overview is too high-level to be useful in this case, but maybe take a look at the cljs compiler for inspiration
17:30brehautpersonally i think you gain very little by writing javascript in python ;)
17:30gtrakthen stop what you're doing and just write clojurescript
17:30brehautgtrak: lol
17:31brehautthe coffeescript compiler might also be worth a look
17:31gfrederi1kscoffeescript has the advantage of being very transparent
17:31gtraki spent some time learning python, went to conferences and such, once I latched onto clojure I haven't touched it
17:32brehautclojure is python 3000 done right ;)
17:32apexi200sx1The pyjamas project (of which the python to javascript translator is part of)
17:32gtrakbasically a compiler is lexer->parser->AST->output code
17:33gtraklisps are basically macros->AST->output code
17:33apexi200sx1brehaut: I am aware that Clojure seems to be an excellent language and I enjoy Rich Hickeys talks he does, he is a smart guy, I just unfortunately don;t have any need/reason at the moment to write Clojure codfe
17:34apexi200sx1gtrak: yeah another reason I chose the Clocjure channel
17:34apexi200sx1:)
17:34gtrakwell, it's a general purpose language, I recommend just piddling around with it until you see the light :-)
17:34brehautapexi200sx1: i write python every day, but i wish i were writing clojure
17:34apexi200sx1Lispy/Clojure isn;t learnt by people to get a job done, it is learnt by people who know what they're doing
17:35apexi200sx1I meant, as in to get a job with a corporation
17:35brehautpeople who are just 'getting the job done' dont choose to learn anything though
17:35apexi200sx1brehaut: you know what I mean, i just didn;t articulate it very well, I mean as in learning the language for its own merits rather than popularity
17:36gtrakapexi200sx1, actually some folks do clojure to get a job done
17:36apexi200sx1brehaut: interesting you saying you write Python in your day job, you are lucky even to be doing that, most people have to write java/c#/c/c++
17:37brehautapexi200sx1: not lucky; determined. i hope to ditch python too
17:38apexi200sx1brehaut: just out of interest is it you dislike Python, or that you just think Clojure is more productive/nicer to program in, just interested to hear
17:38gtrakbrehaut, start by transitioning to jython, then bring in clojure as a concurrency lib :-)
17:38brehautgtrak: lol :)
17:39gtrakapexi200sx1, http://jkkramer.wordpress.com/2011/03/29/clojure-python-side-by-side/
17:39brehautapexi200sx1: high on the list is mutable by default, a lack of higher order operations, an extremely weak iterator model (mutable iterators such a bad idea), shoddy enviroment stuff (easy_install, pip, virtual env etc are easy to create a huge mess with)
17:41technomancyheh; isn't easy_install the one with no uninstaller?
17:41brehauttechnomancy: i think so yeah
17:41brehauttechnomancy: every time i have to use one of those i wish i had lein
17:41gtrakthe maven model is superior, though cumbersome
17:42brehautgtrak: managing the mess that the python 'model' can create becomes dramatically more cumbersome in the long term even if it seems easier in the short term
17:43gtrakbrehaut, yea, those systems are living in denial of the inherent complexity
17:43brehautgtrak: ever installed PIL (the python imaging library)?
17:43gtraki never really had to deal with it, except by noticing just how wrong it was :-), i'm sure it's a nightmare
17:44apexi200sx1brehaut: Yeah I been through the book seven languages in seven weeks, so had a cursory overview of a fair few languages just not used them in anger, my shortlist has been Clojure and Erlang to learn in detail next (depending on the problem I want to solve)
17:44brehautPIL seems to have magic in its packaging that means you cant easily predict what the top level namespace will be (none, PIL, Imaging)
17:45apexi200sx1brehaut: so what was your preferred language before Clojure showed up a few years back
17:45brehautPython
17:46apexi200sx1brehaut: and what made you look into Clojure
17:46apexi200sx1just having a look at Clojurescript
17:46brehautwriting multithreaded code in python sucks :P
17:47apexi200sx1brehaut: multi threaded programming generally sucks
17:47apexi200sx1in any language :)
17:47brehautits quite managable in clojure and haskell
17:48dnolenapexi200sx1: Clojure basically goes out of it's way to make sure that multi threaded programming is actually pleasant.
17:48ChousukeI've been doing just a bit of coding in python and I wish I didn't have to deal with weird class stuff already
17:48apexi200sx1OK, more specifically, shared state multithreaded concurrency is a pain in most languages
17:49Chousukeclojure solves that too :P
17:49dnolenapexi200sx1: which is what Clojure was designed to address.
17:49dnolenor one of the things rather.
17:49Chousukethe problem with shared state in most languages is that everything is state
17:50Chousukein clojure, only certain things are state
17:50Chousukeso it's much easier to handle
17:50brehautapexi200sx1: my clojure programs are an order of magnitude more reasonable (ie, i can reason about them) than the equivalent python
17:50apexi200sx1hey, I am sold on the whole concurrency thing in Clojure, I am not sticking up for Python at all , I was just curious as I like Python even with its shortcomings but I have no allegiance to it
17:50apexi200sx1:)
17:50brehautapexi200sx1: and im a better and more experienced python programmer than clojure programmer
17:51ChousukeI don't hate python either but after programming clojure lots of things in python feel unnecessarily complicated :P
17:51technomancyI knew more about Clojure after one year using it than I knew about Ruby after 5 years.
17:52apexi200sx1If I was tasked with writing a high performant highly concurrent server application then I would seriously look into Clojure or more likely Erlang
17:52Chousukethat might just be urwid though. (I'm working on a console interface for transmission)
17:53apexi200sx1Brehaut: thanks for the insight
17:53apexi200sx1brehaut: the only thing that has put me off Clojure is the association with Java
17:54brehautapexi200sx1: the jvm is an incredible platform
17:54gtrakapexi200sx1, that's kind of why it was created in the first place
17:54dnolenapexi200sx1: Clojure is also good at all the simpler programs that you would use Python for (I also used Python for a while). Admittedly it's not great for scripting, but for that you have ClojureScript.
17:54brehautapexi200sx1: i dont tihnk you can beat it for server applications
17:55apexi200sx1brehaut: not to get into a language war, but Erlang is also worth a look in the server side department, the whole platform from the ground up was built with concurrency in mind
17:55Chousukeurwid's signal system in particular is weird. I can't just send signals and have their registered callbacks called nicely; for some reason urwid requires you to register every class that can send signals :P I'm sure there's a reason for that but it's not documented anywhere as far as I can tell.
17:55brehautapexi200sx1: erlang is a really impressive system
17:55gtrakis there a good article on message passing vs shared-state immutable concurrency?
17:56gtraki haven't used erlang, but my gut says the overhead of its model would be too annoying for most cases
17:56brehautapexi200sx1: but if you are not writing distributed systems, then it makes some decisions that are going to work against you
17:56apexi200sx1brehaut: true
17:56brehautive dabbled in erlang
17:56apexi200sx1anyway, basically what I am currently needing to write is a browser delivered client app that communicates with a webserver :(
17:56brehautthe biggest complaint i have is that actors model can cause youto create really brittle architectures
17:57gtrakbrehaut, do you get transactions?
17:57brehaut(that and the prolog derived syntax is a bit quirky, but thats just syntax)
17:57Chousukegtrak: shared state means reading values doesn't require message passing so many things are easier
17:57apexi200sx1hence the Pyjamas (pyjs) thing, but there are still a few issues with language support and so I was wanting to look into how difficult it would be to get my head around the translator :)
17:57brehautgtrak: i never got to OTP but the actors model doesnt provide them
17:57Chousukegtrak: but on the other hand it doesn't work with distributed systems
17:57gfrederi1ksso I create a deftype class to be called in a Class.forName("...") style from java. When java calls it, the method errors as the namespace hasn't been loaded. So I added a (require 'my.ns) call inside the method of the deftype. Is this the cleanest way to handle it?
17:57gtrakChousuke, why couldn't it?
17:58Chousukegtrak: you can't "just read" memory that might be on another computer over the internet
17:58apexi200sx1brehaut: why you say the actor model can cause you to create brittle archtectures
17:58Chousukegtrak: I mean, you could try but the result would be a mess
17:58brehautapexi200sx1: its not composable
17:59gtrakChousuke, yea... still i think it's better to opt-in for this sort of thing
17:59dnolenapexi200sx1: have you played much with ClojureScript? IMO, it's one of the best compile to JS options if you're looking for something more sophisticated then CoffeeScript
17:59gtrakif you want messages, use a queue
17:59brehautapexi200sx1: actors can be reasoned about easily enough, but changing an existing actors system to incorporate new requirements can be exceedingly difficult
18:00Chousukegtrak: yeah. Java has libraries for distributed computing I'm sure :P
18:01apexi200sx1dnolan: the thing is that Clojurescript although cool, seems to be just a langauge. Pyjamas (for python) is a Python implementation of GWT and has widget sets and DOM manipulation library, it also abstracts away browser differences etc. which from what i can gather clojurescript isnt
18:01apexi200sx1*clojurescript is just a clojure to javascript compiles/translator
18:01gtrakapexi200sx1, well, you get google's closure libs built-in, though I've had a hard time to figure it out
18:02dnolenapexi200sx1: ClojureScript ships with Google Closure which has almost all of that stuff.
18:02brehautapexi200sx1: 'just a language' is a strength
18:04apexi200sx1brehaut: I am not criticising it, just sayng that for me it probably isn;t a reason to learn clojure, and probably isn;t comprehensive enough for my needs regarding web development but things may change in future
18:04brehauti just dont believe in silver bullets
18:04gfredericksbrehaut: silver bullets believe in you
18:05gtraklast time i checked out pyjamas, it looked rough
18:05brehautgfredericks: this is suddenly very theological
18:05gfredericks:)
18:05apexi200sx1gtrak: you are correct, you have to REALLY want to get the thing working sometimes
18:05apexi200sx1:)
18:06gfredericksI'm excited to see the sorts of abstractions that clojurescript can create for browser development
18:06brehautgfredericks: im particularlly looking forward to something for async
18:06apexi200sx1but once you have hacked it a bit, it is way less painful than the Javascript/CSS/HTML/DOM/Browser incompatibility nightmare alternative. GWT is more comprehensive and polished, but you write 5 time as much code, cos its java
18:07apexi200sx1a Clojure GWT type thing might be interesting though
18:07gtrakclojure writes straight to bytecode though, that might be really hard to do
18:08brehautring ecosystem on the server + clojurescript on the client written as seperate server and client components without magic ftw
18:08apexi200sx1gtrak oh yeah it isn;t possible as it stands, you can;t use anything but Java in GWT, not Jython JRuby or anything
18:08apexi200sx1anyway I will stop hijacking the this CLOJURE channel
18:08apexi200sx1:)
18:08gtrakshun the nonbeliever... shun..
18:09apexi200sx1:)
18:10gfredericksbrehaut: I'M looking forward to being able to write fun algorithms for a browser in a decent language.
18:10gfredericksdecent == "has integers"
18:12apexi200sx1It is also annoying though that mobile devices have to be programmed in crummy languages (android java) iphone (Obj C) - or you can use c# using monotouch/monodroid. Why not Clojure or Python. It seems all the coding I wanna do (web and mobile) you have to use shit languages or jump through hoops
18:12gtrakwell, clojurescript is good for that too
18:12dnolenapexi200sx1: you can program most mobile devices with JavaScript - thus again ClojureScript
18:12gtrakandroid's java is too weak
18:12dnolenapexi200sx1: for iOS you have JSCocoa which proper full bridging to Obj-C apis.
18:13gtrakphonegap
18:13dnolenapexi200sx1: I'm assuming similar things exist for Android JS.
18:14brehautgfredericks: modern javascript implementations do have a distinction between integer and floating point; they just happen to pretend they dont with the Number type :/
18:15gfredericksbrehaut: well that's the first I've heard of it
18:15brehautgfredericks: im more interested in a map type that has more than string keys
18:15gfredericksbrehaut: in any case even if that objection is met the stack of objections is still a mile high :)
18:16brehautgfredericks: most definately :)
18:17llasramAny language with both '==' and '===', where the main difference between the two is that the former broken <something> by me!
18:17llasrams,broken,is broken is,
18:18technomancysad fact: most language designers have never read Henry Baker's "Equal Rights for Functional Objects"
18:18gfrederickshow about "you need a 3rd party library just to tell the difference between its built in data types"
18:18brehautgfredericks: huh?
18:18gfredericksobjects, arrays, functions...
18:19brehautit has operators for that. two of them
18:19gfrederickseh?
18:19brehautgfredericks: typeof and instanceof
18:19gfredericksand they act funny
18:19brehauttypeof tells you the primative type of somethng, and instance of does a prototype comparison
18:19llasramOooh -- I knew that being too lazy to stop supporting the ACM's anti open-access policies would come in handy some day
18:19brehautof course :P
18:21gfredericksbrehaut: underscore's version is: toString.call(obj) == '[object Array]';
18:21gfredericksI couldn't say why but I'm sure there's a good reason
18:21gfredericksin one sense
18:22brehauthuh. weird
18:22gfredericksmaybe the root cause of all that is just that you don't get to pick the version of JS your code runs on, for client stuff
18:24tolstoyIf you "lein swank" and then M-x slime-connect and get a "happy hacking" message, what's wrong if the repl buffer never shows up?
18:24tolstoyCan't seen anything revealing in *Messages* or *slime-events*.
18:24technomancytolstoy: slime has a separate slime-repl elisp package
18:25tolstoytechnomancy: Ah, okay. Was working yesterday, I'll check that out.
18:25tolstoyMight be because I'd tried clojure-jack-in yesterday.
18:27gtrakwhat's the difference between clojure-jack-in and slime-connect?
18:29tolstoyAlas, installing slime-repl didn't work. Hm.
18:30llasramgtrak: the latter connects an existing slime to a running swank server. The former bootstraps slime, launches a swank server, and connects to it
18:30gtrakah I see
18:33mtm_technomancy: I wrote a snippet of elisp that will let you know if a TCP port is available
18:44tolstoyWhen I call a function (via slime repl) with a number (do-something "foo" 12) and get something like "cannot cast to java.lang.Number", is there something I should be looking for?
18:44tolstoySome invisible float in there somewhere?
18:46gtrak,((fn [x] (+ x 1)) "hello")
18:46clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
18:46gtraklike that?
18:47tolstoyI must have renamed something and created a collision, I guess.
18:57todunI see somewhere that doing this is a problem (println "Hello" "World"). However, it runs fine in the repl and it looks ok to me. Am I missing something?
19:00joegallowhat would be the problem?
19:01dakrone,(println "Hello" "World")
19:01clojurebotHello World
19:16apexi200sx1OK, just watched the Rich Hickey talk on Clojurescript. Very interesting, especially considering integration with the Google Closure tools
19:21todunjoegallo: thant's what I'm trying to find out.
19:39ThreeCupsnoob question: Is there a way in the std lib to copy fields from one map into another. I want to do something like (assoc m (key-values [:key1 :key2] {:key1 1 :key2 2 :key3 3})) where m would end up with keys :key1 and :key2 and values for each key (plus whatever was in m to begin with)
19:40ThreeCupsActually, not m, but the map that assoc returns
19:40ibdknoxmerge and select keys
19:40ibdknoxthough I think there's probably a more clever way to do it
19:41ibdknox,(doc select-keys)
19:41clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
19:41ThreeCupsibdknox: Thanks
19:41ibdknox,(let [orig {:a 1 :b 2}] (merge orig (select-keys [:c :g] {:c 3 :d 4 :g 5})))
19:41clojurebot{:a 1, :b 2}
19:42ibdknoxhm
19:42ibdknoxoh
19:42ibdknox,(let [orig {:a 1 :b 2}] (merge orig (select-keys {:c 3 :d 4 :g 5} [:c :g])))
19:42clojurebot{:c 3, :g 5, :a 1, :b 2}
19:58aperiodic$findfn "foo" "bar" "foo bar"
19:58lazybot[clojure.core/print-str]
20:01ThreeCupsone more: I want to use doseq over two sequences. But I only want to see each value once. E.g. (doseq [v1 [1, 2] v2 [3, 4]] (println (str v1 " " v2))) prints "1 3\n1 4\n2 3\n2 4\nnil". But I only want to see "1 3\n2 4\nnill". Is there an easy way tot do this?
20:01brehaut,(doseq [[a b] (map vec [1 2] [:a :b])] (prn a b))
20:02clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$vec>
20:02ibdknox,(doseq [[v1 v2] (map list [1 2] [3 4])] (println v1 v2))
20:02clojurebot1 3
20:02clojurebot2 4
20:02ibdknoxbrehaut: bwhaha
20:02brehautibdknox: curses!
20:03ThreeCupsYou guys rock! Thanks. Let me say that I've spent time in the Scala IRC as well, and I definitely prefer this one when I'm learning a new language
20:09brehautibdknox: how is korma progressing?
20:09ibdknoxbrehaut: on track for my intended Conj release :)
20:10ibdknoxbrehaut: mostly just finishing up documentation now
20:11brehautexcellent :)
20:18technomancynothing showcases the value of Clojure metadata like implementing a help system
20:21ibdknox:)
20:31tolstoytechnomancy: Is there a way to get JVM args to a "lein trampoline run" ?
20:32technomancytolstoy: hmm... if JVM_OPTS and :jvm-opts are ignored that would be a bug
20:32tolstoyJAVAOPTS="blah" lein trampoline run ;; doesn't seem to work. Nor :jvm-args in project.clj.
20:32tolstoyAh, maybe I misspelled javaops.
20:32technomancyJAVA_OPTS should be a backwards-compatibility alias for JVM_OPTS
20:32technomancybut definitely open a bug for :jvm-opts
20:34TimMctolstoy: :jvm-args or :jvm-opts?
20:34tolstoyOk, JVM_OPTS definitely works. I'll double check the :jvm-opts thing. (Using jvisualvm to check this stuff out.)
20:34TimMcyou and technomancy wrote different things
20:34tolstoyI'm using jvm-args. Is it opts?
20:34technomancyyeah, it should be opts
20:34tolstoy:jvm-opts
20:35tolstoy:jvm-opts ["-Xmx1g" "-server"]
20:36tolstoyMan, oh, man. I've got a memory leak in a most confusing way. Argh! Maybe clojure laziness is tricking me.
20:36TimMctolstoy: Holding onto the head of a seq, maybe?
20:37tolstoyNo idea. Can't see where I'm doing that. Might be that I'm generating way too much garbage (big byte arrays).
20:40tolstoySpawning a bunch of threads that send byte arrays to a web service. All of a sudden heap spikes all the way to the ceiling. Anyway, it's something I'm not used to debugging.
20:40tolstoytechnomancy: I sure enough can't get the jvm-opts to make it through trampoline. Issue on github?
20:40technomancytolstoy: fer shure
20:48ibdknoxI'm having a brain failure. What is the correct way to format a number to two decimal points?
20:48brehauttwo decimal places?
20:48ibdknoxyes
20:49brehaut%.2f ?
20:49brehaut,(format "%.f" 1.234)
20:49clojurebot#<UnknownFormatConversionException java.util.UnknownFormatConversionException: Conversion = '.'>
20:49brehaut,(format "%.2f" 1.234)
20:49clojurebot"1.23"
20:49ibdknoxduh. thanks
21:14goodieboyIs there a built-in function that will take a map as data, then another map that remaps the keys? (remap {:id 1} {:id :ID}) => {:ID 1} ?
21:14dnolen,(require 'clojure.set)
21:14clojurebotnil
21:14dnolen,(doc clojure.set/rename-keys)
21:14clojurebot"([map kmap]); Returns the map with the keys in kmap renamed to the vals in kmap"
21:15dnolengoodieboy: ^
21:15goodieboydnolen: dang, very nice :) thanks.
21:15dnolen,(clojure.set/rename-keys {:id 1} {:id :ID})
21:15clojurebot{:ID 1}
21:16goodieboyperfect! I'm glad I asked before came up with some kludgy solution.
21:17brehaut,(into {} (map (juxt (comp {:id :ID} first) second) {:id 1})) ;)
21:17clojurebot{:ID 1}
21:17ibdknoxlol
21:18brehautjuxt!
21:18gfredericksif you didn't use juxt and comp, you're doing it wrong.
21:18ibdknox~juxt
21:18clojurebotjuxt is a little hard to grok but it's the best thing ever
21:18ibdknoxaw
21:18ibdknoxsomeone changed it
21:19ibdknox~amalloy
21:19clojurebotamalloy is <amalloy> just use juxt, it'll be great
21:19gfredericks~juxt
21:19clojurebotjuxt is a little hard to grok but it's the best thing ever
21:19gfredericks~grok
21:19clojurebotgrok is a little hard to juxt but it's the best thing ever
21:19brehautlol
21:21brehautthats it. we should call *** grok
21:21gfredericksthat rename-keys function oughta take a function instead of a map
21:22gfredericksmaybe
21:22gfredericks$findfn {:foo 12 :bar 13} name {"foo" 12 "bar" 13}
21:22lazybot[]
21:26brehautgfredericks: theres a special case of that particular instance as stringify-keys in clojure.walk
21:27brehauttheres also keywordize-keys
21:28gfredericksbrehaut: I know. That was merely the easiest example to try.
21:38Raynes&(+ 3 3)
21:38lazybot⇒ 6
21:38Raynes&(System/exit 0)
21:38lazybotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
21:38RaynesAll of that had purpose, I assure you.
21:38brehautmaking slides?
21:39Raynesbrehaut: You've got skills.
21:49TimMcRaynes: Am I on teeeveee?
21:49RaynesTimMc: Sadly, no. Screenshot was already taken. :(
21:49TimMcC'mon, you don't need to crop it so much...
21:49Raynes:)
21:49brehaut&((clojure.lang.Compiler/maybeResolveIn *ns* (symbol "eval")) '(+ 3 3))
21:49lazybot⇒ 6
21:50TimMcbrehaut: You can get even shorter with clojurebot.
21:50brehautRaynes: enjoy
21:50brehautTimMc: im sure you can with lazybot too :P
21:50Raynesbrehaut: When you find things like that, you probably shouldn't wait until I'm giving a talk to tell me about it. :p
21:51brehautRaynes: but i only just found it!
21:51RaynesHeh
21:51brehautespecially!
21:51TimMc,((resolve (symbol "eval")) '(+ 3 3))
21:51clojurebot6
21:51brehautlol
21:51TimMc&((resolve (symbol "eval")) '(+ 3 3))
21:51lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
21:51Raynesclojurebot isn't really going for real security there.
21:52RaynesNot that I'm exactly worried to death about it in lazybot.
21:52RaynesI do fix things when I see them though.
21:52RaynesAssuming fixing them keeps thing useful.
21:52TimMcWhy is eval restricted?
21:53brehautRaynes: you know about Schneier's Law ?
21:53Raynes$google schneier's law
21:53TimMcThere are already Java sandboxing restrictions on filesystem access, etc.
21:53lazybot[Schneier on Security: "Schneier's Law"] http://www.schneier.com/blog/archives/2011/04/schneiers_law.html
21:54brehautdoctrow's revision reads better than the original i think
21:54Raynesclojail uses the JVM sandbox. A good part of my talk is emphasizing that the JVM sandbox keeps your computer safe while clojail is focused on keeping the state of your evaluation context safe.
21:54brehautsensible
21:55TimMcSo... eval could be used to mess up the environment for other users.
21:55brehaut&*clojure-version*
21:55lazybot⇒ {:major 1, :minor 3, :incremental 0, :qualifier nil}
21:55brehautwith more difficulty now ;)
21:55TimMcI think I saw someone do that with one of the bots at one point.
21:56TimMcbrehaut: Right! Someone rebound a var or somesuch.
21:56RaynesMan, everything can be used mess up the environment for others.
21:56RaynesI'm surprised someone hasn't broken it with println yet.
21:56TimMchaha
21:56brehautlol
21:56TimMc,((resolve (symbol "eval")) '(def random-number 17))
21:56clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:57RaynesJust got denied by the SANBOX
21:57TimMcindeed
21:57TimMcwhich is different from the SANDBOX
21:57RaynesYep.
21:57brehauta cthulhu player will tell you that having a safe place to store your SAN is very important
21:58TimMcHas def been redef'ed?
21:59RaynesYou can't redef def.
21:59TimMcOh right, compiler prim.
21:59TimMcI KNEW THAT
23:14adeandradeHey everybody. Sorry to bother but can someone explain me why this works (map #(vector :p %) '(1 2 3 4 5)) but this doesn't (map #([:p %]) '(1 2 3 4 5)) ?
23:15RaynesYour anonymous function in the second example is the equivalent of (fn [x] ([:p x]))
23:16Raynes#() wraps what is inside of it in parens, calling it.
23:16RaynesSo it is trying to call a vector as a function, but vectors as functions take more than 0 args and thus you get an exception.
23:16Raynes&([])
23:16lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector
23:17RaynesThe reason the error message seems bizarre is because vectors actually *are* functions, but they take an argument. ##([1] 0)
23:17lazybot⇒ 1
23:17RaynesIn this case, it isn't getting an argument.
23:19adeandradeUhmm I don't fully understand, let me run some tests in the repl to see if I get it. Thank you.
23:19Raynesadeandrade: #([:p %]) = (fn [x] ([:p %]))
23:21adeandradeYeah.. but how can I use [] as a function?
23:21RaynesYou don't want to here.
23:21RaynesI was more confusing than I should have been.
23:22Raynes&(map #(vector :p %) [1 2 3 4 5])
23:22lazybot⇒ ([:p 1] [:p 2] [:p 3] [:p 4] [:p 5])
23:22Raynesadeandrade: ^ This is what you want.
23:22RaynesOr, ##(map (partial vector :p) [1 2 3 4 5]), either of these will do.
23:22lazybot⇒ ([:p 1] [:p 2] [:p 3] [:p 4] [:p 5])
23:23brehautor ##(map #(-> [:p %]) [1 2 3])
23:23lazybot⇒ ([:p 1] [:p 2] [:p 3])
23:23Raynesbrehaut: Are you trying to kill the poor guy?
23:23aperiodicadeandrade: a vector is also a function that takes an index, and returns the thing at that index
23:23RaynesBut in this case, that isn't what you want.
23:23brehautRaynes: thats the 'i read joy of clojure' version
23:23adeandradeYes I got it.. but now I'm wondering how [] can get used as a function. Shouldn't the reader understand it is a data structure and treat it as one?
23:24aperiodic,([:foo :bar :baz] 1)
23:24clojurebot:bar
23:24adeandradeohh
23:25adeandradeso by calling it like #([]) it thinks I'm asking for a location given a key?
23:25aperiodicthe other way around (a member given a location), but more or less
23:26aperiodicsince you didn't give it a location, it threw the arity error (arity refers to the number of arguments a function takes)
23:26aperiodicmake sense?
23:27adeandradenow I get it
23:27adeandradeyes now it does
23:27aperiodiccool!
23:29adeandradethank you everyone, I'll use the (vector) solution, but I'm gonna find more about your suggested solutions using -> and partial
23:29aperiodicbrehaut: the arrow macro? really?
23:29brehautaperiodic: joy of clojure!
23:29adeandradelol
23:30ibdknoxnooooooooooooooooooooooo
23:30ibdknoxgithub is down
23:30brehautthats a prety great 500
23:31ibdknoxbut, but... I need it.
23:32aperiodicbrehaut: i mean, i love the arrow macro, but...
23:32aperiodicpoor octocat
23:33brehautaperiodic: footnote 14, page 102 of joy of clojure ;)
23:34aperiodicbrehaut: shamefully still need to pick that up
23:34ibdknoxand we're back
23:35Raynesibdknox: I use bitbucket for my talk.
23:35RaynesBecause it has free private repositories. :>
23:35ibdknoxbut it's not as pretty
23:35ibdknoxand it's missing the octocat.
23:35RaynesAgreed.
23:35ibdknox-1000
23:35RaynesRecognized.