#clojure log - Jul 25 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

1:18 Havvy: How do you get a random element out of a set?

1:31 technomancy: Havvy: (rand-nth (vec myset)) might be best

1:35 Havvy: Yeah, I ended up going with that...is there a reason sets don't come with an assoc and rand-nth by itself?

1:37 technomancy: assoc takes three args, so it doesn't make sense for sets. I would argue that dissoc should work on sets instead of making folks use disj, but I can see the argument for parallels.

1:37 rand-nth doesn't work because nth doesn't work

1:37 nth doesn't work because it's not ordered.

1:38 Havvy: I meant the functionality more than the individual function names;

1:40 technomancy: rand-nth relies on nth working

1:41 Havvy: So there is nothing more efficient for sets than (conj (disj set old-val) new-val)?

1:41 technomancy: that's just how it's implemented

1:41 Havvy: technomancy: Yeah, it's a seq function.

1:46 technomancy: I imagine any kind of random-chooser on sets would have to do the moral equivalent of converting it to a vector first anyway

1:47 Havvy: Eh, true.

1:48 hiredman: well, the set sits on some kind of tree structure, a random walk of that structure would get you a random item

1:55 technomancy: maybe so

3:03 neotyk: Morning everyone!

3:14 dbushenko: hi all!

3:22 bobnormal: not exactly a throbbing hub of intellectual exchange, is it

3:23 tufflax: this? it is! not just right now :)

3:25 s/not just/just not/

3:25 lazybot: <tufflax> this? it is! just not right now :)

3:26 tufflax: :P

3:34 ibdknox: hey guys, for those of you doing webdev. I just released the 1.1.0 version of noir with a full set of concept docs

3:34 new docs here: http://www.webnoir.org/tutorials

3:36 ariman: nice design

3:48 hanDerPeder: ibdknox: Congrats! looks really interesting

3:48 ibdknox: ty ty

3:49 now that that's out, I can start coming up with my client side framework in cljs ;)

3:49 it'd be pretty cool to have a completely integrated webstack like that

3:51 dbushenko: does it support heroku?

3:54 hanDerPeder: http://thecomputersarewinning.com/post/clojure-heroku-noir-mongo

3:56 ibdknox: it should work pretty much anywhere

3:56 elastic beanstalk

3:56 heroku

3:56 anything with java on it

4:25 ejackson: Happy Monday folks.

4:30 Fossi: oh yeah

4:30 finally

4:30 waited all weekend

4:34 ejackson: Yes now I get to put down Clojure and pick up Matlab.

4:40 maacl: Has anyone been able to get the Convex Hull ClojureScript demo (http://bit.ly/qP8alt) to work? I just get two empty text boxes.

4:48 ibdknox: works fine for me in chrome

6:13 liquidproof: hello guys, what would be the best way to execute a function periodically, say, every 30 seconds or so?

6:15 ejackson: put it in a future, with a (do (my-function) (thread/sleep 30000)) might work.

6:15 just make sure you keep a handle on the future so you can cancel it

6:15 liquidproof: alright, i'll take a look

6:15 thanks

6:16 ejackson: you'll also want to use a ref type to store any output

6:16 liquidproof: why ref?

6:16 why not, say, agent?

6:16 ejackson: sorry, i meant any reference type

6:16 being lazy

6:16 liquidproof: haha, np

6:34 volton: Hi, why is that a legal expression?

6:34 ,(Integer/MAX_VALUE)

6:34 clojurebot: 2147483647

6:37 ejackson: because MAX_VALUE is a static in the Integer class

6:38 volton: So it behaves both like function and like a constant?

6:39 ejackson: ah, I missed the ()

6:39 terom: Classname/staticfield expands to (. Classname staticfield)

6:55 Pisketti: ~

6:57 scottj: How come the clojurescript repl dies on any error and is there an option to disable that?

8:19 volton: As a beginner I find that quite confusing because Integer/MAX_VALUE behaves like nothing I have seen in Lisp before

8:21 opqdonut: how?

8:21 volton: well (Integer/MAX_VALUE) indicates that it si a function

8:22 and this behaves like a constant:

8:22 ,Integer/MAX_VALUE

8:22 clojurebot: 2147483647

8:22 volton: am I missing something?

8:23 opqdonut: fields and methods can look the same in clojure

8:23 it's really just a convenience

8:23 volton: okay

8:23 opqdonut: weirdly the (Classname/staticField) case is not listed on http://clojure.org/java_interop

8:24 cemerick: It's definitely not idiomatic.

8:25 volton: this may help you:

8:25 * cemerick ,(macroexpand '(Integer/MAX_VALUE))

8:26 cemerick: &(macroexpand '(Integer/MAX_VALUE))

8:26 lazybot: ⇒ (. Integer MAX_VALUE)

8:26 volton: oh thanks

8:26 cemerick: The actual operator is `.`, the interop special form.

8:27 I suspect the fact that (Integer/MAX_VALUE) and Integer/MAX_VALUE might just be vestigial.

8:27 the fact that they are the same, that is

8:27 terom: (Classname/staticField) and (Classname/staticMethod) are indistinguishable, both expand to (. Classname ...)

8:28 (the latter being a static method with no arguments)

8:28 cemerick: right; I forget which "wins" in such cases

8:29 terom: So it's kind of coincidence that (Classname/staticField) works and you should not use it.

8:30 volton: In fact I find it quite discomforting that it works

8:32 In "The Joy of Clojure" they first use (+ Integer/MAX_VALUE Integer/MAX_VALUE)

8:32 And then they use (unchecked-add (Integer/MAX_VALUE) (Integer/MAX_VALUE))

8:33 That's what got me confused

8:34 terom: That's a little confusing yes... since (unchecked-add Integer/MAX_VALUE Integer/MAX_VALUE) works as well...

8:36 volton: indeed

8:49 terom: http://joyofclojure.com/errata/ does not list that, maybe one could add a comment there.

9:10 ariman: i have table with many dynamic records (they are creating by (map)) and i want to create additional column with incrementing value. How can i do incrementing value?

9:11 http://paste.org.ru/?5p3y42 code.

9:25 ffailla: ariman: would map-indexed work?

9:27 ariman: ffailla yes, i'm working at it.

9:28 *on, sure

9:31 wjlroe: Anyone know why with the latest swank-clojure + slime + slime-repl emacs packages installed, I get no repl when I do a `slime-connect` ?

9:32 ariman: solved.

9:32 scottj: wjlroe: are you installing swank-clojure out of elpa?

9:32 wjlroe: scottj: yeah

9:32 scottj: I don't think you're supposed to, I think you should be running swank from lein

9:33 wjlroe: scottj: well I'm running `lein swank` on the cmd lie

9:33 s/lie/line

9:33 lazybot: <wjlroe> scottj: well I'm running `lein swank` on the cmd line

9:33 scottj: wjlroe: in that case I don't know

9:34 is your swank in lein up-to-date?

9:34 wjlroe: scottj: I'll check...

9:41 tufflax: How do I use a gen-class from another clojure file/namespace? I required it but (new gen-class-name) does not work.

9:42 ariman: is there function for checking is number even or not?

9:42 tufflax: even?

9:42 raek: tufflax: you need to import it just like a java class

9:42 tufflax: ok hm, i saw some examples using require, but ok...

9:42 raek: also you need to AOT compile the namespace

9:43 tufflax: ok

9:44 ariman: ok, im just developed it :)

9:44 raek: import does only introduce a shorthand name for the class, so you can use the full name instead if you want to

9:44 ariman: such a complicated case

9:44 raek: ,even?

9:44 clojurebot: #<core$even_QMARK_ clojure.core$even_QMARK_@e3990b>

10:00 tufflax: What does "namespace my-ns not found after loading my_ns" mean?

10:01 ejackson: tufflax: probably that you misnamed your namespace

10:02 if you story the file as my_ns.clj it must be namespace my-ns

10:02 note the _ and -, Java gets persnickety about that

10:02 tufflax: let me see...

10:03 ariman: how can i do some list like http://paste.org.ru/?s9j7ph ?

10:04 lnostdal-laptop: ..perhaps it's just random, but any reason why await doesn't return the agent? .. NIL seems like a useless return value

10:04 tufflax: well it says "namespace game.user_interface not found after loading /game/user_interface" like it expects it to have the name game.user_interface

10:04 lnostdal-laptop: oh, it can take several agents ...hm

10:05 ..and await1 was what i was looking for ....... :)

10:06 raek: tufflax: sounds like you have a typo in the ns form

10:06 the namespace name and the file name have to match

10:07 tufflax: they do, but the ns has - where the filename has _

10:08 ejackson: that is as it should be

10:08 raek: hrm, but why does it say "namespace game.user_interface"? I would expect "namespace game.user-interface"

10:09 tufflax: yes i find that strange too

10:09 raek: and this happens when you do (require 'game.user-interface) ?

10:10 tufflax: (:require (game [user-interface :as ui])) in another ns

10:11 raek: try removing any fiels in the classes/ directory

10:11 *files

10:12 tufflax: was just about to, let's see

10:14 ok now I get "namespace game.user-interface not found after loading /game/user_interface" the underscore turned into a dash...

10:15 raek: and in src/game/user_interface.clj you have (ns game.user-interface ...)?

10:16 tufflax: oh now it works, i changed the name when trying different things

10:16 thank you

10:16 so the old class file was the problem

10:53 ejackson: tufflax: aaaah, interesting.

11:10 theignorati: I want to create a function that accepts one or more parameters, and uses them as parameters for an overloaded method on a java object that accepts 1, 3 or 4 parameters, how would I do that?

11:12 raek: theignorati: (defn foo ([x a] (.foo x a)) ([x a b c] (.foo x a b c)) ([x a b c d] (.foo x a b c d)))

11:13 the methods are separate methods even though they have the same name

11:13 theignorati: ok I thought I was going to have to do something with [&

11:13 thanks

11:14 raek: also, vadiadic functions in java correspond to functions taking an array as the last argument on the JVM level

11:16 so to call "Object bar(Object x, Object... y)" you need to do (.bar x (into-array y))

11:16 * (.bar the-object x (into-array y))

11:17 theignorati: so for that method you would define a function like this (defn bar [x y & args] (.bar x y (into-array args)))

11:19 theignorati: cheers :)

11:19 dont think I've ever used a variadic function in java

11:19 gtrak: if I compile clojurescript from clojure, will it be exposed to google's closure library, or would I need to include that in my html?

11:21 raek: I think if you use the advanced mode, all your code including the libraries will become a single file

11:22 gtrak: ah, neat, can I store that JS string in a map somewhere? If I'm in a WAR file, I don't think I can have files

11:24 raek: you should be able to serve static files (e.g. your script) with servlet containers

11:24 maybe not with jetty they way you launch it from clojure when doing development

11:28 gtrak: if I could keep the compiler running and just cache everything in memory, it shouldn't be too bad, it won't scale to a site with lots of pages for sure

11:39 wjlroe: Slime+Emacs+Clojure is just not working for me now. Any way I try. If I do "lein swank" and connect from emacs "slime-connect" it error with http://pastebin.com/4RvZa0JQ (slime-clj is installed from ELPA). If I try "clojure-jack-in" from emacs, I just get an error that lein is not found (and I don't know how to configure the path for the bash process emacs spawns to run that...).

11:40 raek: slime-clj/swank-clj are new libraries that should not be confused with slime/swank-clojure

11:41 wjlroe: raek: is there a guide for using slime-clj/swank-clj ?

11:41 I've tried everything I can find and it's all broken

11:41 raek: if you want to use clojure-jack-in, then the latter is what you want to use

11:41 wjlroe: This all used to work, but today it's all broken

11:41 raek: I have never used the -clj ones

11:41 hugod: swank-clj is now ritz, to try and reduce the confusion

11:42 raek: oh, great

11:42 wjlroe: slime/swank-clojure is what I've been using for ages - starting swank from leiningen. But today that's just not working at all

11:42 raek: wjlroe: maybe having the -clj ones at the same time is causing a conflict?

11:42 hugod: wjlroe: remove slime-clj

11:42 wjlroe: raek: hugod: ok I'll try that

11:43 raek: hugod: you are the author of the -clj libs, right?

11:43 hugod: yep

11:43 raek: wjlroe: you probably want to avoid the swank-clojure *elisp* package too

11:43 hugod: raek: well, ritz started as a refactored swank-clojure

11:44 raek: and remove any slime versions installed through the package manager of your OS

11:44 wjlroe: raek: there are none - OS X

11:45 raek: okay, just checking :) I've seen lots of people installed the slime debian package

11:45 a common source of conflicts

11:45 wjlroe: sure

11:46 raek: wjlroe: this is a good tutorial: http://technomancy.us/149

11:46 also make sure you don't have multiple versions of swank-clojure on the classpath at the same time

11:46 wjlroe: raek: I think it's working! It must have been the clusterfuck of all the different clj libraries in emacs that messed it up

11:46 raek: e.g. one from :dev-dependencies and installed as a plugin

11:46 wjlroe: No offense to the -clj libraries intended

11:56 with paredit, how do you fix mismatched parenthesis? I have [somthing (blah ))] - can't delete that paren

11:57 ejackson: wjlroe: cut and paste :P

11:57 wjlroe: oh :(

11:57 oh ok

11:57 ejackson: which, in my experience, generally how i get mismatches in the first place :)

11:57 wjlroe: I thought you meant edit somewhere else and paste in...

11:57 ok cool

11:57 thanks

11:58 ejackson: oh no, just cut out the offender.

11:58 Scriptor: wjlroe: I like to keep this handy when using paredit: http://www.emacswiki.org/emacs/PareditCheatsheet

11:58 wjlroe: Scriptor: yeah was checking that out

11:59 Scriptor: hmm, but I guess that won't help with parens that are already mismatched

11:59 wjlroe: yeah - highlight and C-w does it

12:02 tufflax: Can I give a name to the class that I'm creating an instance of with proxy? :p

12:03 chouser: tufflax: nope, sorry

12:04 tufflax: you can discover its name at runtime if you'd like.

12:18 dbushenko: is there a way to define a private mutable java field with clojure?

12:18 without refs, etc.

12:19 ariman: is it not ok to compare two strings with "=" ?

12:19 dbushenko: e.g. I want to generate a JPA class and need normal mutable fields

12:19 ejackson: ariman: I should think so.

12:20 ariman: hm

12:26 raek: ariman: it is ok

12:26 chouser: dbushenko: deftype can do that

12:26 dbushenko: chouser: thanks, I'll have a look

12:27 ariman: raek strange, i don't get a positive result with .equals/=/even compare.

12:28 raek: ,(= "foo" (str "f" "o" "o"))

12:28 clojurebot: true

12:28 ariman: (def ddd [{:abs "a" :b "b"},{:abs "a" :b "b"}]) (defn ch [data toch] (if (= toch (data :abs)) (str toch (data :abs)) "no")) (map ch ddd "a")

12:28 ,(def ddd [{:abs "a" :b "b"},{:abs "a" :b "b"}]) (defn ch [data toch] (if (= toch (data :abs)) (str toch (data :abs)) "no")) (map ch ddd "a")

12:28 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

12:28 ariman: omg

12:29 btw this code returns false

12:30 hiredman: ,(seq "a")

12:30 clojurebot: (\a)

12:30 hiredman: ,(= "a" (seq "a"))

12:30 clojurebot: false

12:30 raek: let's see, (map ch ddd "a") is the same as (list (ch (first ddd) "a"))

12:31 hiredman: raek: no it isn't

12:31 raek: so only one element of ddd is processed. is this intentional?

12:31 hiredman: you forgot to call first on "a"

12:31 raek: right. replace "a" with \a

12:33 ariman: i think it doesn't matters

12:33 or not?

12:33 even that it should returns true

12:34 hiredman: ariman: it does matter you are comparing a string "a" to the character \a

12:34 raek: (dd {:abs "a" :b "b"} \a) --> (if (= \a "a") (str \a "a") "no") --> "no"

12:35 ariman: hmm

12:38 manutter: ,(map (fn [a b] [a b]) [1 2] [1])

12:38 clojurebot: ([1 1])

12:39 ariman: sorry guys i don't understand what should i do

12:39 pdk: (doc dd)

12:40 clojurebot: It's greek to me.

12:40 manutter: ,(= "a" ({:abs "a", :b "b"} :abs))

12:40 clojurebot: true

12:41 manutter: ariman: one thing you might want to do is (map #(ch % "a") ddd) instead of (map ch ddd "a")

12:41 raek: ariman: in your call (map ch ddd "a") you give map a sequence of maps (called ddd) and a sequence of characters (the characters in the string "a")

12:41 manutter: when you give a map two sequences, it iterates through both sequences one element at a time

12:41 raek: ariman: map takes one item from each collection you give it and calls the function on them

12:42 manutter: ,(map (fn [a b] (str a " and " b)) [1 2 3] "a")

12:42 clojurebot: ("1 and a")

12:43 manutter: ,(map (fn [a b] [a b]) [1 2] "a")

12:43 clojurebot: ([1 \a])

12:43 ariman: thank you

12:43 (map #(ch % "a") ddd) works

12:43 raek: if you want to call cc with the same "toch" each time, you should do something like what manutter showed you

12:44 also, when calling map with an anonymous function, consider for: (for [data ddd] (ch data "a"))

12:44 especially if the function has more than one level of parentheses

12:44 ariman: get it

12:45 raek: I prefer for because map+fn expressions idnents so ugly when they are large :-)

12:46 manutter: The caveat is if you have multiple sequences, for and map behave differently

12:46 ,(map (fn [a b] [a b]) [1 2] [1 2])

12:46 clojurebot: ([1 1] [2 2])

12:46 manutter: ,(for [a [1 2], b [1 2]] [a b])

12:46 clojurebot: ([1 1] [1 2] [2 1] [2 2])

12:48 pdk: [12:45] <raek> I prefer for because map+fn expressions idnents so ugly when they are large :-)

12:48 sounds like a job for some macros :p

12:51 tufflax: chouser: ok... I noticed that the name of a proxy I made was "user.proxy$java.lang.Object$0", how stable are they between runs? How much can I rely on them? :p

12:53 chouser: tufflax: IIRC, it's safe to rely on that name as long as these remain unchanged: the class and set of interfaces inherited, and the version of Clojure.

12:53 having said that, I'd be a little uncomfortable relying on the name being stable from one JVM run to the next. What do you need it for?

12:56 amalloy: pdk: a macro like...for?

12:57 tufflax: chouser I'm making a game, and there is this GUI lib that requires me to give the name of a Listener in the XML description of the UI. But then one can provide instances in the java/clojure code and it tries to match the name of the class to the name given in the xml, or something like that, im not totally clear on this :p

12:57 amalloy: hiredman: "SANBOX DENIED" doesn't have enough Ds

12:58 hiredman: DENIED

12:58 chouser: tufflax: yeah, if you actually need the name of the class outside the runtime (like in an xml file) I'd recommend genclass. It's sometimes a pain to set up, but not to bad to use and modify once you've got it working.

12:59 amalloy: chouser, tufflax: or deftype?

12:59 pdk: yeah

12:59 F is for for

12:59 and F is for effin amazing

12:59 amalloy: <3 for

12:59 * tufflax reads about deftype

12:59 chouser: amalloy: ah, good point -- if he doesn't have to inherit from a concrete class.

13:00 amalloy: chouser: do you want a pull request for data.xml, or is it governed by the same jira-based rules as monolithic contrib?

13:09 chouser: amalloy: same rules, so ticket + patch. ...except there is no data.xml jira project yet

13:09 amalloy: sigh. jira is so soul-crushing

13:09 chouser: or maybe I can give you commit access to the github repo

13:09 I'll ask.

13:09 amalloy: thanks

13:11 technomancy: the one good thing about jira: it encourages giving more people commit access to work around how annoying it is =)

13:31 ariman: sorry i can't find how i can use multiple conditions in if-else construction

13:31 amalloy: cond

13:32 or i guess you might mean and/or

13:32 ariman: yep

13:32 amalloy: yep what

13:32 ariman: and/or

13:33 manutter: ,(if (and (= 1 1) (> 3 2)) "yes" "no")

13:33 clojurebot: "yes"

13:33 amalloy: &(if (and (zero? 0) (zero? 1)) "two different numbers are zero!" "looks okay")

13:33 lazybot: ⇒ "looks okay"

13:33 manutter: ,(if (or (false? 0) (false? nil)) "At least one is true")

13:33 clojurebot: nil

13:34 ariman: ah, i completely forgot about notation, thx

13:35 manutter: (if (or (and (sequential []) (or (and (nil? x) (pos? 4) (or ... ah, ferget it

13:36 amalloy: &(if (every? zero? (repeatedly 3 #(rand-int 2))) "Three in a row!")

13:36 lazybot: ⇒ nil

13:57 hiredman: clojurebot: ping?

14:08 jcromartie: you killed clojurebot! you bastard!

14:11 amalloy: ~guards

14:11 clojurebot: SEIZE HIM!

14:11 amalloy: :(

14:11 oh it worked

14:11 haha i was all set to mourn

14:11 jcromartie: hah

14:11 clojurebot: ping?

14:11 clojurebot: PONG!

14:11 jcromartie: I see

14:11 amalloy: maybe he just has hiredman set on /ignore

14:13 ejackson: if he's going to show such spirit then perhaps we could get him to sort the ML...

14:13 amalloy: we should start a second, secret mailing list

14:14 Scriptor: no-blog-posts-allowed

14:19 hiredman: saw a java process taking ~90% cpu time, so I killed and restarted clojurebot, but of course that was the wrong process

14:20 * hiredman is still pumped to have 1.3 in clojurebot's sandbox

14:21 amalloy: hiredman: which one was it, out of curiosity?

14:21 hiredman: elasticsearch

14:21 ~search for jrockit

14:21 clojurebot: <#clojure:coopernurse> cemerick: agreed. the JVM seems to favor long running processes. redeploying seems like a decent route -- I guess I've just been bit by that in the past. perhaps I should take a look at jrockit

14:21 <#clojure:cemerick> or, use a VM that doesn't have permgen (jrockit is now free)

14:21 <#clojure:coopernurse> cemerick: oops, that's jrockit..

14:21 <#clojure:pjstadig> the JRockit Virtual Edition looks kinda cool

14:22 * amalloy makes a note that coopernurse is into jrockit

14:23 amalloy: hiredman: is it intentional that he doesn't include /me actions in his search?

14:23 hiredman: no idea, clojurebot may just ignore those in general

14:25 ah

14:26 actions use an :action key instead of :message and the indexing plugin does (when message ...)

14:27 gtrak: is sexpbot a thing of the past?

14:27 dnolen: ,*clojure-version*

14:27 clojurebot: {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}

14:27 ejackson: $botsnack

14:27 lazybot: ejackson: Thanks! Om nom nom!!

14:27 ejackson: gtrak: nope.

14:28 jcromartie: so there's only two bots here

14:29 I am always sad when I go to other language channels and there's no equivalent bot

14:29 like, there will never be a C#bot

14:29 dnolen: ,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))

14:29 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

14:29 dnolen: ,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1))))

14:29 clojurebot: "Elapsed time: 203.927 msecs"

14:29 dnolen: ,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))

14:29 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

14:29 dnolen: erg

14:29 amalloy: jcromartie: i don't see why not. ##java has a bot; it could be written in C# instead

14:29 dnolen: try lazybot!

14:30 gtrak: ejackson, well there used to be sexpbot, now there is lazybot

14:30 dnolen: &(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))

14:30 lazybot: java.lang.IllegalArgumentException: Unable to resolve classname: long

14:30 dnolen: heh

14:30 ,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1))))

14:30 clojurebot: "Elapsed time: 395.026 msecs"

14:31 ejackson: gtrak: i think its the same bot, dude.

14:31 gtrak: sneaky

14:31 amalloy: dnolen: new 1.3 feature, i guess?

14:32 ejackson: i can't seem to find any 'proper' docs on Google Closure library. Is there a javadoc, or some API overiew that I'm missing (barring the source)

14:32 TimMc: THere are always two Sith^W#clojure bots.

14:32 gtrak: I just bought the book

14:32 dnolen: amalloy: yeah

14:32 ejackson: the google docs are rather sparse

14:32 amalloy: i was just hoping to show off his automatic paren-correction

14:32 gtrak: ejackson, http://www.amazon.com/Closure-Definitive-Guide-Michael-Bolin/dp/1449381871/ref=sr_1_1?s=books&ie=UTF8&qid=1311618789&sr=1-1

14:33 amalloy: &(let [f (fn [a] (+ a 1))] (time (dotimes [_ 1e3] (f 1)))

14:33 lazybot: ⇒ "Elapsed time: 3.242758 msecs" nil ; Adjusted to (let [f (fn [a] (+ a 1))] (time (dotimes [_ 1000.0] (f 1))))

14:33 TimMc: &(identity 1e3

14:33 lazybot: ⇒ 1000.0 ; Adjusted to (identity 1000.0)

14:33 ejackson: gtrak: oh, I'd assumed that was compiler deepthinkery

14:34 gtrak: check out the ToC

14:34 TimMc: Interesting that it prints 1000.0 instead of 1e3. Makes sense, though.

14:34 amalloy: TimMc: sure. 1e3 is fixed by the reader

14:35 hiredman: ,1e10

14:35 clojurebot: 1.0E10

14:35 amalloy: har har

14:35 hiredman: if it takes long enough it will print in scientific notation

14:35 ejackson: gtrak: *SOLD* To the idiot with the ginger beard. Thanks.

14:36 hiredman: (we have a test fixture at work that times tests for each namespace and some of them print out in scientific notation)

14:37 gtrak: I was just in the midst of learning javascript when you guys had to go ahead and blow my mind

14:37 Hodapp: psssh, javascript

14:37 ejackson: welcome to Clojure

14:38 jcromartie: is there something wrong with ginger beards?

14:38 amalloy: hiredman: i hope you're timing in milliseconds, not seconds

14:38 TimMc: *ginger bread

14:38 hiredman: amalloy: me too

14:41 ejackson: jcromartie: they are highly correlated with gingers. Cant trust those people.

14:42 jcromartie: I'm no ginger, but I have a ginger beard

14:42 ejackson: naah, you're just still in the closet.

14:42 jcromartie: my brother is a ginger. he can't walk to his car without getting sunburned

14:43 ejackson: and he deserves it !

14:52 nickik: Hallo, im tring ClojureScript but if I want to start the repl i get "Error occurred during initialization of VM. Could not reserve enough space for object heap"

14:52 I just cloned the github repro and ran the bootstrap script

14:53 mrBliss: nickik: you probably don't have enough RAM available

14:53 chouser: Rhino is a hog -- eats memory and cpu

14:53 leeda: is there a built-in function that does this: (assoc x :a (concat (x :a []) [2]))

14:54 nickik: but if you just do script/repl it should just start a clojure repl right?

14:54 and that should work since i use normal clojure all the time

14:55 I have 1GB of free memory

14:56 phao: nickik, it is jvm

14:56 * phao trolling

14:56 manutter: nickik: I edited the file in script/repl and told it to use 768m instead of 2G -- it worked, but no promises.

14:57 (where "worked" means "booted to the user=> prompt without throwing the OOM exception")

14:58 nickik: java -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs' clojure.main

14:58 witch one is memory?

14:58 manutter: I changed both the -Xmx2G and -Xms2G

14:58 in my abysmal Java ignorance...

14:58 nickik: k

14:59 amalloy: chouser: sweet, thanks

14:59 Scriptor: heh, I just took those 2 flags out

14:59 nickik: @Scriptor do the simplest thing possible

15:00 amalloy: leeda: update-in

15:00 chouser: amalloy: eh? what'd I do?

15:00 amalloy: chouser: just got an email about push access to contrib repos

15:00 leeda: amalloy: thanks

15:03 amalloy: leeda: though using concat with vectors is a little bizarre

15:03 chouser: amalloy: oh, sorry -- didn't see that email yet. Yay!

15:03 leeda: amalloy: oh i should use conj right?

15:03 amalloy: leeda: conj, or into if you want to add multiple things

15:03 the classic way to do your example would be ##(update-in {} [:a] (fnil conj []) 2)

15:03 lazybot: ⇒ {:a [2]}

15:03 leeda: amalloy: thanks

15:06 chouser: amalloy: so, I'm not 100% sure I want to have the two modules

15:06 jcromartie: amalloy: what about: ##(merge-with concat {} {:a [2]})

15:06 lazybot: ⇒ {:a [2]}

15:06 amalloy: chouser: you mean, a prxml module plus the...whatever module you have already? i agree

15:07 jcromartie: ,(merge-with concat {:a [1 2]} {:a [3]})

15:07 clojurebot: {:a (1 2 3)}

15:07 leeda: jcromartie: nice

15:07 chouser: oh, sorry, no I mean a module that depends only on xml features provided by Java 1.5, and another module (for pull-parsing) that depends on a 3rd party lib (though it could actually just depend on java 1.6)

15:07 jcromartie: notice it returns a seq though

15:07 amalloy: jcromartie: don't use concat if you have vectors already

15:08 just merge-with into

15:08 jcromartie: ah, nice

15:08 even better

15:08 amalloy: chouser: oh, i haven't looked at the pull-parser stuff at all

15:08 jcromartie: ,(merge-with into {} {:x [2]} {:x [3 4]})

15:08 clojurebot: {:x [2 3 4]}

15:08 leeda: what would be the easiest way to only append the item if it's not already in the vector?

15:08 jcromartie: leeda: use a set :)

15:08 amalloy: leeda: use a set instead of a vector :P

15:08 chouser: amalloy: either way, I think the prxml stuff should go in the main module

15:09 leeda: ah, nice

15:09 amalloy: chouser: k. i just pushed it

15:10 jcromartie: ,(println "##(println \",(println \\\"woah\\\")\")")

15:10 clojurebot: ##(println ",(println \"woah\")")

15:10 lazybot: ⇒ ,(println "woah") nil

15:10 chouser: amalloy: thanks! I'll take a look at it tonight

15:10 jcromartie: oh not quite, eh

15:10 amalloy: i didn't add a test since i didn't want to deal with maven, but i suppose now that it's in "real" code i will

15:11 jcromartie: who wants to make a lazybot<-->clojurebot ping-ponging quine?

15:11 amalloy: jcromartie: tried and failed, hundreds of times

15:11 lazybot's arrow makes it hard, on purpose

15:12 jcromartie: arrow?

15:12 clojurebot: arrows is http://ro-che.info/ccc/12.html

15:13 amalloy: jcromartie: ⇒ ,(println "woah") nil ;; see that arrow in his output? if not, your client doesn't render unicode very well

15:13 jcromartie: ah right

15:13 yes I see it

15:14 amalloy: ,(#(% %) #(% %)) ##(#(% %) #(% %)) ;; you can get them to race though

15:14 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.StackOverflowError>

15:14 lazybot: java.lang.StackOverflowError

15:15 jcromartie: whoever wrote this should be slapped http://en.wikipedia.org/wiki/Arrow_(computer_science)

15:15 amalloy: jcromartie: never read any haskell wiki entries before? they usually look like that

15:16 jcromartie: I love the part "Note that <arrow symbol> defines a category of types, with the obvious choices for id and <a small circle>."

15:16 OBVIOUSLY

15:16 technomancy: the typesetting always gives it away

15:16 jcromartie: I mean, GOSH you freaking IDIOT!

15:16 ejackson: jcromartie: I'll give you 10 on the dollar that a ginger wrote that doc :P

15:17 jcromartie: I read once: "I want to learn Haskell but I don't know enough math"

15:18 ejackson: does anybody have a recommendation for a book on HTML5/CSS/JavaScript/DOM etc ? I have not done this stuff before, but it looks like now is an opportune moment.

15:21 triyo: Hmm don't think thats gonna be one book.

15:21 For Javascript you could read "Javascript, The good Parts"

15:21 http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742

15:22 ejackson: wow: Crockford finally digs through the steaming pile of good intentions

15:23 sounds a delight.

15:23 pjstadig: i guess i blinked or something, but ... is sexpbot now known as lazybot?

15:25 jcromartie: here's a tip: don't keep Visine next to superglue

15:25 triyo: ejackson: I went the Definitive guide route, the diff looks something like this when you remove the bad parts: http://nerdnirvana.org/wp-content/uploads/2009/09/javascript.jpg

15:25 ;-)

15:25 ejackson: LOL !

15:26 mjg123: Hi can someone help me understand why I can't use "recur" here https://gist.github.com/1104951 ?

15:26 amalloy: pjstadig: yeah

15:27 hiredman: mjg123: recur is not in the tail position

15:27 amalloy: mjg123: recur is only for defining algorithms that require no stack space

15:27 mjg123: recur is not in the tail position?

15:27 amalloy: because you plan to cons something onto the result of the recursion, you need to keep track of your place in the stack in order to do the consing when the sub-function returns

15:27 pjstadig: mjg123: the result of the "recur" is passed to cons which becomes the result of calculate

15:28 mjg123: because cons happens after

15:28 pjstadig: so cons is in the tail position, not the recur

15:28 mjg123: Ah I see

15:28 can this be easily converted to tail-recursion?

15:30 it seems not :)

15:31 nickik: @mjg123 not to fast my inet is slow

15:35 amalloy: mjg123: there are two reasonable choices if you want something that doesn't need stack space

15:35 (probably more than two)

15:35 you can do the classic transformation of keeping an accumulator, initialized to [], and conj onto that every time you recur

15:36 or you can rewrite it with ##(doc iterate)

15:36 lazybot: ⇒ "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"

15:36 mjg123: amalloy: the accumulator approach is like the 2nd one on that gist?

15:36 amalloy: uhhh, the second what?

15:37 mjg123: I added another code snippet to the gist

15:37 https://gist.github.com/1104951

15:37 hiredman: or use reduce?

15:38 amalloy: hiredman: right, if he's willing to add multiple copies of a coin at each step

15:38 pjstadig: untested code, but https://gist.github.com/1104978

15:38 hiredman: amalloy: huh?

15:38 amalloy: there was a discussion of this algorithm in here about a week ago, with me and dnolen and...someone else

15:38 triyo: thats the iteration version. First example is the leaner version

15:38 amalloy: hiredman: what is he reducing over? a list of all the coin denominations?

15:39 triyo: linear cannot be tail recursed

15:39 hiredman: amalloy: no idea, what is this doing?

15:39 mjg123: I'm using it as a coding problem at our FP club - it sounds easy but it's a great puzzle.

15:40 amalloy: hiredman: it looks like he's making change for an amount

15:40 and returning a seq of coins

15:40 triyo: mjg123: you can use loop/recure instead shift (recur ..) to the left.

15:40 mjg123: yes, eg (calculate [1 2 5] 9) => (5 2 2)

15:40 triyo: so it falls in the tail position.

15:41 hiredman: seems reducable to me, the only problem is lack of early termination for reduce

15:42 a solution using iterate may come out nicely, is there a reason to have a vector of coin denominations instead of a set?

15:42 amalloy: hiredman: you have to do the coins in largest=>smallest order or the algorithm doesn't work well

15:43 mjg123: Could be done with a set tho, just (apply max) when you make your choice of coin

15:43 amalloy: here are the solutions dnolen and i wrote last time: https://gist.github.com/1074857/0f32b3d64cd7641ef975f8fa6e08f26518a6cae4 and https://gist.github.com/1074808

15:44 mjg123: it's not a set because part II of the problem will be to make change from a given number of coins

15:44 (ie using what coins you have in your pocket right now, make 84)

15:45 dnolen: https://gist.github.com/1074818 is the last version I did, the shortest and fastest.

15:45 mjg123: wow that's great amalloy & dnolen

15:46 really good (and lucky) to see others' solutions

15:48 then part III, "using what coins you have in your pocket right now, make 84 and 26 and 13"

15:49 ejackson: aaaaaaah, the Closure Library cames with a demo directory !

15:50 sweet jumping jehova !

15:52 i can have clojure with an interface i want to look at !

15:53 hiredman: you mean emacs?

15:53 ejackson: curses !

15:54 Scriptor: ncurses?

15:55 ejackson: ndeed

15:55 now that was a MAN's interface. Before all those stupid butterflies.

15:58 phao: clojure is more like scheme or common lisp?

15:59 chouser: phao: probably slightly more like scheme. But different enough from both to count as it's own dialect of lisp.

16:00 * hugod sighs at being unable to use java.classpath

16:06 theignorati: does (read-line) not work when you run something with leiningen?

16:11 kjeldahl: Anybody know if leiningen outputs anything similar to cake.log when running threaded stuff with output in repl?

16:11 (after emacs clojure-jack-in in my case I guess)

16:12 hiredman: it goes to some buffer

16:14 kjeldahl: hmm, can't find anything

16:15 neotyk: Good evening everyone!

16:16 arohner: neotyk: http://www.total-knowledge.com/~ilya/mips/ugt.html

16:17 nickik: Having this error running script/repljs "Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: sun.org.mozilla.javascript.internal.Context, compiling:(cljs/compiler.clj:956)". did somebody have the same problem?

16:17 neotyk: arohner: Morning than

16:17 arohner: neotyk: :-)

16:18 hiredman: nickik: your jdk is missing rhino

16:19 nickik: ah, I thought thats standart.

16:19 hiredman: it is

16:19 you are non-standard

16:19 nickik: how do i get it?

16:20 theignorati: the internet

16:20 hiredman: ~non-standard

16:20 clojurebot: align yourself with the standard or be crushed

16:20 amalloy: hah

16:20 hiredman: nickik: first figure out what java you have installed

16:21 jre or jdk (rhino comes with the jdk) and which version, etc

16:21 chouser: nickik: you're probably using openjdk instead of sun's

16:21 theignorati: doesn't come with the openjdk

16:23 hiredman: clojurebot: non-standard is <reply> your nonconformance has been noted and we will come for you

16:23 clojurebot: Alles klar

16:24 nickik: chouser, ok i will switch

16:25 kjeldahl: hiredman: It didn't send to any buffer, but binding *out* like described here http://stackoverflow.com/questions/4532862/understanding-output-in-clojure-using-swank-slime worked. Thanks anyway.

16:27 scottj: is it just me or does the clojurescript repl die everytime an exception is thrown (I don't think other repls do this)?

16:32 neotyk: how crazy it is to run against HEAD of closure-library?

16:50 schlechtv: in a ClojureScript REPL: how do I use something from a different namespace, i.e. cljs.reader? I get cryptic exceptions with require, use and (ns xxx (:require ...))

16:54 dnolen: schlechtv: I don't think use/require are supported as fns yet - only the macro form works I think.

16:54 schlechtv: dnolen, meaning (ns ...)?

16:58 dnolen, this fails: (ns tst (:require [cljs.reader :as rdr]))

16:59 neotyk: is there easier way to support ClojureScript swank than one via inferior-lisp?

17:12 dnolen: schlechtv: sorry I didn't mean to imply that you could run that interactively at the REPL.

17:14 schlechtv: dnolen, fair enough, I was just frantically trying to figure out if I made a syntactic mistake :)

17:14 dnolen, so it simply doesn't work, no?

17:18 dnolen, that makes playing with the reader and thus with ClojureScript's answer to JSON a bit unwieldy, no? or am I missing something?

17:20 dnolen: schlechtv: some Clojure/core folks said they'd take a patch to make require work as an fn.

17:22 schlechtv: dnolen, I'm sure... unfortunately I'm far better at finding lose ends than at tying them :-)

17:23 dnolen: schlechtv: I think that's going to be the case for a while with ClojureScript. From the looks of it, it does seem like you're supposed to be able to play with the reader from the REPL.

17:24 schlechtv: dnolen, I'll hang in there and play with some of the other features in the meantime. Thanks for the assistance!

17:28 skybound: can anyone offer advice on cljs & node? i have run into this error http://groups.google.com/group/clojure/browse_thread/thread/67256b0b198e1533/84bafb2ab8aa0e3f?show_docid=84bafb2ab8aa0e3f ; compiling with :simple & :pretty-print seems to imply that accessing 'goog.global.Date.prototype.cljs$core$IEquiv$ = !0;' fails, but deciphering why is beyond me :-(

17:34 gtrak: can I use a :gen-class'd clj from clojure without precompiling with lein compile?

17:35 amalloy: i hope not

17:36 gtrak: so that's AOT only?

17:36 amalloy: &(doc gen-class)

17:36 lazybot: ⇒ "Macro ([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling,... http://gist.github.com/1105293

17:37 technomancy: but, but, clojure.org says that all clojure features are supported at runtime!

17:37 gtrak: hmmm, why'd they prevent it from happening?

17:37 amalloy: technomancy: just a different run-time? the time when you run the compiler?

17:38 technomancy: hehe

17:38 gtrak: amalloy, I thought clojure generates classes all the time, there's no way to pass in a dynamically generated class in some java code that the clojure is calling?

17:39 amalloy: uhhh

17:39 i'm not sure that made sense

17:40 technomancy: gtrak: clojure can't regenerate classes with a given name repeatedly

17:40 java code that requires gen-class generally needs a named class

17:40 if it doesn't, you can use reify

17:40 gtrak: right, can it do it once at runtime though?

17:41 hiredman: you can fudge it with defrecord and deftype

17:41 technomancy: gtrak: if you want to call clojure.core/compile by hand, I think so.

17:42 gtrak: ah ok, it's not the preferred way then

17:45 hiredman: https://github.com/hiredman/agilezen-jdbc/blob/master/src/agilezen_jdbc/core.clj#L254 depending on what you do with the classname you can fake it out

17:46 gtrak: ah, neato

17:48 nickik: haha I typed (+ 1 1) and it returned 2. finally ClojureScript works.

19:08 neotyk: Guys can you tell me if it works for you? http://ec2-46-137-58-250.eu-west-1.compute.amazonaws.com:8108/

19:08 that is Clojure talking with ClojureScript via WebSocket

19:08 how cool is that?

19:10 thanks I see it works :-)

19:12 gfrlog: neotyk: clojurebot is not responding over your channel

19:12 neotyk: gfrlog: should it?

19:12 gfrlog: neotyk: no

19:13 so I guess it's working

19:13 neotyk: it is just a proof of concept

19:14 Raynes: "popup blocked"

19:14 :o

19:14 neotyk: will have to polish it a bit, but I'm frilled by having clojure talking to clojure over webscoket

19:14 Raynes: this is debug window if you care to see it

19:14 Raynes: Ah.

19:15 neotyk: default debug of closure-library is like that

19:15 Raynes: neotyk: Nodejs can do TCP sockets. :>

19:16 neotyk: everything can do tcp this days

19:17 scottj: for anything in a clojurescript app to be compiled in closure advanced mode does everything have to be advanced mode compatible? could you have clojurescript+closure libs compiled in advanced mode while some of the clojurescript calls jquerymobile which is just included not touched by closure?

19:17 Raynes: neotyk: I'm not sure what you're planning to do with your toys, but I'm writing a clojurescript client for http://github.com/flatland/portal as we speak. Might be useful to you when it's finished.

19:18 neotyk: Raynes: not sure, I'm big fan of swank/slime

19:19 scottj: you can via js* form

19:20 good night everyone!

19:20 scottj: is (js/foo a b) special syntax for calling js forms?

19:21 Raynes: It's a shortcut to goog globals.

19:21 neotyk: look at cljs.core

19:22 leeda: ,(contains? [1] 1)

19:22 clojurebot: false

19:22 leeda: what's up with that?

19:22 amalloy: contains?

19:22 clojurebot: contains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains

19:22 Raynes: &(doc contains?)

19:22 lazybot: ⇒ "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or... http://gist.github.com/1105524

19:22 leeda: oh... oops

19:22 amalloy: way to go, bots. you have this one covered

19:23 Raynes: scottj: https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea should clear things up a bit.

19:23 scottj: Raynes: thanks

19:23 technomancy: is it too early for oscon adventurers?

19:45 leeda: can I use lein for a dependency that is a Java library?

19:46 hiredman: that is what lein does

19:46 mdeboard: leeda: yeh u can

19:46 leeda: how do i specify it? https://github.com/notnoop/java-apns/wiki/installation

19:49 technomancy: leeda: try "lein help tutorial"; it's explained in there

19:49 mdeboard: leeda: https://github.com/vitalyper/clj-http/blob/master/src/clj_http/core.clj

19:49 for an example

19:49 (not promised to work )

19:49 leeda: cool, thanks a lot.

19:49 hiredman: mdeboard: what does that have to do with lein?

19:50 mdeboard: wow i have no idea

19:50 my brain broke like 2 minutes ago

19:50 sorry leeda, got myself turned around

19:50 technomancy: mdeboard: just restart swank; that should bring it back to normal

19:50 leeda: haha

19:51 mdeboard: in my defense ijust remapped ctlr->caps in emacs

19:51 so

19:51 yeah

19:56 leeda: okay i thought [com.notnoop.apns/apns "0.1.1"] would work, but it says that the artifact "com.notnoop.apns:apns:jar:0.1.1" is missing... am i still doing it wrong, or maybe it really is missing?

19:59 oh i changed the version to 0.1.6 and it worked. thanks everyone.

20:45 jsnikeris: Hi all. I've written a fn to convert months between two different formats, e.g. "jun" -> "06" and vice versa. However, I'm thinking there must be a way that is more concise. Any ideas? https://gist.github.com/1105641

20:49 aaelony: clj-time might do this (and more)...

20:50 jsnikeris: That's what I'm using

20:50 aaelony: ah, sorry.

20:51 jsnikeris: aaelony: np

20:54 mdeboard: how would one produce an hmac sha1 message digest in clojure?

20:59 wink: https://bitbucket.org/tebeka/clj-digest/src maybe?

21:08 mdeboard: yeah that's good for sha1 but not for hmac standard

21:08 been using that to no avail :)

21:26 chouser: amalloy: looks great. Willing to add any tests for your new xml code?

21:26 amalloy: chouser: yeah, i grudgingly volunteered a few hours ago in irc, but i gather you missed it

21:41 mdeboard: HA

21:41 Oh man

21:41 I just made Clojure give me that sweet hexdigest hmac sha1 chocha

21:41 you beautiful thing

21:47 amalloy: ah, i remember the first time i ran maven. didn't even know what it was supposed to be/do, and hit C-c because it certainly couldn't be *intended* to download this much stuff i'd never heard of

21:47 tarcieri: so like... Clojure kinda leaks JVM internals all over the place... how does that stuff work in ClojureScript?

21:48 I guess I should just play with ClojureScript and see for myself

21:48 mdeboard: tarcieri: "leaks jvm internals"?

21:48 tarcieri: what does `Integer do on ClojureScript?

21:49 I assume it doesn't qualify it to java.lang.Integer

21:52 amalloy: chouser: one of the tests i'd like to write fails, because i convert :empty (as opposed to [:empty]) into {:tag :empty, :attrs {}, :content nil} instead of :content (). care to take a position on whether that's a distinction you want to enforce?

21:53 hiredman: is the map a struct? (cannot leave out the :content key?)

21:53 amalloy: hiredman: it's a record

21:55 i can certainly make it set a :content of (), but from the client's POV it shouldn't matter which is used; if they write something of their own that sets a :content of nil, i don't think we want it to compare as not= to something with a :content of ()

21:56 hiredman: mmm

21:57 but what about the result of :content (map foo some-empty-seq)

21:58 amalloy: hiredman: right, that's what [:empty] (wrapped with brackets) yields. maybe i'm just being silly in even wanting this

21:58 hiredman: ,(= nil ()) ; and all the wishing does not make it so

21:58 clojurebot: false

21:59 jcromartie: What's the current way to use sessions from compojure?

21:59 amalloy: jcromartie: sandbar is popular, i think

22:01 scottj: sandbar or noir for stateful ones, compojure itself for functional ones.

22:01 jcromartie: https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session.clj

22:01 yeah

22:02 Noir is "the" Clojure web framework :)

22:02 according to its site

22:03 I guess I'll grab Noir

22:16 chouser: amalloy: hm, I guess I don't have an opinion. I'd need to think about it more. You think it's an important distinction?

22:19 mdeboard: oh man

22:20 I'm really excited and want to brag. I wrote a wrapper in Clojure for the US Dept of Labor API as a self-teaching project and I just finished it!

22:20 I'm more excited than a puppy who just found his you-know-what

22:22 chouser: mdeboard: congrats!

22:22 amalloy: chouser: not especially, but because my test used = and the things compared not=, it artificially became important

22:22 mdeboard: chouser: thanks! really thrilled irl

22:23 amalloy: ie, if you revert https://github.com/clojure/data.xml/commit/21998b then the test fails to pass

22:24 i kinda wanted to be ambivalent about the two, but hiredman has me mostly convinced that that's a naive thing to want

22:25 chouser: It would probably be best to use ()

22:26 because in most (all?) contexts, :content is a lazy seq. An empty lazy seq is (), not nil.

22:26 amalloy: *nod*

22:28 well, i'm gonna head home. glad to finally have some code of mine in clojure/contrib

22:29 chouser: amalloy: Thanks so much, I really appreciate it.

23:12 technomancy: anyone up for some golf?

23:12 (int (Math/ceil (/ (:_total-hits (meta results)) (float page-size))))

23:15 ah, the float is unnecessary

23:16 nice that Math/ceil works on ratios

23:16 amalloy: technomancy: as is the int/ceil combo: (int (+ .5 x)) does the same

23:16 technomancy: hmm; no fewer tokens though

23:17 amalloy: more tokens, even

23:17 technomancy: yeah

23:17 amalloy: but fewer characters

23:17 technomancy: I just need int that rounds up

23:17 amalloy: &(doc unchecked-do-what-technomancy-wants)

23:17 lazybot: java.lang.Exception: Unable to resolve var: unchecked-do-what-technomancy-wants in this context

23:17 amalloy: $findfn 0.7 1

23:18 lazybot: []

23:18 technomancy: oh man... + 0.5 *does* take it from 83 columns to 79.

23:18 hard to resist

23:19 amalloy: you can even afford to put a semicolon as the end. "look! it's documented!"

23:20 hiredman: have you arrowed it yet?

23:20 zmaril: Pardon me, how was the first macro written? "Programming Clojure" says that defmacro is itself a macro. If you check the source of defmacro with repl-utils, then you bump up against something called setMacro which doesn't seem to exist anywhere.

23:20 technomancy: wait that's not right

23:21 ,(int 0.9)

23:21 clojurebot: 0

23:21 zmaril: Is there another way to define macros somehow?

23:21 amalloy: technomancy: haha sorry, that trick is for rounding, not for ceil

23:21 hiredman: zmaril: a macro is just a function with a particular bit set that lets the compiler know it is a macro

23:22 technomancy: 83 columns!!!oneone

23:23 duck1123: Does anyone know if it's possible to add my resources directory to the classpath with maven? (the source, not the copied versions)

23:23 zmaril: hiredman: That makes sense. But how did they write the first macro then? Is it the same way they defined what a function is but just with this particular bit set?

23:23 duck1123: I'm messing around with soy templates and I have to reprocess the resources to get the changes picked up

23:23 hiredman: (-> results meta :_total-hits (/ page-size) Math/ceil int)

23:24 joegallo: the first macro stands on the back of a turtle, and then it's just turtles all the way down

23:24 technomancy: hiredman: aw dang; right as soon as I push =)

23:24 hiredman: I asked if you arrowed it

23:27 zmaril: That is what every programmer says. C was written in C, Clojure was written in Clojure, Javascript was written in a week.

23:27 hiredman: clojure is written in java

23:28 amalloy: and C was written in asm. later, someone rewrote it in C

23:28 zmaril: Right but isn't the big push to write clojure in clojure? I thought that was part of the point of ClojureScript

23:28 hiredman: asm? not B?

23:28 technomancy: hiredman: I thought you were making a joke about monadic arrows =(

23:29 amalloy: haha me too

23:29 dnolen_: zmaril: there's no "big push" to get Clojure in Clojure as of yet. ClojureScript is a step in that direction.

23:30 amalloy: hiredman: i'm hardly an expert, but i didn't think B was involved in implementing C, just as an ideological ancestor

23:30 hiredman: amalloy: sure

23:32 zmaril: dnolen_: ah. back to the books then.

23:36 qed: If I have a structure like [[0 1 1 '(0)] [...]], and I want to call #(= (range %1 %2 %3) %4) across each [...], how do I do that?

23:38 What's a good way to get at the inner [...]'s, and assert that some function called on the first elements of any [...] is equal to the 4th?

23:39 amalloy: qed: it's simpler if you instead use [['(0) 0 1 1] ...]

23:39 then you can do (for [[result & args] test-cases] (= result (apply range args)))

23:41 gtrak``: is there such a thing as a lein clojurescript plugin yet?

23:43 Pupeno: I want to play around with IMAP, is JavaMail the way to go or should I try something different?

23:46 rimmjob_: if i do my java homework in clojure, would my teacher be able to tell?

23:46 duck1123: rimmjob_: He'll probably want source

23:47 and even still, you can tell it's clojure by looking at the class names

23:47 rimmjob_: oh ok :*(

23:48 Pupeno: I'd give extra points if a student uses Clojure instead of Java… but then again… I'm not teaching and I can more or less understand Clojure. If the teacher doesn't, you are probably causing him a problem because he won't be able to know whether what you did is right or wrong.

23:49 duck1123: Welcome to the world of a programmer. forced to use something when you really want to use clojure. :)

23:49 amalloy: Pupeno: nah, easy, it would be wrong: using a language that is not the one you're supposed to be learning

23:49 duck1123: Pupeno: I tried to pull that in my C# class. Didn't go over well

23:50 rimmjob_: i use it at work and my boss doesnt care

23:50 amalloy: rimmjob_: that's because your boss cares about getting things done

23:50 Pupeno: It might depend on the teacher.

23:50 amalloy: when you take a class like "data structures", ask about implementing your stuff in clojure

23:50 when you take a class called "java", do your stuff in java

23:51 rimmjob_: its conurrency in java :*((

23:51 amalloy: but seriously, i know someone who'd be way more well-placed to judge what your teacher would want: your teacher

23:51 hiredman: I started a lisp->java source code generator thing a while back

23:51 Pupeno: rimmjob_: you might end up like me once… as teacher assistant.

23:51 hiredman: went looking for it the other day and could not find it

23:52 amalloy: meh. then definitely use java: it has all kinda of exciting problems you won't be able to solve if you use clojure, because clojure doesn't have them

23:52 duck1123: rimmjob_: then all you can really do is sit back and make "clojure does this better" comments

23:53 rimmjob_: ill try to be as smug as possible

23:53 gtrak``: are you allowed to use libraries at all?

23:54 rimmjob_: um he hasnt really said anything about it

23:55 duck1123: probably only the one specific library the book uses

23:55 importing clojure's data structurs for the chapter on avoiding deadlocks probably won't fly

23:57 amalloy: and wouldn't really be learning anything anyway

23:57 i mean, if you don't spend your whole life writing clojure, you'll want to know how to avoid deadlocks in a mutable language

23:58 even if you don't like java's syntax, learning the concepts is good

23:59 rimmjob_: i geuss youre right

Logging service provided by n01se.net