#clojure log - Apr 13 2011

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

0:35 kephale001:  /j #incanter

0:35 upps

0:35 any incanter folks here?

2:49 devn: ,(let [{:keys [a b c d]} {:a 1 :b 2 :c 3 :d 4}] [a b c d])

2:49 clojurebot: [1 2 3 4]

2:49 devn: ,*clojure-version*

2:49 clojurebot: {:major 1, :minor 2, :incremental 0, :qualifier ""}

2:49 devn: hmm, weird

2:52 im doing this in my repl and i keep getting nil

2:52 the thing im using is clearly a map

2:54 ,(let [{:keys [layer octave duration n-notes repetitions]} {:layer "0" :octave "5" :duration "q" :n-notes "16" :repetitions "2"}] [layer])

2:54 clojurebot: ["0"]

2:54 devn: weird

2:57 (def note-map-coll (first [{:layer 0 :octave 5 :duration "q" :n-notes 16 :repetitions 2}, {:layer 1 :octave 3 :duration "q" :n-notes 4 :repetitions 8}]))

2:58 (defn play-random-note-maps [{:keys [layer octave duration n-notes repetitions]} nmc] [layer])

2:59 ;=> "Wrong number of args (1)"

2:59 when calling (play-random-note-maps note-map-coll)

3:02 (defn play-random-note-maps [nmc]

3:02 (let [{:keys [layer octave duration n-notes repetitions]} nmc]

3:02 [layer]))

3:03 stirfoo: devn: don't key arguments have to be in a rest list? [& {:keys ...}]

3:03 devn: ^^works, is this intentional?

3:04 stirfoo: no, but curiously...

3:04 (defn play-random-note-maps [{:keys [layer octave duration n-notes repetitions]} & nmc] [layer])

3:04 ;=> ["0"]

3:08 curious...bed time

3:09 stirfoo: are defn, defmacro, let, and letfn argument destructuring handled the same?

3:10 my ver: {:major 1, :minor 2, :incremental 0, :qualifier ""}

3:16 ,(print "foo")

3:16 clojurebot: foo

3:18 stirfoo: ,(defmacro awhen [x f] `(when-let [r# ~x] (~f r#)))

3:18 clojurebot: DENIED

3:19 stirfoo: bah!

3:29 ,(print "bar")

3:29 clojurebot: bar

3:29 stirfoo: so, you just don't like macros

4:05 raek: stirfoo: yes they are handled the same. but note that with defn, you can't do (defn foo args ...) or (defn foo [:as args] ...)

4:05 stirfoo: this is because destructuring are done for function parameters, but not the whole parameter list

4:20 noidi_: I have an unbound var, for which I need to establish a binding during my cucumber test run. I can't use binding, since in cuke4duke there's no way to surround all the test code.

4:21 alter-var-root doesn't work, since the var has no root binding

4:21 and I can't re-def the var since it's defined in another namespace

4:22 raek: noidi_: alter var root takes the var object as an argument

4:22 ejackson: hello

4:22 noidi_: what's the best way to set the var's binding for the rest of the programs execution? intern? push-thread-bindings (without popping)?

4:22 raek: it sounds like you are sending it the value of the var

4:23 if you want to set it once during initialization, and binding is not an option, then I'd suggest alter-var-root or intern

4:23 (alter-var-root #'the-var altering-fn)

4:23 noidi_: that doesn't work without a root binding

4:23 raek: (intern 'the-ns 'the-var value)

4:23 oh, now I see :)

4:24 the intern version should work, then

4:24 noidi_: thanks, I'll go with intern

4:25 raek: if you use lein, it is probably possible to make a wrapping binding with a hook

4:26 noidi_: I use maven

4:27 cuke4duke sucks a bit when it comes to setup/teardown code...

4:29 but yay, the intern hack worked

4:36 clgv: noidi_: I am curious. what is cuke4duke used for? there is only a short sentence talking about "step definitions".

4:37 noidi_: it's Cucumber for JVM languages http://cukes.info/

4:38 clgv: ah "behavior driven development". I did read about bdd for c# some weeks ago

4:40 noidi_: I don't buy completely into the whole BDD thing, but cucumber is quite nice for writing tests that exercise the complete program

4:41 clgv: I had similar thoughts while reading: it enables tests whose definition is much more similar to specified use cases

4:42 s/much more/very/

4:42 sexpbot: <clgv> I had similar thoughts while reading: it enables tests whose definition is very similar to specified use cases

7:07 markoman: what are good practices to create tests on clojure?

7:08 ejackson: do so :)

7:09 markoman: i have punch of files now and want to do tests for them, maybe not the order some suggest, but anyway. i wonder if I should test every function, what about defn- ?

7:09 ejackson: you should really only test the interface functions

7:09 markoman: do you usually test with big sets of good, bad, correct and false values?

7:10 ejackson: i try to get an example of each mode of success/failure etc

7:10 there are no coverage tools, but you would like to exercise each logical phase of your code

7:11 markoman: can you provide example of "each phase"?

7:13 is there any tool in clojure to get started with tests easily? i mean when i create new project with lein, it creates a test file fore core.clj. something similar that scans files on src and creates some files automated?

7:19 ejackson: sorry, "each phase" -> "each logical branch "

7:19 i dunno of any tests

7:19 i just make a test directory and put the tests in there

7:19 dunno what's to automate :)

7:21 markoman: you could have a skeleton of files and public functions from files pre made

7:22 im lazy writer and copy paster :)

7:26 https://github.com/marick/Midje seems to be one of the many test frameworks

7:29 clgv: markoman: it is. there is also clojure.test

7:30 markoman: im using (is) tests at the moment, but thinking if there are more organized ways, especially for web apps

7:31 clgv: yeah I've been using them too

7:34 I was considering to test midje next when I start testing the new code

7:38 ejackson: yeah I looked at it, but i'm sticking with clojure.test for now

7:39 markoman: decisions :)

7:40 clgv: yeah I am still wondering if midje provides me real advantages and if it's mature enough

7:43 markoman: there is also this https://github.com/semperos/robot-remote-server-clj robotframework for automated testing

7:44 clgv: markoman: I am not doing webdevelopment, so dont need that one ;)

7:45 markoman: right. it would be ideal to make tests first and use functions from tests on actual app, but it requires total twist of mind, at least on my case

7:46 clgv: hmm don't know that test-first is always a good choice

7:46 s/that/if/

7:46 sexpbot: <clgv> hmm don't know if test-first is always a good choice

7:48 TimMc: I try for test-first as an ideal, but I don't hate myself if I implement first. It works out to a nice balance.

7:48 markoman: id like to have bug free apps, tired of problems and time they take, lol

7:48 TimMc: Writing unit tests after implementation catches enough bugs as it is. :-)

7:49 ejackson: i agree. pure TDD presumes the lack of a repl

7:49 i like to play about in the REPL get it in line

7:49 then write the tests to 'tie it down'

7:49 can think more flexibly, i find

7:49 TimMc: I don't think that's true, though.

7:50 clgv: with all the probabilistic stuff I do, it's sometimes really difficult to come up with complete tests

7:50 TimMc: ejackson: I think the REPL is great for getting a correct implementation quickly, but that's probably orthogonal to whether you've already written the tests.

7:50 markoman: (probably-true test case)

7:51 TimMc: clgv: You pass around a random seed?

7:51 markoman: or just (probably? test case) :)

7:51 TimMc: (Or use binding, I guess.)

7:52 clgv: hmm for simple cases this is an option. I used mocking to select the cases I need

7:52 ejackson: TimMc: writing tests often fixes my initial mode of thought on a problem, whereas playing in a repl often leads me to new thoughts and thus a different interface to test

7:53 TimMc: ejackson: There is that.

7:54 markoman: i still find myself uncomfortable with testing new functions on REPL. I mean it takes time to collect all pieces from repl history and put on function

7:54 ejackson: markoman: Oh i write code in a file, and use C-x C-e to pass it to the repl to avoid that

7:55 markoman: plus knowing, what is active on current repl namespace, that gives gray hairs too

7:55 ejackson: i *do* end up with giant (comment ...) blocks that I then purge

7:55 otherwise yes, you have spaghetti

7:55 markoman: lol, that I know very well already

7:55 clgv: In fact you cant test everything in REPL. I often have to write new functions that are deep within my algorithm framework, so that a huge setup would be required to get the input for these functions - debug-repl is an option though

7:56 ejackson: clgv: yeah, I have same problems, getting into a deep context

7:56 i keep meaning to try these debug tools, but never seem to get around to it :(

7:56 clgv: you should get started with debug-repl easily

7:57 it's kinda nice to launch a repl inside your algorithm at a point you specified

7:57 markoman: emacs slime?

7:57 ejackson: yeah, emacs+slime

7:58 markoman: the other thing I do have a foo-lab.clj file, that loads up relavent libraries, and play there

7:58 but *always* write the tests afterwards

7:59 for me its mostly to keep tabs on the interfaces so that if something changes between when I worked in the repl, and time t, a test will break to alert me

8:00 markoman: yeah, its good tip, test interfaces primarily

8:01 you mean you create a foo-lab and :use or :require all your libs there?

8:02 clgv: markoman: depends - my only interface function is the main algorithm which is not easily testable, so I have to test its inner parts

8:02 ejackson: i think its the accepted practice for unit testing

8:02 although I agree with clgv too :)

8:03 markoman: clgv: sure. i think different purposes makes the different

8:03 difference*

8:04 clgv: e.g. it was a pretty good idea to test the creation of the commulative distribution function and it's usage to select a random element accordingly

8:05 ejackson: indeed !

8:05 inversion sampling :)

8:06 that's such a cute idea

8:09 markoman: (vals {:a 1 :b 2}) is different datatype than [1 2]

8:09 how can you convert vals same, or are they both ordered lists?

8:10 clgv: let's see which: ##(type (vals {:a 1 :b 2})) and ##(type [1 2]) ;)

8:10 sexpbot: (type (vals {:a 1, :b 2})) ⟹ clojure.lang.APersistentMap$ValSeq

8:10 (type [1 2]) ⟹ clojure.lang.PersistentVector

8:10 ejackson_: ##(type (into [] (vals {:a 1 :b 2})))

8:10 sexpbot: ⟹ clojure.lang.PersistentVector

8:10 clgv: &(compare (vals {:a 1 :b 2}) [1 2])

8:10 sexpbot: java.lang.ClassCastException: clojure.lang.APersistentMap$ValSeq cannot be cast to java.lang.Comparable

8:11 markoman: vector should keep its index order by default?

8:12 persistent map sounds like it keeps order too

8:18 clgv: &(= (seq (vals {:a 1 :b 2})) (seq [1 2]))

8:18 sexpbot: ⟹ true

8:32 markoman: ok, seq and type into makes them same

8:33 thanks again guys

8:37 ejackson: markoman: sortof. into turns into a the vals into an actual vector. seq just presents a seq over each collection.

8:38 clgv: $source group-by

8:38 sexpbot: group-by is http://is.gd/JJJRzs

8:38 * cemerick opts to feed a troll

8:38 cemerick: I simply can't help it. :-(

8:39 ejackson: where is the troll show ?

8:40 cemerick: It's not much of a show. :-)

8:40 edw: Thinking of Marilyn Manson: "We're all stars now, in the troll show..."

8:40 ejackson: you should feed it spicier trolltreats

8:41 cemerick: ejackson: I'd feel badly for the unwilling spectators.

8:42 ejackson: i guess so, it sortof makes you a troll too...

8:42 a troll of the 2nd order

8:42 edw: $source map

8:42 sexpbot: map is http://is.gd/Fd9Ag4

8:42 edw: That is kinda awesome.

8:45 clgv: edw: it is :)

8:45 findfn is even better ;)

8:47 * edw /MSGs sexpbot...

8:48 edw: sexpbot is a bit cagey regarding help. Talking to it is like playing zork. Kinda hot.

8:49 clgv: $findfn {:bla 1 :blubb 2 :lala 3 :haha 4} [:bla :lala] {:bla 1 :lala 3}

8:49 sexpbot: [clojure.core/select-keys]

8:49 clgv: edw: that's what I meant - feels like magic ;)

8:50 ejackson: what !

8:50 its become selfaware

8:50 edw: How many minutes did it take to develop a sense of irony?

8:51 $findfn {:a 1 :b 2 :c 4} [1 2 3]

8:51 sexpbot: []

8:51 edw: $findfn {:a 1 :b 2 :c 4} [1 2 4]

8:51 sexpbot: [clojure.core/vals]

8:52 edw: I could spend all day talking to sexpbot.

8:52 * edw gets a dreamy look.

8:54 edw: Whoa, it automatically posts gists when its responses get too chatty!

9:15 matthias_: okay... so i got swank and leiningen and emacs + slime working but... how do i now build and run a clojure program? i made a new project and put some code into core.clj and then added the program's namespace to the project.clj after :main, but it says it doenst find a main. im not even sure how that's supposed to work, do clojure programs have mains?

9:20 edw: matthias_: Check out the "sample" test project in the leiningen repo on github. I'd tell you the answer, but I'd rather help you develop mad learning skillz.

9:27 matthias_: i've checked it out, that's where i saw the :main stuff

9:27 but i havent read all of it yet

9:28 ejackson: matthias_: you'll only use a main if you precompile stuff, usually in clojure you won't need to do so

9:28 edw: OK, I couple of "hints": 1) in projects.clj: ":main nom.nom.nom".

9:29 2) in src/nom/nom/nom.clj: "(defn -main [& args] ... )

9:30 (End quote.)

9:30 matthias_: ugh, i think i was in the wrong folder. its like folder/folder/folder/project.clj, i was in folder/folder and folder/project.clj also exists

9:30 ejackson: matthias_: if you have lein, swank, emacs and slime all working then all you need to is:

9:30 matthias_: weird

9:30 ejackson: issue: lein swank from the project root directory

9:30 matthias_: there's a start function in the program im trying to run

9:31 ejackson: then in emacs go M-x slime-connect

9:31 that'll bring up a repl in emacs

9:31 from there you're off

9:31 edw: ejackson: I didn't even want to touch the "why do you want a `main' anyway?" question... There's some REPL philosophy grokking that needs to occur her.

9:32 matthias_: does lein search for a project.clj in a higher directory if it doesnt find one where you are?

9:32 edw: s/her\./here./

9:32 sexpbot: <edw> ejackson: I didn't even want to touch the "why do you want a `main' anyway?" question... There's some REPL philosophy grokking that needs to occur here.

9:32 ejackson: matthias_: don't think so, issue it from the root

9:32 matthias_: well that seems to have happened when i was in the wrong folder

9:32 maybe

9:33 at least it ran without complaining when i was in a folder without project.clj

9:34 getting lots of artifacts missing when i run lein deps now... but i dont see it telling me what's actually missing

9:35 looks like it cant find clojure contrib :|

9:35 edw: matthias_: Are you starting with the simplest possible scenario that should work? You don't need a lot of dependencies to get a lein project running a swank server and Emacs connected to it.

9:35 matthias_: i've already had that

9:36 now im trying to run an example program from the web

9:36 (its tetris with penumbra)

9:37 edw: matthias_: Dude, try creating a new, empty, lein project, adding swank to the dev-dependencies, firing it up, and connecting to it. Keep it simple...

9:37 matthias_: oh, i had to add clojure contrib to the deps

9:37 i did that before

9:37 edw: Does it work?

9:38 matthias_: yes it does

9:39 i mean the simple version worked

9:39 edw: So what didn't work that led you to download a random project from the internet and try to get that to work?

9:40 matthias_: slime still says it cant find the (start) function. thats define in my core.clj

9:40 edw: Dude you (use 'core)?

9:40 matthias_: i didnt download a random project. i got swank + slime to work and then i wanted to run a real program. everything worked until there, but i couldnt get the real program to work

9:40 no

9:41 edw: Try that.

9:41 matthias_: Could not locate core__init.class or core.clj on classpath:

9:41 [Thrown class java.io.FileNotFoundException]

9:41 edw: Is core in 'src/'?

9:42 matthias_: its in src/tetris/

9:42 edw: So, did you do a (use 'tetris.core)?

9:43 matthias_: org.lwjgl.opengl.GL11

9:43 [Thrown class java.lang.ClassNotFoundException]

9:43 edw: Is that a depenedency?

9:44 s/dependendency/dependency/

9:44 * edw throws up his hands.

9:45 matthias_: penumbra is a dependency. penumbra uses lwjgl

9:46 i installed lwjgl using synaptic. dont know how to add it as a dependency

9:46 edw: And I have no idea what synaptic is.

9:47 matthias_: the package manger gui of ubuntu

9:48 is there really no easier way to run a clojure program? i thought it must be something like "cljcompile bla.clj" "these jars are not in your classpath!" *adds to classpath* "cljcompile bla.clj" "success!" "clj bla.class" program runs :>

9:48 edw: Well that org.lwjgl.opengl... reference is probably to some Java glue classes (that are missing).

9:50 Yes, you can `lein run' and if you've defined a main package, its `main-' will be be called.

9:50 matthias_: oh, i think i had to run lein native-deps

9:50 edw: Err, `-main' function.

9:52 matthias_: aahhh now it works :)

9:52 edw: There have got to be easier ways to play Tetris under Ubuntu...

9:52 matthias_: thanks for your help

9:52 edw: You're welcome.

10:46 choffstein: Hey all. What is the best way to find out whether clojure core or contrib contains a function? For example, if I want to know if there is a natural log implementation, what's the best way to try to find that?

10:47 TimMc: choffstein: I use clojuredocs.org

10:49 jlf`: choffstein: http://clojuredocs.org/clojure_core/clojure.core/find-doc

10:49 choffstein: perfecto. Thanks

10:49 * angerman is very confused about his webapp. for some very strange reason, session-data is mangled between users.

10:50 choffstein: angerman, I can feel your pain

10:51 angerman: choffstein: worst of all. It simply makes no sense. the users have to connect to an ssl site. The routing is funtional, there's just no state.

10:51 it makes no sense at all.

10:51 choffstein: angerman: that is confusing ...

10:51 angerman: I would be happy to give you a set of fresh eyes, though no promise I can get anywhere on it

10:52 angerman: choffstein: nah, it's been reviewed three times already. I'm currently thinking about the clients network topology.

10:52 choffstein: angerman: well, best of luck :)

10:52 angerman: choffstein: thanks, will need it :D

10:53 choffstein: when you have to start thinking network topology level...

10:53 angerman: especially because I don't think I'll be able to obtain any reliable information from the persons within...

10:53 that's probably along the lines of: "Well, we click this icon and then we are on the internet"

10:55 TimMc: angerman: Session data is stored in cookies?

10:56 angerman: no. cookies are only used to identification, then the session-data is pulled out of memcache

10:57 TimMc: And users are getting each others' data?

10:57 angerman: apparently. but it looks more like they get another session.

10:57 TimMc: Ah, OK.

10:57 Consistently?

10:57 angerman: no

11:01 TimMc: I'm not sure what network topology has to do with this.

11:01 angerman: TimMc: I'm wondering if there is some weird proxy in between.

11:01 TimMc: Ah.

11:03 angerman: In a case like this, it might be interesting to send the cookie data explicitly in the response body and have JS check to see if they differ. :-P

11:03 In any case, it sounds like a slog.

11:05 sritchie: hey all -- once I bundle up a project with "lein uberjar", how can I use it to load up a repl?

11:06 something like -- java -jar myproject-standalone.jar clojure.lang.Repl

11:07 angerman: TimMc: yes. it is _very_ strange.

11:08 TimMc: Anybody seeing checksum problems with maven central?

11:10 clgv: sritchie: you can use clojure.main/repl in your -main function explicitely

11:11 sritchie: clgv: ah, got it. so, I should add ":main clojure.main" to project.clj?

11:11 TimMc: sritchie: java -cp myproject-standalone.jar clojure.lang.Repl is a start

11:11 sritchie: or define a -main function in one of my namespaces, point to that, and run clojure.main/repl there?

11:12 clgv: sritchie: hmm would be an option as well. I thought you might have a -main function already, so you could include the repl call in there

11:12 TimMc: sritchie: So you're not asking how to get a REPL in an arbitrary uberjar?

11:12 sritchie: TimMc: that would be more helpful, I think

11:13 I'm getting -- Failed to load Main-Class manifest attribute from forma-0.1.0-standalone.jar

11:13 I'm not sure how to provide that at the command line

11:13 TimMc: That's not what I get.

11:13 It yells at me about clojure.lang.repl being deprecated and then gets me a repl anyway.

11:14 c.l.Repl, rather

11:14 sritchie: here's my command -- java -jar forma-0.1.0-standalone.jar clojure.lang.repl

11:14 s/repl/Repl

11:14 sexpbot: <sritchie> here's my command -- java -jar forma-0.1.0-standalone.jar clojure.lang.Repl

11:14 sritchie: do you have any :main at all defined?

11:14 TimMc: You want -cp I think.

11:14 Instead of running the jar, you use it as a library.

11:15 sritchie: Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

11:15 followed by

11:15 Could not find the main class: clojure.lang.Repl. Program will exit.

11:15 but that gives me a lead!

11:25 angerman: Are bindings call local?

11:27 amalloy: angerman: huh?

11:29 raek: clgv: clojure.main defines a main function, but it hase the name "main" instead of "-main", so you can't use the :main option for that directly, unfortunately

11:29 edw: Why does (java.lang.Math/PI) not throw an exception?

11:29 raek: iirc, this was discussed recently at the leiningen mail list

11:30 clgv: raek: sritchie needed it. so he might still implement his own main and call clojure.main/repl in it

11:31 sritchie: clgv: bundling with cake uberjar, then running java -cp myapp-standalone.jar clojure.lang.Repl actually ended up working out

11:31 raek: you could also start you project with java -jar myproject-standalone.jar clojure.main

11:32 hrm, maybe you need to have -cp instead of -jar there...

11:32 Vinzent: http://paste.lisp.org/display/121462 - any ideas? This code is in fn called from the macro

11:34 amalloy: Vinzent: are you on clojure 1.3?

11:35 Vinzent: amalloy, no, stable 1.2

11:36 amalloy: &(let [f "f"] (fn [x] (throw (UnsupportedOperationException. (str "z" type)))))

11:36 sexpbot: ⟹ #<sandbox15764$eval18933$fn__18934 sandbox15764$eval18933$fn__18934@144774e>

11:37 amalloy: Vinzent: sexpbot is on 1.2.0 and it works; i tried it on 1.2.1 and it works. i'm going to say you have something messed up in your environment. maybe stale AOT compiled classes? those cause messes "like" this

11:37 Vinzent: it's ok from the repl for me too. Problem appears only in that function.

11:37 edw: &(java.lang.Math/PI)

11:37 sexpbot: ⟹ 3.141592653589793

11:38 edw: ^^^ ???

11:38 amalloy: edw: it's not printing all the infinite digits! oh no!

11:39 Vinzent: that is not clear. what do you mean, it's okay from the repl but only "in that function". if that function works in the repl, the problem is not in that function

11:39 edw: No, what's bothering me is that both "java.lang.Math/PI" and "(java.lang.Math/PI)" eval to the same thing.

11:39 I am confused.

11:40 amalloy: &(map macroexpand '((Math/PI) Math/PI))

11:40 sexpbot: ⟹ ((. Math PI) Math/PI)

11:40 amalloy: &(doc .)

11:40 sexpbot: ⟹ "Special Form: Please see http://clojure.org/special_forms#."

11:40 amalloy: go read about the . special-form: it says it's just fine to call a field as a function

11:41 hm. that link kinda sucks, though

11:42 edw: Ah. Thanks. Makes sense if you think of it as if it's calling an implicit getter.

11:42 amalloy: try http://clojure.org/java_interop

11:42 edw: amalloy: No prob; I know where. Ah. Thanks.

11:43 Vinzent: amalloy, well, fn itself works fine, but when called from the macro leads to that creepy exceptions. I can paste the whole code, but don't think somebody wants to read it all

11:43 amalloy: heh. i'm glad thinking of an implicit getter works for you, cause it certainly doesn't do anything for me

11:43 edw: I'm trying to work with Java here, trying not to be a hater.

11:47 amalloy: edw: what really happens is that (. Math PI) looks inside of the Math class to see whether Math has a field named PI or a no-arg method named PI

11:47 that allows ##(.PI Math) to expand into something simple

11:47 sexpbot: java.lang.IllegalArgumentException: No matching field found: PI for class java.lang.Class

11:47 amalloy: hm. guess not

11:48 &(map macroexpand '((Math/PI) (.PI Math)))

11:48 sexpbot: ⟹ ((. Math PI) (. (clojure.core/identity Math) PI))

11:48 amalloy: feh

11:51 edw: I'll checkout out the source. This came up because I was verifying my conversion of Morrie's Law into radians, and accidentally typed (java.lang.Math/PI) and got an answer.

11:51 amalloy: edw: you don't have to type java.lang., you know

11:52 edw: Ah. Thanks. But it's a nice reminder to pay respect to the gods.

11:55 amalloy: *smile* on the contrary, the java gods only want you typing when they demand it. else it is sacrelige

11:56 edw: But srsly, I knew I didn't have to type some part of it, but I'm getting over a cold and the amber light on my caffeine guage just lit up.

11:56 s/guage/gauge/

11:56 sexpbot: <edw> But srsly, I knew I didn't have to type some part of it, but I'm getting over a cold and the amber light on my caffeine gauge just lit up.

12:02 Vinzent: Ah! there was a typo, not 'type' but 'foo' of course: http://paste.lisp.org/display/121462#1 And no, I have no aot-things. When any local var passed to the Exception constructor, ExceptionInInitializerError is throwed

12:03 amalloy: Vinzent: i figured you actually meant type. but it works fine with foo too

12:03 &(let [f "f"] (fn [x] (throw (UnsupportedOperationException. (str "z" f)))))

12:03 sexpbot: ⟹ #<sandbox15764$eval19011$fn__19012 sandbox15764$eval19011$fn__19012@17994ab>

12:07 Vinzent: amalloy, i can't reproduce it too. There is a macro which calls one fn, then passes the result to another, then uses last result to generate some defs. I've tried to write thing with similar structure but have no luck

12:22 So I have no idea what actually leads to the exception; probably it'd be better to pass just a static string...

12:31 matthias_: (im completely new to slime and emacs and clojure) hmm, i tried running a function by having the point in it and pressing C-M-x. slime is running and if i start the same function by typing it in the repl, it works. i tried making a new function (println "bla"). running that with C-M-x worked. saw bla in the repl. but starting the other function doesnt work. it's the start function of penumbra's tetris example. any guesses why that might b

12:31 e?

12:31 clojurebot: the reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit.

12:31 matthias_: uh huh

12:31 wow, that got a bit long

12:31 amalloy: matthias_: just long enough to split into two messages :P

12:32 matthias_: heh

12:32 amalloy: "having point in it" sounds worrying. C-M-x evals the form *starting* at point

12:32 i think

12:32 Vinzent: тщ

12:32 amalloy: i usually use either C-c C-c (eval top-level form containing point) or C-x C-e (eval point ending at form)

12:32 Vinzent: *no

12:32 matthias_: hmm, i thought it starts the "toplevel form". some video said so, and it seemed to be working

12:33 i'll try cc

12:33 amalloy: matthias_: they're probably right, then. as i said, i don't use it much

12:35 matthias_: difference seems to be that cc also compiles? i dont really get it

12:35 C- C-c didnt work either, but got a different reply in the minibuffer

12:47 rak85: hi, guys!

12:48 is there any way to remove the keys in a hash which have empty values?

12:48 or giving a condition?

12:48 or a function? =P

12:49 amalloy: filter

12:50 &(into {} (remove (comp nil? val) {:a 1 :b nil})))

12:50 sexpbot: ⟹ {:a 1}

12:50 rak85: filter is returning a list for me

12:50 amalloy: a little more involved than needed to remove strictly nils, but more flexible than the simple ##(into {} (filter val {:a 1 :b nil}))

12:50 sexpbot: ⟹ {:a 1}

12:51 cemerick: amalloy: you need nil? to remove strictly nils

12:52 &(into {} (filter val {:a false :b nil}))

12:52 sexpbot: ⟹ {}

12:52 rak85: thanks, amalloy

12:52 cemerick: Truthiness, you hurt so bad. :-)

12:52 amalloy: cemerick: yeah, i know

12:52 cemerick: I know you know; just being pedantic in a spare moment. :-)

12:53 amalloy: *laugh* thanks; my life might actually be fun if you didn't have spare moments

13:08 Raynes: cemerick: http://www.reddit.com/r/Clojure/comments/gn3d1/can_has_meet_clojure_website/c1p1vdz This must be why we write books.

13:10 cemerick: Raynes: that's a nice comment :-)

13:10 Raynes: Nice. Frightening, but nice.

13:10 cemerick: I can't say I have any groupies of my own yet, though.

13:28 devn: better way to do #(apply str (interleave " " ["A1" "A2" "A3"])) ?

13:28 * devn thinks he mixed up the syntax

13:29 amalloy: devn: clojure.string/join

13:29 devn: ,(apply str (interleave " " ["A1" "A2" "A3"]))

13:29 clojurebot: " A1"

13:29 amalloy: you also meant intperpose, not interleave

13:29 devn: blah thank you :\

13:29 amalloy: &(doc interpose)

13:29 sexpbot: ⟹ "([sep coll]); Returns a lazy seq of the elements of coll separated by sep"

13:29 devn: and of course..join..*doh*

13:32 stirfoo: Why would slime not pretty print an expanded macro (C-c RET)? Not sure if this is the correct place to ask that question, but there it is.

13:38 edw: Has the state of Clojure SLIME debugging advanced in the last couple months?

13:38 technomancy: edw: there's this: http://georgejahad.com/clojure/swank-cdt.html

13:39 edw: technomancy: Thanks!

13:40 Ruh roh: "Installing *should* now be just a matter of..." (Em. mine.)

13:51 matthias_: erm, java is currently using 1gb of ram... im not doing anything, just having swank open

13:54 pdk: ,(/ (+ .7 .9 1) 3)

13:54 clojurebot: java.lang.Exception: Unable to resolve symbol: .7 in this context

13:54 pdk: ,(/ (+ 0.7 0.9 1) 3)

13:54 clojurebot: 0.8666666666666667

14:03 fliebel: pdk: Floating point is lovely, eh?

14:04 amalloy: i don't get the joke. ##(/ 2.6 3) is basically the same, right? i wouldn't expect rounding errors for that

14:04 sexpbot: ⟹ 0.8666666666666667

14:11 znutar_: Is there some handy reference for the differences between java floating point and ieee754?

14:11 fliebel: &(/ (rationalize 2.6) 3)

14:11 sexpbot: ⟹ 13/15

14:22 chouser: ,(/ (+ 7/10 9/10 1) 3)

14:22 clojurebot: 13/15

14:22 chouser: ,(double (/ (+ 7/10 9/10 1) 3))

14:22 clojurebot: 0.8666666666666667

14:27 choffstein: What is the best way to set a default value for a function input?

14:29 Chousuke: choffstein: multiple arities?

14:30 eg. (defn foo ([] (foo :defval)) ([x] (do something with x)))

14:30 choffstein: yeah, I guess. so if I do (defn f [a b] ...), if b is not supplied, it has a default value. I assume this can only really be done using match cases on arity or with a map input, right?

14:31 Chousuke: yeah.

14:31 for that case, just supply both arities [a] and [a b]

14:31 choffstein: okay. thanks.

14:33 cemerick: choffstein: don't forget about keyword args

14:56 dnolen: interesting how fancy abstractions in Haskell, SML, and Ocaml, Scala don't play well with usability features like pattern matching...

15:12 angerman: yikes, why are ssl certs so damn expensive?

15:13 (and the system is flawed… just gives the client a warm and fuzzy feeling :( )

15:13 anyone got a sugestion?

15:13 MarkN3D: Seller's market, I guess

15:13 Did you check GoDaddy? I thought they had certs for relatively cheep

15:15 angerman: oh crap, what's that warrenty about?

15:15 kencausey: angerman: The value of an SSL certificate is in the certainty that it represents who it claims to represent.

15:15 cemerick: angerman: I'm idly investigating gandi.net. They seem to have very reasonable cert prices, along with a good assortment of other stuffs.

15:15 kencausey: angerman: As such, if the certifier does proper checking (aka labor) then the costs can be high.

15:17 angerman: kencausey: yes, yes, yes… but they ssl provider seem to focus on ecommerce and offer some insurance… :/

15:17 kencausey: doesn't ssl encrypt the data channel as well?

15:18 kencausey: I should say that the last time I got one I got it from GoDaddy

15:18 But this is for a non-public site so identification certainty is of little importance

15:18 angerman: of course, and for me that was the important part

15:19 we got along for years with a self-signed certificate but it became more and more annoying so it was worth about $30 per year to deal with it

15:19 angerman: yea right. that's all I neeed, the user should feel fuzzy because it has the *secure* feature feeling and I get a secured channel.

15:19 semperos: if I have a seq of seqs, all integers; how do I find the inner seq with the largest number in first position?

15:20 e.g. [ [1 2 3 4] [200 5 6 7 8] [9 10 11] ]

15:20 in this case, I want [200 5 6 7 8] returned

15:20 since 200 is larger than 1 or 9 (the first element of the other two vectors)

15:21 angerman: kencausey: yea, been going with self singed ssl for a while as well. But the more computer-challenged the people become the worse it gets.

15:21 * kencausey nods

15:22 angerman: hmm comodo (via namecheap) starts at 8,95/yr

15:23 markskilbeck: semperos: first and sort, I'd guess.

15:25 semperos: markskilbeck: actually, sort will save me work I was already doing; thanks

15:25 markskilbeck: semperos: ##(first (sort-by first > [[1 2 3] [200 4 5] [6 7 8]]))

15:25 sexpbot: ⟹ [200 4 5]

15:25 semperos: nice

15:26 choffstein: anyone use marginalia?

15:26 it looks ... awesome

15:26 semperos: yep

15:26 angerman: choffstein: marginalia?

15:26 semperos: quite nice

15:27 fogus' code documentation tool

15:27 choffstein: any gotchas I should be aware about?

15:27 angerman: semperos: ohh the literate code thing with markdown?

15:27 semperos: yep

15:27 angerman: yea, that looked nice

15:27 semperos: choffstein: not that I'm aware of

15:27 it's hosted on Github, so you can just leave fogus an issue if something is up :)

15:28 markoman: i have two problems to throw on table now

15:28 choffstein: Just wondering if it was as awesome as it looks before I jump in head first :D

15:28 semperos: as long as you understand it's not producing documentation like on clojure.org or javadoc

15:28 I just add it as a dev-dep and run "lein marg" do generate the docs

15:28 produces a single uberdoc.html file

15:28 that's it

15:28 markoman: first one is simple i want [1 2 3] -> "1,2,3"

15:30 semperos: ,(apply str (interpose "," [1 2 3]))

15:30 clojurebot: "1,2,3"

15:30 amalloy: augh. clojure.string/join

15:30 semperos: :)

15:30 where's the fun in that?

15:31 markoman: I'd check clojure.string for any string needs by default, including join

15:31 markoman: alright, will do that

15:32 rak85: hi, everyonde

15:32 *everyone

15:32 how do i check if a given string is in a list of strings?

15:32 i'm trying contains?

15:32 markoman: $source join

15:32 sexpbot: Source not found.

15:32 amalloy: clojurebot: contains?

15:32 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

15:32 rak85: but it's not returning properly...

15:32 markoman: $source clojure.string/join

15:32 sexpbot: clojure.string/join is http://is.gd/1eAPlt

15:33 rak85: (contains? [1 2 3 4 "adf"] "adf) -> false

15:33 sorry, (contains? [1 2 3 4 "adf"] "adf") -> false

15:33 amalloy: rak85: do you read what people say? i just asked clojurebot about contains, just for you

15:33 rak85: Yes, I read amalloy

15:34 semperos: ,(some #{"asdf"} [ 1 2 3 "asdf" ])

15:34 clojurebot: "asdf"

15:34 semperos: ,(some #{ "asdf"} [ 1 2 3 "asd" ])

15:34 clojurebot: nil

15:35 semperos: rak85: ^^

15:35 is that what you meant?

15:36 markskilbeck: rak85: amalloy told you why contains? *wouldn't* work.

15:36 * markskilbeck the Clarifier

15:55 markoman: ok, join is clear now. then other q is more complicated to present but im sure answer is simple

15:58 fliebel: chouser, fogus`: JoC has arrived! Thank you for writing that.

15:59 chouser: fliebel: Thanks, hope you enjoy it!

15:59 amac: forgot to order that

15:59 * amac off to amazon

16:00 chouser: amac: I don't know if you get the ebook with it when you order from amazon.

16:00 fliebel: chouser: What is the ebook anyway? Not the meap I assume?

16:01 chouser: The PDF is available now, laid out like the printed book (to wit, rather better than the early MEAP versions)

16:01 semperos: and has color :)

16:01 chouser: other formats will be available eventually: epub, mobi, etc.

16:03 markoman: so the question is here http://pastebin.com/BmZbkJZF how to loop list and get expected return

16:06 amac: chouser: good to know regarding the ebook, I love my kindle

16:07 chouser: markoman: maybe replace the 'let' line with (for [dtype (map :dtype division)]

16:07 hm, no that's not right

16:08 (defn form-generate division-coll (for [division division-coll] ...then your let, etc...))

16:09 markoman: yes, i was thinking i need to variables for division in there, let me test

16:09 phenom_: what's the easiest way to get the name of a function passed in as a parameter ?

16:09 chouser: just got my copy of JoC :) thnx for all the work !

16:10 chouser: phenom_: quite welcome. Fogus did most of the work, but I'll take the credit anyway.

16:11 choffstein: Anyone use marginalia that can tell me why my comments at the bottom of: https://github.com/newfoundresearch/construct-index/blob/master/src/construct_index/core.clj don't make it into the docs (http://github.com/newfoundresearch/construct-index/raw/master/docs/uberdoc.html)? Thanks.

16:13 For some reason, it just seems to ... stop working half way through my comments :D

16:15 markoman: im starting to love this channel and language, thanks chouser :)

16:17 working version http://pastebin.com/qAf3GdcQ

16:19 fogus`: choffstein: Can you modify the comments at lines 127-128 to remove the ## and -- ? They might be causing issues. Not sure yet though.

16:19 markoman: I seem to have this repeating pattern on my codes now: {:id (:id args)} its kind of transfering key from one map to other, not bad if its just id, but when it multiplies Im thinking if there is a shortcut

16:19 choffstein: i'll try it now fogus`

16:20 fogus`: Thanks

16:21 choffstein: Doesn't seem to make a difference

16:21 markoman: is it time for macros here?

16:23 fogus`: Weird. I'll investigate later tonight

16:23 Sorry about that

16:25 markoman: i think its just filtering map

16:26 choffstein: fogus`: No worries. It is an amazing tool :)

16:29 markoman: (select-keys args [:id]) -> {:id (:id args)} -> {:id 'some} I think

16:54 choffstein: man, it's amazing how much my network messes up my clojure work when I try to use clojars.

16:54 Things that don't compile now because of strange errors will work fine on my home network...

17:02 like, for example, 'resolve-uri' cannot be found in hiccup. Of course it can. But for some reason, lein deps just gets some whacky downloads on this network. It is ... strange.

17:03 jkkramer: choffstein: have you tried lein clean to see if it helps?

17:07 scottj: anyone know where the project fetcher is hosted?

17:08 choffstein: jkkramer: yep

17:17 wwmorgan: if I have a collection of key-value pairs [[:a :b] [:a :c] [:d :e]], how can I turn it into a map grouped by key? {:a [:b :c] :d [:e]} ?

17:19 raek: ,(group-by first [[:a :b] [:a :c] [:d :e]])

17:19 clojurebot: {:a [[:a :b] [:a :c]], :d [[:d :e]]}

17:20 chouser: ,(reduce (fn [m [k v]] (assoc m k (conj (m k []) v))) {} [[:a :b] [:a :c] [:d :e]])

17:20 clojurebot: {:d [:e], :a [:b :c]}

17:21 raek: ,(apply merge-with into (for [[k v] [[:a :b] [:a :c] [:d :e]]] {k [v]}))

17:21 clojurebot: {:d [:e], :a [:b :c]}

17:22 wwmorgan: thanks raek, chouser

17:23 chouser: ,(->> [[:a :b] [:a :c] [:d :e]] (group-by first) (map (fn [[k v]] [k (map second v)])) (into {}))

17:23 clojurebot: {:a (:b :c), :d (:e)}

17:23 scottj: (reduce (fn [m [k v]] (update-in m [k] conj v)) {} [[:a :b] [:a :c] [:d :e]])

17:24 Raynes: I thought I was in #perl for a moment there. What, with all these ways to do the same thing. :>

17:26 scottj: s/conj/(fnil conj [])/

17:26 sexpbot: <scottj> (reduce (fn [m [k v]] (update-in m [k] (fnil conj []) v)) {} [[:a :b] [:a :c] [:d :e]])

17:28 drewr: I have a script that bootstraps some code using eval, but eval insists on printing to stdout the result of the ns form inside

17:28 is there any way to turn that off or otherwise do what I'm doing?

17:30 polypus: best client lib for redis: clj-redis or redis-clojure or wrapping jedis or ??

17:31 fliebel: polypus: Or Aleph?

17:32 https://github.com/ztellman/aleph/blob/master/src/aleph/redis.clj

17:33 polypus: fliebel: ty, forgot about that one. looking better and better since i also want websockets

17:57 devn: clj-redis

17:57 polypus: that's your best bet...right now

17:58 Q: If I have a (defn [{:keys [foo bar]}] [foo bar]), is there an option I can use to retain the original map as something I can pass along?

17:59 raek: devn: {:keys [foo bar], :as m}

18:00 joshua__: Hmm. When I do lein deps I'm getting a slew of WARNING] POM for 'org.clojure:clojure:pom:1.2.0:compile' is invalid. It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for project org.clojure:clojure at /root/.m2/repository/org/clojure/clojure/1.2.0/clojure-1.2.0.pom

18:00 I have no idea what I'm doing wrong.

18:01 devn: raek: hmph, thought i tried that, guess not. thanks!

18:03 MarkN3D: joshua__: I seem to recall seeing something like that when using an old version of marginalia, does that help?

18:03 joshua__: MarkN3D, Nope, not really. I get that errors for -every- project I have. So I can't really do anything with Clojure right now =/

18:04 So I not only get it for Clojure, but for Enlive etc. When I use lein run it fails saying clojure.main not found.

18:04 MarkN3D: joshua__: Hmm, corrupted lein plugin?

18:04 raek: joshua__: maybe you could try to remove the files in ~/.m2/

18:04 MarkN3D: reinstall leiningen?

18:06 joshua__: raek, looks like that is working ;)

18:06 raek: maybe it was a corrupted download

18:07 joshua__: Might be. I'm on the school network which can cut out randomly.

18:08 MarkN3D: I'll have to remember that one

18:10 joshua__: Gah. Checksums keep failing..

18:10 A lot of: [WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for org/mongodb/mongo-java-driver/2.0/mongo-java-driver-2.0.pom - IGNORING

18:10 Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: end tag name </HEAD> must be the same as start tag <META> from line 1 (position: START_TAG seen ...snapshots/enlive/enlive/1.0.0-SNAPSHOT/maven-metadata.xml"></HEAD>... @1:361)

18:10 ???

18:11 raek: looks like you get HTML in your files

18:11 maybe a login portal or something

18:12 or a bad http proxy

18:26 joshua__: raek, ahh. Thank must be it. I have to go through a proxy, because I'm on the schools internet... this sucks. This also explains why I don't get the error when I ssh to my linode box.

23:02 choffstein: Any idea where I could be dredging up this error from (using hiccup): Exception in thread "main" java.lang.IllegalAccessError: resolve-uri does not exist (form_helpers.clj:1)

23:03 digging down the stack trace, it seems to be coming from me calling (:use [hiccup core page-helpers form-helpers]) in one of my name spaces

23:03 but I don't know why it would be giving that error

23:44 Why in the world am I getting this error?

23:44 * choffstein bangs his head against the table

23:46 choffstein: why ... why ... why

23:46 carllerche: Are there any clojure json parsers than can take a lazy seq and return a lazy seq/

23:46 amalloy: carllerche: don't think so. json objects are hashes

23:47 carllerche: amalloy: I'm trying to parse the campfire streaming API which returns a stream of json hashes... not sure of the best way to do it (my "learn clojure" project is trying to write a campfire bot)

23:49 choffstein: well, well, well...hiccup 0.3.0 works, but not 0.3.4. Interesting. I wonder why...

23:51 technomancy: I really hope hiccup is named after the hero of http://en.wikipedia.org/wiki/How_to_Train_Your_Dragon_(film)

23:55 why does this echo a newline despite the output redirection? rlwrap -m -q '"' /bin/true > /dev/null 2>&1

23:57 amalloy: technomancy: rlwrap uses ncurses or something doesn't it?

23:57 (fyi, foo &>/dev/null is shorthand for that)

23:58 justinlilly: http://i.imgur.com/dcVGX.png -- I don't see a newline? ... or at least not an extra one.

23:59 amalloy: good point. neither do i; that rlwrap produces the same output as echo -n, not echo, for me

Logging service provided by n01se.net