#clojure log - Nov 26 2010

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

2:19 Lajla: Chousuke, ajattelet että olen kanavahullu, kylläkö? =(

3:10 LauJensen: Morning all

3:15 mduerksen: Morning. Good to see I'm not the only one in a europian timezone :)

3:31 sthuebner: mduerksen: no, you're not ;-)

4:21 mduerksen: sthuebner: german, right?

4:23 LauJensen: mduerksen: thats Herr Huebner to you :)

4:26 AWizzArd: There are several germans here, mduerksen

4:26 Some of them btw in #Clojure.de too (:

4:29 bartj: is there any advantage to returning multiple values from functions

4:29 mduerksen: Oh wow, I didn't realize there was another channel for germany! :)

4:30 bartj: also, can someone please confirm that Clojure does not support returning multiple values from functions

4:34 mduerksen: bartj: what do you mean exactly by multiple values? A function can return a tuple of values, of course

4:35 bartj: mduerksen, I mean in Perl, Python you can do something like a,b = func(c)

4:35 mduerksen, of course, you can return a tuple of values

4:36 I was just curious to know why some languages support it specifically

4:36 also, if it was not possible for languages which treat functions as first class objects

4:38 timrod: bartj, if you do a,b = func(c) in python, func returns a tuple which is "destructured" into a and b

4:38 mduerksen: bartj: well, similar to your perl example, you could write something like this: (let [a b] (func c))

4:38 _ato: need an outer vector for the let: (let [[a b] (func c)] ...)

4:38 but yeah, that's virtually exactly the same as what python is doing

4:38 mduerksen: _ato: thanks

4:40 bartj: hmm, so you have to explicitly destructure it in Clojure, right ?

4:40 _ato: huh? not more than you have to do with Python

4:40 timrod: yes, just like you have to in python (and afaik in perl, but I'm not sure)

4:43 _mst: are you thinking multiple return values ala common lisp?

4:43 _ato: perhaps perl is weirder, due to the contexts stuff, but the principle is the same isn't it, you're just returning an array and then destructuring it?

4:45 bartj: _mst, I am afraid, I don't know CL

4:45 ok thanks, guys

4:45 _mst: common lisp's slightly different in how it handles multiple return values, in that if you're not interested in anything but the first one you can just pretend the others don't exist

4:46 _ato: how do you get at the other values?

4:46 _mst: for instance (setq foo (gethash :somekey my-hash)) would just bind the value taken from the hash to that var

4:46 if you want the other values things start to look an awful lot like destructuring:)

4:47 except usually you wouldn't bother, because you'd have to type multiple-value-bind and by the time you've finished typing that out you've generally lost interest...

4:47 _ato: ah, so it's a special purpose "let" for multiple return values?

4:47 _mst: yup

4:47 _ato: ick

4:55 sthuebner: mduerksen: yepp, german ;-)

4:58 Derander: I want to learn ocaml

4:59 sorry, random.

5:07 samx: If a specify a keyword in a namespace, like: (ns my.long.namespace) (def a { ::foo 10 }).. And then try to use it from another namespace with using an :as, such as: (ns my-namespace (:require [my.long.namespace :as mln])) (:mln/foo mln/a).. That does not seem to work, so that I'll have to do (:my.long.namespace/foo mln/a).. Can I get the one using a namespace alias to work somehow?

5:10 _ato: samx: try ::mln/foo

5:10 samx: thx

5:11 _ato: :: means resolve in current namespace (which includes resolving aliases)

6:12 sandGorgon: hi guys.. i was looking for solutions on how to recur on exception and I found this http://stackoverflow.com/questions/1879885/clojure-how-to-to-recur-upon-exception - I dont get why you need the macro. You can make do with the function only right ?

6:22 Tordmor: sandGorgon: The macro is there to wrap the passed form(s) into a function call. You'd have to do that yourself without it. So you can do without the macro only in so far as you could do without any macro.

6:25 sandGorgon: Tordmor, by passed form - do you mean the "body" that needs to be executed ? I'm still a little unclear on what the macro is wrapping and how

6:25 Tordmor: yes

6:26 sandGorgon: so if the body was, in fact, a function - then you dont need a macro. right ?

6:29 Tordmor: yes

6:29 sandGorgon: thanks

7:45 jegb: I use leiningen, emacs, and slime for compojure development. I use 'lein swank' from the console, and connect from emacs. This works fine. However, when I get an exception, the stack trace goes in the console. I would obviously like to get it in a slime debug buffer (sldb), so that I can inspect the frames, etc. How do I do this?

7:46 bartj: I need to show the complete stack-trace of tail-recursive calls to my colleague

7:46 this example from http://stackoverflow.com/questions/33923/what-is-tail-recursion is very appropriate

7:46 but, it is in python; can I do the same in Clojure

7:47 I mean show that the intermediate variables are not all stored on the stack!

7:52 oh well, I found the scheme explaination on the same page - http://stackoverflow.com/questions/33923/what-is-tail-recursion/33931#33931 much better

7:53 thanks

8:43 sandGorgon: a functional programming question - two functions need to be called one after the other (second doesnt use the return value of first, insofar as that is simply a status that the first function has successfully executed). Would you use "do" ?

8:44 stuartsierra: yes

8:44 But remember that most forms like fn, defn, and let all have an "implicit do"

8:45 opqdonut: that's not functional programming ;)

8:45 stuartsierra: true

8:46 mduerksen: nonetheless required from time to time :)

8:49 sandGorgon: you should always be aware of which form have an "implicit do" and which don't. I already fell into that trap with "if"

8:51 sandGorgon: mduerksen, trap with an "implicit do" ? you mean you assumed "if" had one ?

8:53 mduerksen: sandGorgon: yes, i had used an "if" without using the else form, then added some code afterwards that i wanted to be evaluated as well. that's where i discovered the "when" macro ;)

8:53 sandGorgon: ah... thanks guys

8:53 mduerksen: you should use "when" if you don't need the else form

8:54 sandGorgon: yup.. figured that one out

9:36 Guest18523: clojure? long-polling? comet?

10:13 serp__: how do I remove an element from a set?

10:14 AWizzArd: serp__: disj

10:14 ,(disj #{10 20 30} 30)

10:14 clojurebot: #{10 20}

10:14 serp__: tyvm

10:21 pppaul: can i use curl in clojure?

10:22 stuartsierra: libcurl the library or curl the command-line program?

10:27 pppaul: libcurl

10:27 or the commandline too

10:27 tool

10:28 i guess libcurl would be preferred

10:29 cemerick: stuartsierra: morning :-)

10:30 We're good to go on hudson; I'm about to start my writeup of the whole process and the outstanding policy / process issues.

10:30 Do you have any open questions/issues on the clojure + classic contrib builds?

10:32 stuartsierra: morning

10:32 I just pushed updates to "classic contrib" that builds from the base POMs.

10:33 What about providing for "alternate path to clojure.jar" in the contrib base pom?

10:34 cemerick: right, right

10:35 stuartsierra: You'll want to use >= 0.0.20 of the pom.oss-deploy POM, and take a look at the hudson configuration in the build.poms job. The post-maven build step + disabling the maven release plugin's auto-push prior to the nexus deploy is a must-have IMO.

10:38 stuartsierra: I used pom.contrib as the parent of clojure-contrib/modules/parent

10:39 serp__: I have a function (f [x y]) I want to do (f (f (f (f a p) q) r) s). is there a "better" way to do this than with reduce?

10:40 magnet_: serp__, of teeworlds? :)

10:40 stuartsierra: serp__: reduce *is* the better way

10:40 serp__: magnet_: maaaybe :S

10:40 magnet_: serp__, small world

10:40 :)

10:40 serp__: :P

10:42 stuartsierra: cemerick: Just pushed contrib/modules/parent/pom.xml with parent pom.contrib:0.0.19

10:43 cemerick: right, sorry, 0.0.20 is the current snapshot

10:45 stuartsierra: updating config in hudson now to match build.poms

10:47 pppaul: hey, can someone tell me if libcurl is in clojure?

10:47 abedra: stuartsierra: you know we decided yesterday that anyone who breaks the build has to sort out and eat the butter popcorn jelly beans at the office

10:48 serp__: stuartsierra: all right thanks

10:48 stuartsierra: abedra: I don't break builds, I break heads.

10:49 abedra: stuartsierra: me email says that you have to eat the butter popcorn AND the black licorice ones

10:49 kryft: Oo, black licorice

10:49 abedra: s/me/my

10:49 :)

10:51 cemerick: stuartsierra: does this look right? https://gist.github.com/c9a316b66f78e4a9cbef

10:51 stuartsierra: pppaul: libcurl is written in C, you can call it from Clojure if you have JNI or JNA bindings to it

10:51 cemerick: there's more to it than that

10:51 hang on

10:52 cemerick: https://github.com/clojure/clojure-contrib/blob/60e7162a5a29615cae3e6d494a3653c34b6ddb66/modules/parent/pom.xml#L60

10:53 cemerick: stuartsierra: what's the why the default profile dep instead of just having the clojure dep with a parameterized version in the top-level deps?

10:54 * cemerick can't type, talk, or think, apparently :-x

10:55 stuartsierra: cemerick: as I recall, that was how I tried to do it the first time. It didn't work.

10:55 I think if you want to override the dep in a profile, that dep has to be part of a profile to begin with.

10:59 cemerick: Any idea what this means? http://build.clojure.org/job/clojure-contrib/275/console

10:59 It says "You can't push to git://github.com/richhickey/clojure-contrib.git" but that isn't configured anywhere as the repo.

11:00 oh, wait, it is set wrong...

11:01 cemerick: stuartsierra: first, that should be a POST build step, not pre

11:02 stuartsierra: it's trying to push @ richhickey/contrib.git because that's origin in the hudson job's workspace.

11:03 I strongly suggest checking off "Wipe out workspace" in the Advanced section of the job's SCM config area.

11:04 stuartsierra: cemerick: ok, trying again

11:06 cemerick: stuartsierra: We have a general hudson configuration problem. Getting everything we want on every job is going to be a PITA, nevermind sane change mgmt over time.

11:07 I don't have any solutions on that topic at the moment. I was hoping for a baseline-hudson-job-config plugin or somesuch, but haven't found one yet.

11:08 stuartsierra: Yeah, that's annoying.

11:09 For now we'll just have to get one right and make sure to copy that config everywhere.

11:10 Making sure old projects are kept up-to-date will be the hard part.

11:12 cemerick: stuartsierra: yeah; we've only 2 jobs that are OSS-capable so far, and it's already irritating.

11:12 stuartsierra: ok, updated clojure-contrib Hudson config, failed for a different reason

11:13 http://build.clojure.org/job/clojure-contrib/277/console

11:13 cemerick: I saw.

11:14 stuartsierra: I'm not clear on what actually failed.

11:15 stuartsierra: cemerick: "Authentication failed: The host was not known and was not accepted by the configuration: build.clojure.org"

11:15 but what does that mean ?

11:15 cemerick: right, that's what I mean, I don't understand that.

11:15 stuartsierra: is this the first time you've tried deploying a snapshot to OSS for contrib?

11:16 stuartsierra: ah

11:16 wait

11:16 the top-level contrib POM has a <repository>

11:17 cemerick: Shouldn't all of the deployments failed if that's the problem?

11:17 stuartsierra: cemerick: no, because they inherit from modules/parent, not the top-level pom

11:17 cemerick: ah

11:18 stuartsierra: FYI, IIUC, the groupId must be org.clojure. That's what our creds have privs to release (perhaps that doesn't apply to snapshots).

11:19 stuartsierra: oh piffle

11:19 That probably means changing the artifactId of every module.

11:20 cemerick: stuartsierra: Maybe I'm wrong; but if so, then we'd be able to deploy releases of other projects' artifacts...

11:20 stuartsierra: right… unless it's a prefix match

11:20 doubtless that's too much to hope for

11:21 cemerick: We need to set up a dummy project for testing deployments and such. I've been using build.poms for that, but that's got to end.

11:21 stuartsierra: Good point.

11:21 cemerick: We should set up a project and hudson job just for stuff like experimenting with groupId, etc.

11:22 stuartsierra: With just enough code to test things like plugins and AOT-compilation.

11:24 serp__: how do I change a root binding? I want to set the root binding of *out* to the *out* in the current thread

11:25 stuartsierra: (doc alter-var-root)

11:25 clojurebot: DENIED

11:25 cemerick: stuartsierra: no parent defined in the top level POM

11:25 stuartsierra: serp__: well, alter-var-root is what you want

11:25 cemerick: Dude, it's not your day. :-P

11:25 stuartsierra: yeah

11:25 ok

11:26 cemerick: This is sorta water under the bridge at this point, but: why the separate parent pom, and not just point modules back at the top-level?

11:27 stuartsierra: No big reason, seemed easier at the time.

11:27 Ok, take #279

11:34 cemerick: shazam

11:34 stuartsierra: Thank you, ladies and gentlemen, I'll be here all week.

11:35 N.B.: This is building on Clojure 1.2.0. Can't build on 1.3.0-master-SNAPSHOT because it's not deployed to OSS.

11:36 cemerick: right.

11:36 One thing at a time :-)

11:36 stuartsierra: OK, contrib pom 0.2.0-SNAPSHOT has the clojure.jar system dep. It looks good here with my local nrepl checkout. See how it fares on your end.

11:36 I'm going to be logging off of irc in ~20 min. Ping me on email if there's an issue. Look for that process writeup later today.

11:39 stuartsierra: Will do.

11:39 Heading out to lunch in a few minutes myself.

11:44 cemerick: process writeup can go on the dev.clojure.org wiki

11:46 cemerick: stuartsierra: Of course.

11:53 stuartsierra: cemerick: Can't build clojure-contrib with "mvn -Dclojure.jar ..."

11:53 "ClassNotFoundException: clojure.lang.Compile"

11:53 cemerick: hrm

11:54 serp__: why is (alter-var-root *out* (constantly *out*)) wrong?

11:54 stuartsierra: cemerick: Why <dependencyManagement> in the alternate profile?

11:55 Instead of just <dependencies>

11:55 ?

11:55 serp__: You need the Var #'*out*

11:55 serp__: aha..

11:56 ty

11:58 stuartsierra: cemerick: This seems to work in the pom.contrib: https://gist.github.com/716954

12:01 cemerick: stuartsierra: yeah, that's better -- I'm actually more confused as to why it's working as-is for me locally.

12:02 stuartsierra: yeah, dunno

12:03 Try running "mvn -Dclojure.jar=… clojure:repl" and see what version string it prinst out.

12:04 cemerick: as expected, 1.1 when I use that jar…

12:05 anyway

12:05 stuartsierra: dep mgmt eliminated on HEAD

12:06 stuartsierra: Got it, works for me.

12:09 replaca: stuartsierra: did you see I made a couple of hacks to c.c.java-utils?

12:10 stuartsierra: replaca: no, sorry

12:11 replaca: stuartsierra: It wasn't loading right after file and as-str had been removed cause other stuff used them

12:11 stuartsierra: I'm just maintaining the build.

12:11 I do not want to maintain everything else.

12:11 replaca: stuartsierra: it seems obviously like the right thing to me, so I just went ahead and did it

12:11 stuartsierra: I actually want everything else to die as quickly as possible.

12:12 replaca: stuartsierra: I second that. It's a bear now

12:12 stuartsierra: ok, I really am going to lunch

12:12 replaca: enjoy!

12:26 anonymouse89: I'm having some trouble with clojure.xml/parse. The file I'm parsing does not have a root binding so xml/parse throws an exception. How do I get around this? Is there a way to concat InputStream's to add <root> and </root>?

14:31 jweiss_: what exactly are variables like *print-meta* (from clojure.core ns) that i can do set! on them. but it doesn't work for anything that i create using def or defvar.

14:31 ,(set! (defvar x 1) 2)

14:31 clojurebot: java.lang.Exception: Unable to resolve symbol: defvar in this context

14:32 jweiss_: ,(set! (clojure.contrib.def/defvar x 1) 2)

14:32 clojurebot: DENIED

14:32 jweiss_: bah

14:37 stuartsierra: Those Vars are given thread-local bindings in the REPL

14:39 jweiss_: aha, that explains a lot

15:11 stuartsierra: BOOM: http://dev.clojure.org/jira/browse/CLJ-681

15:56 joshua__: How do I match just the first <div class="some_class"> with an enlive selector?

15:58 raek: (-> ... (select [:.some_class]) first) ?

16:00 it might be possible to do that with just a selector, but I haven't looked very deepl into that yet

16:05 hugod: cemerick: you could always configure hudson jobs with pallet :)

16:06 patrkris: Hi folks. I've been out of the Clojure loop for a while. Tell me, has cake won over leiningen?

16:06 maacl: Is there a safe variant of read-string that will only read data (i.e. no function/macro calls)?

16:06 Raynes: patrkris: It hasn't 'won'. Leiningen is still very popular.

16:07 patrkris: I don't think they're really competing for blood though.

16:07 Cake has grown quite a bit though, so I definitely suggest checking it out. I use it myself.

16:07 patrkris: Raynes: I know. :) But I don't know what to choose. Maybe it doesn't matter much.

16:08 Raynes: It's really down to which feature set you like more. Just check out the READMEs and you should be able to make an informed decision.

16:09 stuartsierra: And then switch to Maven when you need it.

16:09 patrkris: Raynes: Thanks. You wouldn't happen to know about a 'repository' of cake task libraries?

16:09 joshua__: I figured your way would work raek, but it felt wrong for there not to be built in support for it. Turns out there was. This works as I wanted: (def *project-selector* [[:.project html/first-child]])

16:09 html being enlive-htim :as html

16:12 raek: ah, so it matches every element with the project class that is the first of its kind which among other project class sibling elements?

16:12 my code snipped would select the first element with the project class that occurs in the document

16:37 maacl: Is there a safe variant of read-string that will only read data structures?

16:40 joshua__: Is there a difference?

16:41 raek: joshua__: maacl's question or mine?

16:42 maacl: you can disable the #= reader macro by rebinding *read-eval*

16:42 maacl: (defn safe-read-string [s] (binding [*read-eval* false] (read-string s)))

16:42 joshua__: yours

16:42 raek: ok

16:43 maacl: ah - thanks raek

16:43 raek: if element E1 and E2 has E3 as their parent element, then first-child will only select E1 in that case

16:44 but if E1 and E2 are not siblings, both will be selected, I tihnk

16:45 joshua__: <project 1><project 2></project 2><project 3></project 3></project 1> would have my code select project 2?

16:47 raek: I think so, but I haven't tested it

16:47 should be fairly easy to test... one moment please...

16:47 joshua__: I'll test it right now and get back to you. Going to test it using w3schools.

16:49 LOPP: #= ?

16:49 joshua__: Looks like it is selecting project 1.

16:50 serp__: I want to append sequences to eachother, but I can't find the function append.. am I doing this wrong?

16:51 joshua__: Well, it looks like it is selecting all three of them with how css selectors work.

16:51 since the first one contains the other two.

16:52 LOPP: what's #=

16:54 joshua__: Should be able to select sub-projects with something like [[:.project first-child :.project first-child]] if it maps back to css selectors, but I haven't tested it. If you ended up seeing something different let me know.

16:55 Everything is working for me now though.

16:57 `(find-doc "#=")

16:59 Came up with something about how it is the EvalReader.

17:00 dmart_: #=(Integer. 12)

17:00 &(Integer. 12)

17:00 sexpbot: ⟹ 12

17:00 dmart_: it evals the stuff after the #=

17:00 s/stuff/form/ I guess?

17:02 LOPP: &(doc read-string)

17:02 sexpbot: ⟹ "([s]); Reads one object from the string s"

17:02 stuartsierra: #= does read-time evaluation

17:03 LOPP: really?

17:03 how is that useful?

17:03 stuartsierra: in rare cases for data serialization

17:03 dmart_: I've found it useful for quick serialization / reading back

17:05 &(str "#=(java.util.Date. \"" (.toString (java.util.Date.)) "\")")

17:05 sexpbot: ⟹ "#=(java.util.Date. \"Fri Nov 26 14:05:29 PST 2010\")"

17:05 LOPP: ok, what now?

17:06 dmart_: if you passed that string to read-string in with read-eval true, you'd get a new Date object equal to the one printed out

17:07 LOPP: so read-string evals the string?

17:08 dmart_: well, type it in the repl and see what happens

17:08 read-string is sort of analogous to eval in javascript I guess?

17:09 if that helps

17:10 patrkris: Raynes: is it possible to have the non-dev dependencies in the class path when invoking a custom task?

17:13 Raynes: patrkris: re cake task libraries: There is a list of plugins in the wiki on the cake github page. re non-dev dependencies: that is what bake is for, if I understand your question properly.

17:13 * Raynes is sorry for being absent. Coming and going because he is watching a game.

17:13 patrkris: Raynes: Thanks. I'll take a look at bake.

17:19 Raynes: I looked through the wiki but didn't find an explanation of bake. Is it available anywhere?

17:21 Raynes: Ah... it's just using bake inside your task? I'll give it a try.

18:54 jjido_: can you generate a not-so-random sequence of numbers? i.e. a sequence that looks random but is partially sorted.

19:02 ,(letfn [(shuffle [s] (flatten (swap (split s (int (rand (count s)))))))] (shuffle [1 2 3 4 5 6]))

19:02 clojurebot: java.lang.Exception: Unable to resolve symbol: swap in this context

19:03 jjido_: ,(letfn [(shuffle [s] (flatten (reverse (split s (int (rand (count s)))))))] (shuffle [1 2 3 4 5 6]))

19:03 clojurebot: java.lang.Exception: Unable to resolve symbol: split in this context

19:03 jjido_: ,(letfn [(shuffle [s] (flatten (reverse (split-at s (int (rand (count s)))))))] (shuffle [1 2 3 4 5 6]))

19:03 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

19:03 jjido_: ,(letfn [(shuffle [s] (flatten (reverse (split-at (int (rand (count s))) s))))] (shuffle [1 2 3 4 5 6]))

19:03 clojurebot: (3 4 5 6 1 2)

19:03 jjido_: ,(letfn [(shuffle [s] (flatten (reverse (split-at (int (rand (count s))) s))))] (shuffle [1 2 3 4 5 6]))

19:03 clojurebot: (2 3 4 5 6 1)

19:04 jjido_: ,(letfn [(shuffle [s] (flatten (reverse (split-at (int (rand (count s))) s))))] (shuffle (range 10)))

19:04 clojurebot: (5 6 7 8 9 0 1 2 3 4)

19:05 jjido_: how do I repeat that n times on the result?

19:07 ,(letfn [(shuffle [s _] (flatten (reverse (split-at (int (rand (count s))) s))))] (reduce (partial shuffle (range 10)) (range 3))

19:07 clojurebot: EOF while reading

19:07 jjido_: ,(letfn [(shuffle [s _] (flatten (reverse (split-at (int (rand (count s))) s))))] (reduce (partial shuffle (range 10)) (range 3)))

19:07 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: sandbox$eval724$shuffle

19:08 jjido_: ,(doc reduce)

19:08 clojurebot: "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item...

19:08 raek: jjido_: in what way should it be random and sorted?

19:08 jjido_: raek: I am not very particular...

19:10 ,(letfn [(shuffle [s _] (flatten (reverse (split-at (int (rand (count s))) s))))] (reduce (partial shuffle) (range 10) (range 3)))

19:10 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial

19:10 jjido_: ,(letfn [(shuffle [s _] (flatten (reverse (split-at (int (rand (count s))) s))))] (reduce shuffle (range 10) (range 3)))

19:10 clojurebot: (3 4 5 6 7 8 9 0 1 2)

19:11 jjido_: ,(letfn [(shuffle [s _] (flatten (reverse (split-at (int (rand (count s))) s))))] (reduce shuffle (range 10) (range 3)))

19:11 clojurebot: (3 4 5 6 7 8 9 0 1 2)

19:12 raek: jjido_: also, there is a rand-int function

19:12 jjido_: raek: thanks

19:13 Raynes: &(sort (repeatedly 30 #(rand-int 10000000)))

19:13 sexpbot: ⟹ (38797 128400 1347904 1415320 1583404 1589076 1676210 1777652 2381785 2512796 2552871 3177841 4076783 4195345 4439859 4894263 5045857 5247199 5491817 5519674 5768961 5826224 5864209 6255536 8033027 8782210 8935694 9001985 9481409 9584555)

19:13 jjido_: Raynes: nope that is much too sorted

19:13 Raynes: I have no clue what you're asking for anyway. ;p

19:14 raek: ,(let [[l r] ((juxt take drop) 3 (range 10))] (concat r l))

19:14 clojurebot: (3 4 5 6 7 8 9 0 1 2)

19:15 jjido_: raek: that is cleaner

19:15 raek: ,(let [[l r] (split-at 3 (range 10))] (concat r l))

19:15 clojurebot: (3 4 5 6 7 8 9 0 1 2)

19:15 raek: even better.

19:16 (although, in the other example I got to use juxt)

19:16 jjido_: and for the repeat?

19:16 I want to shuffle again

19:18 slyrus_: so... any good blog posts on migrating one's code to clojure 1.3?

19:18 raek: (letfn [(random-swap [coll] (let [[l r] (split-at (random-int (count coll) coll)] (concat r l)))] (nth (iterate random-swap (range 20)) 5))

19:18 ,(letfn [(random-swap [coll] (let [[l r] (split-at (random-int (count coll) coll)] (concat r l)))] (nth (iterate random-swap (range 20)) 5))

19:18 clojurebot: Unmatched delimiter: ]

19:19 raek: ,(letfn [(random-swap [coll] (let [[l r] (split-at (random-int (count coll) coll))] (concat r l)))] (nth (iterate random-swap (range 20)) 5))

19:19 clojurebot: java.lang.Exception: Unable to resolve symbol: random-int in this context

19:19 raek: ,(letfn [(random-swap [coll] (let [[l r] (split-at (rand-int (count coll) coll))] (concat r l)))] (nth (iterate random-swap (range 20)) 5))

19:19 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$rand-int

19:19 raek: ,(letfn [(random-swap [coll] (let [[l r] (split-at (rand-int (count coll)) coll)] (concat r l)))] (nth (iterate random-swap (range 20)) 5))

19:19 clojurebot: (4 5 6 7 8 9 10 11 12 13 ...)

19:21 raek: jjido_: ^^

19:21 jjido_: raek: great!

19:24 huh, I need to mix in something else. The swaps tend to cancel each other quickly

19:24 raek: how curious... the swap parts operation is only "rolling" the sequence

19:25 and the composition of two of those could be seen as one "swap"

19:25 jjido_: when playing cards I also interleave to shuffle

19:25 raek: if you think of the sequence as a ring, then the sorted order will never be broken (except of the 20 -> 0 discontinouity...)

19:26 jjido_: yes

19:26 raek: what you go here would be something that is know as a "Norwegian shuffle" in Sweden.

19:27 jjido_: can't be good ;) ;)

19:27 raek: most probably, it is known as a "Swedish shuffle" in Norway too :-)

19:28 anyway, if you modify the swap code to reverse on of the halves, it would randomize it a bit more

19:28 jjido_: yes I just tried that

19:28 raek: (concat r l) -> (concat r (reverse l))

19:36 jjido_: Oh well... That was to test a sorting algorithm. My optimisation does not help much more with partially sorted data as compared to random. Kind of bad.

19:45 slyrus_: technomancy: around?

19:54 raek: does someone recall how to make swank-clojure listen for only one connection and then stop listening?

19:55 Raynes: raek: Doesn't not passing dont-close do that? However, that would be the default.

19:57 raek: no, but it used to, I think...

19:57 now I can connect to the same port multiple times

19:57 (and to my friend's swank server too)

19:58 since I'm not alone on my server, I thought it might be time to tighten up the security...

19:59 hrm... is there any stop-repl fn in swank-clojure?

20:08 the source of the current version of swank-clojure does not contain "dont-close" at all... :/

20:13 slyrus_: ,(case nil nil 3)

20:13 clojurebot: java.lang.NullPointerException

20:14 slyrus_: huh?

20:21 raek: ,(case nil 1 2)

20:21 clojurebot: java.lang.IllegalArgumentException: No matching clause:

20:21 raek: weird

20:27 slyrus_: seems bogus to me

20:33 joshua__: I have a question.

20:34 Is this comic (http://xkcd.com/627/) appropriate for even questions asked to the people of this channel?

21:08 mister_roboto: ~seen cermick

21:08 clojurebot: Huh?

21:15 Raynes: $seen cemerick

21:15 sexpbot: cemerick was last seen quitting 4 days and 2 hours ago.

21:20 KirinDave: Damn, why hasn't anyone told me about lamina?

21:20 This is pretty cool.

21:46 jimdagem: hi

21:49 replaca: KirinDave: I think's Zach has been discussing it on Jira

21:49 KirinDave: It's pretty neat.

21:49 And gloss is something I was writing awhile ago but never finished, for plt-scheme.

21:49 Very useful.

21:49 replaca: the boy's on a roll :)

21:53 KirinDave: Thank you so much, clojurebot

21:53 replaca: hiredman: you here?

21:54 jimdagem: is clojurebot written in clojure?

21:54 replaca: It seems to have started doing that when someone (or at least me) checks something into contrib

21:54 jimdagem: yup

21:54 jimdagem: https://github.com/hiredman/clojurebot

21:57 Raynes: No way. It's written in Haskell, of course.

21:58 jimdagem: lol

21:58 Raynes: $botsnack

21:58 sexpbot: Raynes: Thanks! Om nom nom!!

21:59 jimdagem: can anyone provide or direct me to a good compare-and-contrast of Haskell and Clojure?

22:19 Raynes: wooby: This keyboard is fantastic. <3

22:20 danlarkin: which keyboard?

22:21 Raynes: Das ultimate.

22:21 He gave me one at the conj.

22:21 I switched to it last night. Used to use the same keyboard you use, iirc. MS ergo 4000?

22:22 danlarkin: moving past the weirdness of you knowing which keyboard I use, yes

22:23 Raynes: The reason I wanted to try a Das is because of your discussion with technomancy and others a couple of months ago. Just happened to remember.

22:24 danlarkin: I enjoy the split

22:24 Raynes: Yeah, the split was always nice.

22:33 _ato: the Das is great, I use it as well

22:36 I can't use ergonomics, I never learned to type in the "proper" way. I type fast and without looking, just I inevitably end up trying to reach across the split

22:36 Raynes: _ato: I always did that with my other keyboard!

22:37 I'm a two-three finger typer. Never learned to type properly.

22:37 Not counting my thumb.

22:37 leifw: if I didn't bring my laptop everywhere and move it around my house all the time, I'd still be using the kinesis I got a few years back

22:37 those things are fantastic

22:38 _ato: I'm a full five fingeer typist, but just learnt by typing a heck of a lot rather than by doing formal lessons

22:38 leifw: but you have to be a traditional typist for it to make sense

22:38 Raynes: It looks neat. Not sure I'd be able to tolerate it.

22:38 leifw: the main nice bit is that it brings all the pinky keys to the thumb

22:38 which is particularly good for emacs

22:39 Raynes: _ato: Well, so am I, if you count hitting the 'enter' key with my pinky. ;)

22:40 And, of course, capslock which is control.

22:44 _ato: yeah, I do the capslock control thing as well. My brother actually swaps caps-lock and backspace, hits control with his palm (which doesn't usually work too well on a laptop)

22:45 so if I use his computer inevitably end up deleting everything I'm trying to work on :p

22:45 hippiehunter: what is the correct order for accessing a field in a map/record/whatever, (:field instance) or (instance :field) ? it looks to my noob eyes like both work but I'm sure there is a preferred way

22:46 also das ultimate S ftw

22:47 _ato: hippiehunter: (:field instance) has the benefit of working when instance is nil

22:47 hippiehunter: does it just return nil as a result?

22:47 _ato: yep

22:48 hehe, I guess other people might say that (instance :field) has the benefit of barfing when instance is nil :p

22:56 hippiehunter: is try catch the best way to interact with java exceptions from clojure?

23:03 _ato: hippiehunter: yes

23:15 hippiehunter: is there a better way to debug in clojure (aside from just not making bugs)? I'm using netbeans and enclojure and the breakpoint fidelity is very low. I seem to be able to step on/break on about 1/4 of the lines

23:25 leifw: dunno, I usually just use a repl and this macro:

23:25 (defmacro dbg

23:25 [x]

23:25 `(let [x# ~x]

23:25 (binding [*out* *err*] (println '~x "=" x#))

23:25 x#))


23:26 sorry about the big paste

23:26 forgot whose blog I got that from but it's nice

23:32 _ato: hippiehunter: see also: http://stackoverflow.com/questions/2352020/debugging-in-clojure

23:46 hippiehunter: as far as I can tell, dotrace doesnt interact well with jetty could just be that I'm using it wrong though

23:47 never mind I figured it out

23:56 ossareh: anyone done much with hiccup? I've a loop which returns two nodes which are at the same level in the DOM as eachother and I'm struggling to understand how this should be returned.

23:56 (for [data data-list]

23:57 (do [:tr [:td (:msg data)]] [:tr [:td (:othermsg data)]]))

23:57 naturally that only returns the last <tr/>

23:57 and I'm stumped on how to get both back.

23:58 _mst: maybe try replacing "do" with "list"?

23:58 I think lists get automatically flattened (although it's been a little while since I used hiccup)

23:59 ossareh: nailed it _mst !

23:59 thanks

23:59 clojurebot: give _mst props

Logging service provided by n01se.net