#clojure log - May 28 2012

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

0:04 technomancy: amalloy: CL's reader syntax for vectors implicitly quotes

0:04 it's indescribably horrid.

0:15 amalloy: yes, that's how i remembered it, but i thought maybe my mind was just blocking out some even more painful memory

0:38 OwenOu: hi, i would like to know a way to improve this piece of code, (defn make-keyword [word]

0:38 (let [word (str/trim word)]

0:38 (->> (str/split word #"(\s+|-|_)")

0:38 (map str/lower-case)

0:38 (interpose \-)

0:38 str/join

0:38 keyword)))

0:38 Raynes: It looks a lot better on refheap.com. :p

0:38 OwenOu: don't like the "let" to trim the word, but not sure how to pass word into "str/split"

0:38 Raynes: What is this code meant to do?

0:39 (And seriously, if you don't mind, paste it on refheap.com)

0:39 OwenOu: Raynes: make a random string into keyword

0:39 Raynes: Is there a particular reason you can't just use 'keyword'?

0:39 OwenOu: https://www.refheap.com/paste/2893

0:40 Raynes: the string can be separated by space

0:40 Raynes: One thing: ##(keyword "foo_bar") ; you can have underscores in keywords.

0:40 lazybot: ⇒ :foo_bar

0:41 OwenOu: but how about "foo bar"?

0:41 amalloy: you usually shouldn't be making random strings into keywords anyway

0:42 but it's perfectly possible to just leave in the space: ##(keyword "pretty much any string can be a keyword")

0:42 lazybot: ⇒ :pretty much any string can be a keyword

0:43 OwenOu: amalloy: i would like to convert the space to "-" and append the string

0:44 Raynes: Well, the point is that you probably don't need to.

0:44 OwenOu: my problem is if i make str/trim as the first function in ->>, i can't pass its result to str/split

0:44 Raynes: Keywords can have spaces in them. More importantly, why do you need keyword for this particular problem?

0:44 keywords*

0:45 OwenOu: Raynes: maybe not necessary a keyword, i just need to make it as the key for a map, it can be string

0:45 but the requirement is to replace all spaces with "-"

0:45 say "foo bar" -> "foo-bar"

0:46 Raynes: &(.replace "foo bar" " " "-")

0:46 lazybot: ⇒ "foo-bar"

0:46 OwenOu: Raynes: but str/trim has to come first, otherwise " foo bar" -> "—foo-bar"

0:47 Raynes: Note that the existence of ->> does not necessarily mean it is a requirement.

0:47 If your code doesn't work right with it, it probably isn't the pattern it is designed for.

0:47 OwenOu: does ->> only work for function that takes the previous result as the last argument?

0:48 like str/split, the argument i get for the previous result, e.g., str/trim, is not the last one, e.g., (str/split word #"\s+")

0:49 word is in the middle

0:50 Raynes: &(-> " foo bar baz_quux" clojure.string/trim (clojure.string/replace #"(\s+|-|_)" "-"))

0:51 lazybot: ⇒ "foo-bar-baz-quux"

0:51 Raynes: OwenOu: ^

0:52 &(-> " foo BAR baz_quux" .toLowerCase clojure.string/trim (clojure.string/replace #"(\s+|-|_)" "-"))

0:52 lazybot: ⇒ "foo-bar-baz-quux"

0:52 Raynes: That should do the same thing you wanted, right?

0:52 I would just use the string rather than convert to a keyword though.

0:52 OwenOu: What's the difference between -> and ->>

0:53 Raynes: (-> foo (bar baz)) = (bar foo baz); (->> foo (bar baz)) = (bar baz foo)

0:53 The difference is that -> threads each form in as the second argument, while ->> threads it as the last.

0:54 OwenOu: Raynes: what if i need both?

0:54 i guess i have to (-> ( ->> xxx) xxx)

0:55 Raynes: Or just don't use either of them.

0:55 metellus: then neither will help on its own

0:55 OwenOu: i guess i would need comp and partial in this case?

0:55 Raynes: You don't *have* to use these things just because they exist. If they make one particular piece of code easier and cleaner to express, then use them. Otherwise don't.

0:55 For what case?

0:56 The code I just gave you should suffice, right?

1:02 OwenOu: Raynes: that's sufficient, still trying to understand the difference between -> and ->>

1:02 thanks

1:02 coventry: What does it generally mean when the repl just says "; Evaluation aborted" without providing a backtrace?

1:03 Raynes: coventry: Means you should type (pst *e)

1:03 :p

1:04 coventry: Thanks. Why does that happen? (I'm doing this in swank, in case it matters.)

1:04 Raynes: Usually swank opens up a buffer with the stacktrace.

1:04 Not sure I've ever seen it not do that.

1:05 OwenOu: Raynes: can u help me to understand why it uses ->> here? https://www.refheap.com/paste/2894

1:05 this is an example from the clojure programming book

1:06 amalloy: i used to always get stacktraces, and then eventually i did something (what?) and now like a quarter of the time, just ; Evaluation aborted

1:06 coventry: Raynes: I'm sure it's wrongheaded clojure code, but I have some which is reliably having that effect: http://pastebin.com/tiLTmJW9

1:07 It's happening to me less frequently than that. Maybe a tenth of the time.

1:07 amalloy: coventry: whaaaaat is that code

1:08 coventry: That is my ongoing attempt to solve 4clojure problem #69.

1:08 amalloy: hey, that was my guess!

1:09 or at any rate it looks like an attempt to write merge-with

1:09 coventry: yep

1:10 amalloy: well, the first issue seems to be that you're using contains? wrong

1:10 ~contains

1:10 clojurebot: contains? checks whether an indexed collection (set, map, vector) contains an object as a key. to search a sequence for a particular object, use the `some` function, which accepts a predicate. if you want to only match a certain object, you can use a set as the predicate: for example, (some #{5} (range)) finds the first occurrence of 5

1:10 amalloy: like, you're mapping over the values of mm, and then treating those as if they were keys in s/mm

1:11 coventry: Ohhh, I'm such a dope. Thanks for the pointer.

2:47 Malondron: Hi, I have a clolurescript question: I am not really familiar with javascript, but am using it for some simple things. Now I want to change to clojurescript. NowI have a problemthough: how do I access specific elements in an element containing a list(vector) of items ,e.g. the different option items in an select element? (.. form -select-name -options) gives me the list of options, but I cannot find out a way to get the [0] element. I

2:47 think I have tried every likely way now without luck.

2:49 ivan: maybe `into` the Array into a vector first?

2:50 some CLJS users here might know better

3:00 borkdude: Malondron what is the type of your collection?

3:01 Malondron don't know much about clojurescript, but if the collection is seqable, you can just call first on it: &&(first [1 2 3])

3:02 amalloy: good try, borkdude: ##(first [1 2 3])

3:02 lazybot: ⇒ 1

3:03 borkdude: amalloy I keep forgetting this notation ;)

3:05 kmicu: # # , & where is this notation specified? :)

3:05 Malondron: Why not simply ,(nth '(1 2 3) 2)

3:16 pepijndevos: What constitutes a "conditional put" in datomic? Is that just compare-and-set! behavior?

3:17 kmicu: pepijndevos: try in #datomic channel if you don't get answer here

3:17 Malondron: Hi, I guess the problem is that I don't know what type of collenction I acttually get from the above code. The translated code is: form.select-name.options, which is fine. I just cannot get a .[0] to show up in the translation in any way. first does not work, -[0] does not work, 0 does not work :0 does not work, (options 0) does not work, etc.

3:18 kmicu: Malondron: but this is in js not cljs?

3:20 Malondron: Well, I am translating into javascript.

3:20 borkdude: Malondron you can call type on it

3:20 ,(type [1 2 3])

3:20 kmicu: Malondron: but where you can't acces in js or cljs? :)

3:20 clojurebot: clojure.lang.PersistentVector

3:22 kmicu: // collection access is first class (def m {:foo 1        :bar 2}) (get m :foo) (def v ["red" "blue" "green"]) (nth v 0)

3:22 // map access is a static// language feature var m = {  "foo": 1,  "bar": 2}; m["foo"];m.foo; // array access is a static// language feature var a = ["red", "blue", "green"];a[0];

4:01 alex_baranosky: does anyone have sagely wisdom on why some functions have :ns and :name metadata on them, but others don't?

4:01 amalloy: alex_baranosky: not many functions do. if you think they do, you're probably looking at the metadata on the var, not the function

4:03 alex_baranosky: ,(meta integer?)

4:03 clojurebot: nil

4:05 alex_baranosky: &(meta integer?)

4:05 lazybot: ⇒ nil

4:06 alex_baranosky: ahhhhh it is a 1.2 to 1.3 thing,

4:06 we're still using 1.2 here

4:06 if you wanted a the name a of a given function how would you go about getting it?

4:07 amalloy: you can't

4:07 alex_baranosky: dang

4:07 amalloy: functions don't have names

4:07 alex_baranosky: they do in 1.2

4:07 :)

4:07 at least a lot of them do

4:07 amalloy: meh. def was broken

4:08 did some weird shit with copying metadata from vars to functions, sometimes, for no real reason

4:08 or that was defn, i guess? i dunno

4:08 alex_baranosky: is there a way to achieve a similar result without needing to us a macro to snag the symbol , and other crap I don't want to stoop to?

4:08 basically I want to accept any predicate for my function, and then printout "Your predicate 'foo?' filed…"

4:09 amalloy: &(let [named-first (with-meta first '{:name first})] (name (meta named-first))) ;; not very satisfying, huh?

4:09 lazybot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named

4:09 alex_baranosky: failed*

4:09 amalloy: &(let [named-first (with-meta first '{:name first})] (:name (meta named-first)))

4:09 lazybot: ⇒ first

4:09 amalloy: your function has to be a macro

4:10 and even then it won't work very well because what if they pass an anonymous function?

4:10 alex_baranosky: anonymous functions are all bets off, but… I figured I'd live with that

4:10 worth the tradeoff in simplicity

4:10 amalloy: it doesn't sound simpler. easier, maybe

4:11 alex_baranosky: I could change my code to accept a predicate and a predicate-name, and then wrap a thin macro layer around it to get the name of the predicate symbol and pass it in

4:11 Malondron: Well, let's say I want to set the first option in a select element in a form. I want to write: (set! (first (.. form -select-name -options)) (js/Option. "New" "New")), but this fails as first does not work with the compiler (nor does nth, or any other reasonable "usual" clojure way to use collections). And the problem is not with set!; trying to access the value property fails as well, so I am not getting the first (or nth 0)

4:11 element. At least not in the form I want.

4:11 alex_baranosky: it is easier and simpler

4:12 adding a layer of macros just to get a predicate's name seems silly

4:12 borkdude: can protocols be used to "alter" the toString of, let's say a ClasscastException?

4:12 alex_baranosky: (which is what I was suggesting it was simpler than)

4:12 I think the answer to that is no

4:13 thanks smalloy for the info

4:13 now I don't want to move to 1.4 ;)

4:15 borkdude: for example, what's going wrong here? https://www.refheap.com/paste/2897

4:55 Malondron: Actually, I just found out that aget/aset does what I want in this case.

5:41 Dvyjones: Any idea why this outputs question marks instead of the ticks it's supposed to output? https://gist.github.com/2818174

5:47 kral: namaste

5:47 rodnaph: Dvyjones: where are you viewing the output? font probably doesn't support those characters.

5:53 mittchel: Why am I getting a nil when I do the following: (my-map :a) in this function: (defn my-map {:a "appel" :b "peer"})

5:53 maps are supposed to behave as functions, right?

5:56 andyfingerhut: ({:a "appel" :b "peer"} :a) will do what you are expecting. So will ((my-map) :a) -- note the extra parens so that my-map is called with no args, and the return value of a map is then used as a function.

5:57 You'll have to change it to (defn my-map [] ...) to specify the function takes no arguments, though.

5:57 mittchel: Hm thanks.. probably an mistake in the course :P

5:57 Dvyjones: rodnaph: In my console, and the font does support those characters.

5:58 mittchel: andyfingerhut: when I try that Im getting: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: user$my-map (NO_SOURCE_FILE:0)

5:58 rodnaph: Dvyjones: are you going through the REPL?

5:59 andyfingerhut: when you try what?

6:00 mittchel: 9

6:00 ((my-map) :a)

6:01 andyfingerhut: After changing the defn to (defn my-map [] {:a ...}) ?

6:01 Dvyjones: rodnaph: Nope.

6:01 mittchel: (get my-map :a) returns nil too lol

6:01 Dvyjones: rodnaph: Well, I tried importing that into the REPL, and that failed too.

6:01 andyfingerhut: Are you sure you don't want (def my-map {:a "appel", ...}) (note def not defn)

6:02 that will define a var called my-map that you can use the way you are describing, rather than a function.

6:02 mittchel: Ye

6:03 thankyou :D

6:03 andyfingerhut: (def my-map {:a "appel" :b "peer"}) (my-map :a) => "appel"

6:03 np

6:03 rodnaph: Dvyjones: not sure then sorry mit. Try (println "CHAR") in various places (shell, repl) to see where the problem is.

6:27 mittchel: () are literals for lists right? Since (= '(3 4 5) (map (partial + 2) [1 2 3])) results in (3 4 5)

6:28 borkdude: mittchel '(1 2 3) equals to (list 1 2 3)

6:30 mittchel: Yep I know cause ' makes sure that it doesn't see the 1 as a function with arguments 2 and 3.. but when I do the following in the repl: (map (partial +2) [1 2 3])) this gives me (3 4 5).. is this a map as a result or a list? Cause I thought () was the literal for a list:P

6:30 borkdude: mittchel it is a sequence

6:30 Raynes: It is a seq.

6:30 borkdude: ,(type (map (partial + 2) [1 2 3]))

6:30 clojurebot: clojure.lang.LazySeq

6:31 borkdude: mittchel a sequence is printed as (. . .)

6:31 mittchel: Alright, thanks..

6:31 so basically a list can be seen as a sequence too?

6:31 borkdude: mittchel yes

6:32 ,(seq? (list 1 2 3))

6:32 clojurebot: true

6:32 lucian: afaik, they just both print the same

6:32 mittchel: Pff I'm always messing that up :P

6:32 lucian: ,(seq? [1 2 3])

6:32 clojurebot: false

6:32 lucian: ,(seq? (seq [1 2 3]))

6:32 clojurebot: true

6:32 lucian: ok, so i'm wrong

6:34 mittchel: ,(seq [1 2 3])

6:34 clojurebot: (1 2 3)

6:34 mittchel: ,([1 2 3])

6:34 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>

6:34 borkdude: ,[1 2 3]

6:34 clojurebot: [1 2 3]

6:34 mittchel: ,[1 2 3]

6:34 clojurebot: [1 2 3]

6:34 mittchel: ye hehe

6:34 se you are actually right lucian.

6:36 ,(clojure.set/intersection #{1 2 3 4} #{3 4 5 6})

6:36 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set>

6:37 borkdude: &(clojure.set/intersection #{1 2 3 4} #{3 4 5 6})

6:37 lazybot: ⇒ #{3 4}

6:37 borkdude: mittchel apparently, clojurebot has not required clojure.set

6:37 mittchel: too bad

6:37 borkdude: mittchel but you can also use lazybot with &

6:38 mittchel: What's the difference between those two?

6:38 borkdude: mittchel also you can evaluate an expression like this: ##(+ 1 2 3)

6:38 lazybot: ⇒ 6

6:38 borkdude: mittchel they are two different bots

6:38 mittchel: ahh

6:38 borkdude: mittchel http://www.unexpected-vortices.com/clojure/brief-beginners-guide/getting-help.html

6:39 mittchel: thats much easier

6:40 borkdude: mittchel lazybot was implemented by Raynes I believe

6:41 mittchel: It comes in very handy

6:49 leo2007: I started swank-clojure in a terminal and connect to it from emacs.

6:50 but I must provide emacs with the real IP address (i.e. not localhost or 127.0.0.1) otherwise it won't connect.

6:50 ideas?

6:50 I can connect to my CL swank server using localhost

7:52 kilon: anyone here used Quil with Clojure, wondering how mature really is

8:03 soulman: hello

8:06 mrphoebs: hi @soulman

8:06 soulman: i'm searching for a possibility to splice a list as flat function arguments

8:06 mrphoebs: use apply

8:07 soulman: e.g. a list of elements as sub elements of an xml element

8:07 (element {} (<splice> (map element-list coll))

8:08 )

8:08 mrphoebs: hmmm

8:11 @soulman you want to flatten the list

8:11 ?

8:12 soulman: but it's still a list after flattening

8:20 the-kenny: soulman: You want something like (magic + (list 1 2 3))?

8:21 soulman: yep

8:21 PKHG: raek: hello, you helped me yesterday, isn't it? got lein working too in Emacs (all on Vista) ;-)

8:21 the-kenny: magic is called apply ;)

8:21 ,(apply + (list 1 2 3))

8:21 clojurebot: 6

8:24 pepijndevos: What happens to a protocol when you AOT it?

8:26 PKHG: Hallo, busy with clojure since yesterday a newbie :-) How do I do this: a bunch of *java files form webcompmath at sourceforge and is it possible to use those in clojure , a link explaining this maybe?

8:27 soulman: i need something like (magic xfn stuff [1 2 3]) where xfn is defined like (defn xfn stuff & content) but content is treated as a single argument when you give it a coll

8:27 G0SUB: soulman, apply

8:27 mrphobes: Hi PKHG

8:27 G0SUB: ,(apply + 1 [2 3 4])

8:27 clojurebot: 10

8:27 soulman: like data.xml element

8:28 mrphobes: Clojure can import any complied java files as long as they are on the classpath

8:28 soulman: => (doc element)

8:28 -------------------------

8:28 clojure.data.xml/element

8:28 ([tag & [attrs & content]])

8:29 G0SUB: soulman, couldn't understand your problem.

8:35 PKHG: mrphobes: hmm you mean I have to compile my *.java into a jar and then ... how to define a classpath in clojure?

8:37 mrphobes: PKHG: this talks about how classpath with repl http://lpsherrill.blogspot.in/2009/05/clojure-classpath-made-easy.html

8:37 PKHG: thanks looking at your linkg ;-)

8:37 mrphobes: If you are working on a project using 'lein' the simplest way would be to put your jars in the lib directory, but this is not the right way

8:38 The right way is to include the jar as a dependency in lein

8:38 np

8:40 @PKHG also look at this http://stackoverflow.com/questions/2121670/how-do-i-include-java-stuff-in-jar-files

8:40 PKHG: next to read ;-)

8:44 hmm yes I think now what to do with CLASSPATH ... THANKS!

8:44 soulman: G0SUB: to state it as plain as possible, I want to create an xml element with a list of elements as content.

8:45 G0SUB: soulman, doesn't "apply" work in your case?

8:45 soulman: the list of elements is created dynamically and the elements contain sub elements so flatten doesn't do the job. it flattens to much

8:46 apply doesn't seam to do the job because of the tag name and the attributes of the element fn

8:47 G0SUB: soulman, some example code would help.

8:57 soulman: G0SUB:

8:57 (defn xml-element [el]

8:57 (element :b {}

8:57 (element :c {:name (:name el)})))

8:57 (defn xml-elements [coll]

8:57 (element :a {}

8:57 (map xml-element coll)))

8:57 (indent-str (xml-elements [{:name "Hello"} {:name "World"}]))

8:57 #<IllegalArgumentException java.lang.IllegalArgumentException: No implementation of method: :emit-element of protocol: #'clojure.data.xml/Emit found for class: clojure.lang.LazySeq>

9:00 G0SUB: soulman, looking

9:00 soulman: (defn xml-elements [coll]

9:00 (apply element :a {}

9:00 (map xml-element coll)))

9:01 G0SUB: soulman, can you paste all the code somewhere?

9:01 soulman, refheap.com

9:01 soulman: seems to work in this case ;-)

9:02 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\n <b>\n <c name=\"Hello\"/>\n </b>\n <b>\n <c name=\"World\"/>\n </b>\n</a>\n"

9:02 that's what I like to see. ;-)

9:03 G0SUB: soulman, paste the code and your comments on refheap.com and I will take a look.

9:03 soulman: G0SUB: thanks for making me build a simple sample code. The problem seems to be lurking in some of my own code.

9:04 G0SUB: soulman, that's what I thought.

9:04 soulman: rubber ducking ;-)

9:04 G0SUB: soulman, it's always better to find a minimum test case to track down problems.

9:07 dan_b: cripes, how much easier is it to install clojure these days than it used to be?

9:08 soulman: G0SUB: sure, and select isn't broken ;-)

9:16 tominated: Hello

9:16 can anyone here help me with an issue I'm having with compojure?

9:18 rodnaph: depends on what the issue is!

9:18 tominated: haha i'm getting an exception when browsing to a route

9:18 I have it on github at https://github.com/tominated/twitface

9:19 rodnaph: what's the exception?

9:19 tominated: clojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap

9:19 rodnaph: sounds like you've missed the args [] from ur handler?

9:19 which route exactly?

9:20 tominated: it happens whenever I use the routes included from the controller files, which are '/users/', '/posts/' and 'comments'

9:21 rodnaph: tominated: try taking the parenthesis off your index function. ie. (GET "/posts/" [] index)

9:22 tominated: will do

9:22 rodnaph: they you might have to add the ring request object as a parameter to your handler, (defn index [req] ...)

9:23 tominated: yeah that seems like the case

9:23 it just had an exception saying there was too many arguments

9:25 hmmmm odd

9:25 that goes back to the same exception

9:25 2012-05-28 23:20:37.605:WARN:oejs.AbstractHttpConnection:/posts/

9:25 clojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap

9:30 rodnaph: tominated: it's probably the way your adding the routes in core.clj then, i've not seen that syntax before and can't imagine how it works.

9:31 tominated: I was roughly following the tutorial at https://devcenter.heroku.com/articles/clojure-web-application

9:31 it may be because they use an old version of compojure

9:31 there were a few things I had to change because of outdated packages

9:35 kilon: anyone can show me instructions on how to install leiningen in windows ?

9:35 tominated: rodnaph: I may just chuck all the routes in the core file

9:36 rodnaph: or import them by calling the controller functions eg. (my.controlls/routes)

9:38 tominated: how do you mean?

9:39 coventry: How do I turn a list of chars into a string?

9:40 Never mind, I forgot to google first.

9:41 tominated: ok, it seems that the error changes when I add or remove the argument from the controller's index functions

9:42 when I have it as (defn index [] ….) it says the following

9:42 clojure.lang.ArityException: Wrong number of args (1) passed to: posts$index

9:43 and when i have it as (defn index [request] …) is shows up this

9:43 2012-05-28 23:36:45.085:WARN:oejs.AbstractHttpConnection:/posts/

9:43 clojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap

9:43 wait a second

9:45 it seems like it may be my template that's screwing up

9:53 Oh you have got to be kidding me

9:54 it was because I was using a now non-existent function

9:56 rodnaph: thanks for all your help!

10:01 pandeiro: is there something i can install to paste to refheap directly from emacs?

10:02 tmciver: pandeiro: yes, there is a refheap package.

10:03 pandeiro: tmciver: available from marmalade? is it called refheap?

10:03 tmciver: pandeiro: yes, just do a search for 'refheap' after doing M-x package-list-packages

10:05 pandeiro: hmmm, marmalade-repo.org is down i think

10:05 ouch and package-list-packages is blocking

10:06 tmciver: ah, yes, it is for me too.

10:08 michaelr`: is there a way to break execution at the repl?

10:09 pandeiro: tmciver: finally went through but i don't see any refheap package

10:09 maybe that's stale, site still seems to be down

10:13 ok i typed it in by hand: https://www.refheap.com/paste/2898

10:15 michaelr`: i think C-c C-c does it no?

10:16 tmciver: pandeiro: yes, I do see the refheap package now. I have version 0.0.1.

10:16 twhume: Hi, I'm trying to flatten a sequence of sequences of sequences… but not completely. What I have is the sequence (((:istore 0 :istore 0) (:istore 0 :istore 1) (:istore 1 :istore 0) (:istore 1 :istore 1)) ((:ixor :ireturn))) and what I'd like is ((:istore 0 :istore 0) (:istore 0 :istore 1) (:istore 1 :istore 0) (:istore 1 :istore 1) (:ixor :ireturn)) … any ideas? (clojure n00b)

10:18 Bronsa: ,(mapcat identity '(((a b) (c d)) ((e f))))

10:18 clojurebot: ((a b) (c d) (e f))

10:19 twhume: Bronsa: aha, thank you. Is there any magic in that, or will a read through docs make it clear? ;)

10:19 Bronsa: no magic

10:20 * twhume wanders thankfully back to the docs

10:21 Bronsa: ,(reduce concat '(((a b) (c d)) ((e f))))

10:21 clojurebot: ((a b) (c d) (e f))

10:21 pandeiro: tmciver: yeah my package list is out of date and marmalade is not responding... oh well... wanna help me with my macro? ;)

10:24 tmciver: pandeiro: I would but my macro experience is almost non-existent. :/

10:25 _Azrael_: Cbg

10:26 Fuckkkkkkkk

10:27 pandeiro: wow the slime repl remembers history from previous sessions...

10:42 scottj: does :jvm-opts ["-Xmx256M"] cap just the map, or also the lein process jvm? is there is there a separate option for that?

10:42 s/map/app/

10:44 p_l: scottj: I believe the app, because lein can't exactly change those options after launching (unless it relaunched itself, and lein is slow enough without doing that)

10:47 rvgate: How do i remove an entry within an atom using clojure?

10:48 KIMAvcrp: what is stored in your atom ?

10:49 rvgate: KIMAvcrp, currently the atom has: {"agrg" {:title "agrg", :authors "wrrk", :publisher "wadst"}, "bla" {:title "bla", :authors "Henk", :publisher "piet"}}

10:50 and im trying to create a simple function (defn delete-book [title]

10:50 lucian: rvgate: you're probably looking for dissoc, to replace the atom's value with another

10:51 rvgate: something like (swap! book dissoc title)

10:53 rvgate: thank you lord \o/

10:53 thats you lucian :P

10:53 lucian: i'm glad it helped :)

10:54 rvgate: just learning clojure, no offence, but the documentation is horrible :/

10:55 pandeiro: rvgate: http://clojure.org/api ?

10:55 rvgate: pandeiro, there is documentation, yes... but some descriptions and examples are weird

10:56 pandeiro: rvgate: do you use the repl?

10:56 rvgate: ofcourse

10:56 rodnaph: i concur! the clojure docs assume a *lot* of knowledge. here's a great example of assuming a lot of stuff: http://clojure.org/macros

10:57 pandeiro: you know (dir ...) (doc ...) etc?

10:58 rvgate: another example: http://clojure.org/atoms, am i the only one that finds it weird that the example on that page seems inrelevant... i dont see why elapsed time has anything to do with atoms...

10:59 mfex: the documentation on clojure.org is a reference, not a tutorial. for that a book is better

10:59 gfredericks: rvgate: the elasped time bit there is demonstrating that the naive fib algorithm is speeded up by memoization

10:59 rvgate: gfredericks, and how is that relevant to atoms?

10:59 gfredericks: it's a bit indirect, but it relates because memoize is implemented with an atom

11:02 pandeiro: rvgate: clojuredocs.org and clojure.org/cheatsheet <- the latter shows you the principal functions for dealing with atoms

11:04 gfredericks: somebody could start a clojure-newb-docs project which, when included, replaces all the docstrings in clojure.core :)

11:08 rvgate: i think the docs should show simple examples, using clear variable names (not using x y z, m, ret, etc etc) so everything becomes more understandable :P but thats just me

11:14 justint: anyone know if there's a marmalade-repo mirror anywhere? it seems to be down

11:21 rvgate: lucian, sorry to bother you again, assoc inserts, dissoc deletes... but how do i update?

11:21 lucian: rvgate: assoc with the key you want

11:21 rvgate: seriously....

11:22 lucian: rvgate: assoc just returns a new map with that value at that key

11:22 gfredericks: ,(assoc {:a 1 :b 3} :b 20)

11:22 clojurebot: {:a 1, :b 20}

11:27 soulman: hi

11:28 lucian: rvgate: what other language are you more comfortable with?

11:30 soulman: if i compile some code with clojure, referenced jar files get unzipped to *clojure.compile.path*. Is that correct?

11:31 so they land in the resulting jar file which i build from *clojure.compile.path*?

11:34 edw: Running in the SLIME REPL, (clojure.java.io/resource ".") returns a URL to my project's test directory. This puzzles me. Shouldn't it return a URL to the project root?

11:39 wmealing_: in the interest of anti wheel re-invention is there a jar which watches a directory and can load the files (kind of like a plugin loader ?)

11:39 edw: There's watchtower on github.

11:39 It's crude but effective.

11:39 mfex: soulman: no; referenced jars are not unzipped, perhaps you are looking for "lein uberjar" which packages a project and all its jar dependencies into one jar

11:40 wmealing_: edw, ok

11:40 edw: It doesn't using any kqueue-like fancyness: it polls.

11:41 * wmealing_ nods

11:41 wmealing_: thats probably good enough for now

11:42 edw: Something more sophisticated might require JNI: I don't think the JVM exposes any abstraction for kqueue or similar system facilities.

12:06 bordatoue: anyone facing problem installing leningen 2 installation on RHEL

12:06 rvgate: lucian, java and php mostly... (sorry, was having dinner)

12:06 wmealing_: more specifically ?

12:06 PKHG: hello, who can help a newbie? trying to use Java from clojure: here is my problem visible: http://www.petergragert.info/pmwiki/pmwiki.php/Clojure/Applet

12:07 wmealing_: bordatoue, that was for you.

12:07 PKHG: Peter thats me ;-)

12:07 bordatoue: i followed the instruction specified in https://github.com/technomancy/leiningen

12:07 PKHG: bordatoue: what is RHEL?

12:08 lucian: rvgate: right, so in java you'd have Map.set(key, val). you can both add and "overwrite" keys with that. just like clojure's assoc

12:08 bordatoue: downloaded the script , changed the mode . but when I try to execute lein self-update , i get Exception in thread "main" java.lang.NoClassDefFoundError: java/util/concurrent/Callable

12:08 at clojure.main.<clinit>(main.java:19)

12:08 wmealing_: el6 ?

12:08 soulman: mfex: no, I'm not building with lein but with 'java clojure.lang.Compile...'

12:08 bordatoue: RHEL -- red hat scrap

12:09 wmealing_: are you on version 6 ?

12:09 bordatoue: yes

12:09 PKHG: hmm sorry, installed yesterday on Vista with lein.bat ..

12:10 wmealing_: bordatoue, disclaimer, i work for red hat.

12:10 bordatoue: Kernel version is 2.6.18-194.el5

12:10 wmealing_: i dont think the kernel verrsion has much to do with it.

12:10 i assume the file downloaded ?

12:10 ie, you saw a progress meter ?

12:11 bordatoue: nothing happens it throws an exception stated above

12:12 wmealing_: ok, el6 current here, and not getting any issues

12:12 default install.

12:12 bordatoue: did you just downloaded the script and executed it

12:12 wmealing_: yes

12:12 i'll paste you

12:12 bordatoue: i did not use any package manager

12:13 wmealing_: http://hastebin.com/fajudocaku.vhdl

12:13 neither did i

12:13 do you have wget or curl installed

12:14 bordatoue: i do have wget installed

12:14 PKHG: hallo again, someone used a java applet from closure?

12:14 * wmealing_ thinks

12:15 bordatoue: i will try deleting all the files

12:16 you don't seem to use --no-check-certificate option for wget , could that be th reason

12:17 wmealing_: i'm pretty sure it is

12:17 line 128

12:17 coventry: Is there such a thing as an anonymous macro? I'm working on a 4clojure problem where I think a macro would be useful, but the 4clojure evaluator doesn't allow defs.

12:18 gfredericks: coventry: nothing available from 4clojure I don't think

12:18 wmealing_: but by all means, give it a go.

12:18 gfredericks: the clojure.tools.macro package has tools for that

12:18 coventry: gfredericks: Thanks.

12:19 wmealing_: bordatoue, bash -x lein self-update

12:20 maybe you're mising something, and that should show the code-path its executing

12:20 bordatoue: okay

12:20 wmealing_: however, i dont think this is a rhel "problem", you're missing something that is required/assumed to be installed

12:20 bordatoue: http://hastebin.com/cayutiweti.diff

12:22 wmealing_: what java are you running

12:22 bordatoue: current path is set to 1.4

12:23 wmealing_: i dont know what that means

12:23 i'm not running third party java

12:23 and i dont think that clojure works with the older jdks

12:23 bordatoue: java 4

12:23 wmealing_: (again, i dont write java)

12:23 bordatoue: i can try changing it to jdk 6 or 7

12:24 wmealing_: java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64

12:24 i'm using whatever ships with el6.

12:25 bordatoue: wmealing_: thanks, it seems to work with jdk 6

12:26 wmealing_: yeah, i imagine that the util.concurrent stuff isnt in 1.4

12:26 just taking a punt

12:26 thanks for calling redhat support :P

12:27 bordatoue: shouldn't the script doing some checks before proceding

12:27 wmealing_: if you think so, lodge a bug

12:27 or a patch

12:31 KIMAvcrp: hey #clojure

12:31 wmealing_: the developer is here frequently, but I do think that 1.4 perhaps is a little old.

12:32 bordatoue, https://github.com/technomancy/leiningen/issues

12:32 KIMAvcrp: afaik util.concurrent was introduced in java 5

12:33 wmealing_: there ya go

12:34 bordatoue: i am trying to clojure with emacs , still haven't figured out how to get it working

12:35 gfredericks: bordatoue: I think all I've ever had to do is use the swank-clojure plugin

12:35 I'm not any good for troubleshooting though

12:36 bordatoue: could not start swank server

12:36 what is that about

12:37 could you please provide a link to the steps you have followed, I seem to be picking an old outdated one

12:38 gfredericks: https://github.com/technomancy/swank-clojure

12:38 KIMAvcrp: http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CFMQFjAA&amp;url=http%3A%2F%2Fdev.clojure.org%2Fdisplay%2Fdoc%2FGetting%2BStarted%2Bwith%2BEmacs&ei=HanDT8XkHcLdtAbFnITdCg&usg=AFQjCNEBjHTq8rCVLevFYiWtsZXeBezzAw

12:40 this is the recommended setup. I followed this after reinstallation of ubuntu 2 days ago and it worked out of

12:40 the box

12:52 wmealing_: and i can assure you it works on standard rhel, nothing magical there.

12:55 peregrine81: Does clojure-ring have its own IRC channel?

12:56 gfredericks: peregrine81: not that I've heard of

12:57 peregrine81: Well I will ask here. I am trying to ring.middleware.reload but its not reloading my routes file on a new request, here is the core file. http://pastebin.com/cpvc981a

12:58 it never actually reloads any of my code on file change

12:58 or ever

12:59 docs for wrap-reload are pretty basic (http://mmcgrana.github.com/ring/ring.middleware.reload.html#var-wrap-reload). I tried setting directory to "src' directly I also checked to make sure the handler is truly wrapped.

13:00 gfredericks: peregrine81: so you're 100% sure that (= env "DEV") is true there, right?

13:01 oh I guess you just said that more or less

13:01 peregrine81: Yep I print the out the handler object and see this #<reload$wrap_reload$fn__231 ring.middleware.reload$wrap_reload$fn__231@6fbdea60>

13:01 so more or less yes

13:02 gfredericks: and you're running this with `lein run`?

13:02 peregrine81: I am running it with foreman and with the following command lein trampoline run -m gameapi.core

13:03 which drops the lein process

13:03 gfredericks: I'm not too familiar with reload. If nobody else has any suggestions, you could try pulling in the ring project with checkouts and debugging it directly

13:04 peregrine81: Well the code is pretty basic https://github.com/mmcgrana/ring/blob/master/ring-devel/src/ring/middleware/reload.clj

13:04 I'd just prefer not to need to reload the entire JVM everytime I change the code

13:05 its kinda slow :P

13:06 gfredericks: welp if it were me I'd do the checkouts thing and have it log which ns's it's reloading each time

13:06 might end up debugging that ns-tracker thing after that

13:06 jt123: anyone know if there's a marmalade-repo mirror out there? it seems to be down

13:07 peregrine81: could be a difference with OSX

13:39 badjer: hi, does anyone use noir and enlive together? I'm running into an issue there that seems like it would come up a lot

13:56 r0adrunner: Hi. I want to copy a directory from one place to another using clojure. How to do that?

13:57 meiji11: learn to copy a file and make a directory in clojure, and build up from there.

13:57 that shouldn't be hard, I'm sure clojure can talk to the shell.

13:57 the rest sounds like a good job for a finite state machine.

13:58 in which case, I'd go with trampoline.

14:00 r0adrunner: I was looking for an one-liner. but thanks anyway

14:05 gf3: ibdknox: https://github.com/ibdknox/noir-cljs/blob/master/src/noir/cljs/core.clj#L5-6

14:26 gfredericks: r0adrunner: the fs project might have a one-liner for you

14:31 r0adrunner: gfredericks: Yes.. there is a "copy-dir" function. thanks

15:21 Bronsa: still.

15:21 ops, wrong chan

15:41 jsabeaudry: Elegant way to transform "BU0.003W0.322L" into [0.003 0.322] ?

15:43 gfredericks: ,(map read-string (re-seq #"[\.\d]+" "BU0.003W0.322L"))

15:43 clojurebot: (0.0030 0.322)

15:43 gfredericks: may or may not work depending on what your input domain is

15:45 jsabeaudry: gfredericks, thanks that is very elegant

15:48 gfredericks: ,(mapv read-string (re-seq #"[\.\d]+" "BU0.003W0.322L"))

15:48 clojurebot: [0.0030 0.322]

15:48 * gfredericks isn't used to mapv yet

15:55 pepijndevos: &(doc mapv)

15:55 lazybot: ⇒ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any ... https://www.refheap.com/paste/2901

15:56 pepijndevos: $source mapv

15:56 lazybot: mapv is http://is.gd/CvFceu

15:57 borkdude: has anyone got the clojurebook near him/her, I've got a question about sorting

15:57 on page 107: "how does clojure turn a predicate (function) into a comparator (Java Comparator)?"

15:58 because you can do smth like ##(sort < [6 5 4])

15:58 lazybot: ⇒ (4 5 6)

15:58 borkdude: but sort works with comparators which return -1,0 or 1… when I look at the source of sort, I see no transforming of the predicate into a comparator

15:59 so, where does this happen...?

16:00 pepijndevos: borkdude: interesting... I assume fn implements it or something?

16:01 raek: ,(supers (class <))

16:02 clojurebot: #{java.lang.Runnable clojure.lang.IObj clojure.lang.IMeta clojure.lang.Fn java.util.concurrent.Callable ...}

16:02 pepijndevos: borkdude: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFunction.java#L18

16:02 borkdude: pepijndevos great tnx! wish the info was just given in the text, in a footnote or smth :)

16:03 bordatoue: hi

16:04 is anyone having problem with marmalade-repo.org:80

16:04 it seems unreachable

16:05 raek: seems to be down from here (Sweden) too

16:05 pepijndevos: seems to be down for me too, but: http://www.downforeveryoneorjustme.com/marmalade-repo.org:80

16:05 bordatoue: is there any straight forward tutorial to install clojure with emacs i have spent about a week

16:05 nearly about to give on this

16:06 borkdude: bordatoue I think on technomancy's blog

16:06 pepijndevos: borkdude: Come to the dark side, we have vim and cookies.

16:06 erm, bordatoue

16:06 raek: bordatoue: the most straight forward way (IMO) uses marmalade :(

16:06 bordatoue: but marmalade an't working

16:06 borkdude: haha

16:06 bordatoue: i can't do a package-refresh

16:07 please i am going crazy here

16:07 raek: bordatoue: you could donwload clojure-mode via git

16:07 I have never seen marmalade down before

16:07 borkdude: I'm not laughing about your problem… about technomancy leaving again after his name is mentioed..

16:07 bordatoue: can you please check if marmalade is down

16:07 raek: bordatoue: for how long has it been down?

16:07 bordatoue: all of today

16:08 its all way down, when i sit in from of my mac book

16:08 raek: bordatoue: do you know how to install emacs packages without package.el?

16:08 bordatoue: no

16:08 as such this is complicated enough

16:09 is there any proxy ip i need to use

16:09 raek: bordatoue: you only need one elisp package for clojure: clojure-mode.el

16:09 pepijndevos: Isn't there some easy emacs starter bundle including clojure you can get?

16:09 raek: bordatoue: it seems to be down from here too

16:09 borkdude: pepijndevos technomancy made smth like this, but it works through marmalade

16:09 raek: it's hopefully temporary

16:09 borkdude: probably on git as well

16:09 pepijndevos: borkdude: samaaron also has one for overtone livecoding, I think

16:09 raek: bordatoue: https://github.com/technomancy/clojure-mode

16:09 bordatoue: how long have you guys using this marmalade

16:10 raek: one to two years, maybe

16:10 borkdude: bordatoue only when I installed clojure stuff, a while ago

16:10 bordatoue: that long ,

16:10 i just heard about it few days back

16:10 and when i tried it , its down

16:10 raek: bad luck :(

16:11 bordatoue: i will summarise what i had done so far

16:11 pepijndevos: https://github.com/overtone/emacs-live

16:11 bordatoue: i have installed lein

16:11 raek: bordatoue: download the clojure-mode.el file and put it in your ~/.emacs.d/ directory

16:11 bordatoue: using lein i install swank-clojure

16:11 raek: marmalade is convenient (usually), but you can install clojure-mode without it

16:11 bordatoue: so how does the repl get started

16:12 raek: bordatoue: ok, that good.

16:12 bordatoue: you invoke M-x clojure-jack-in form Emacs

16:12 which is provided by clojure-mode.el

16:12 borkdude: bordatoue raek you have to start it from a project though

16:13 bordatoue: when i invoke M-x i get an error, saying could not start swank server

16:13 do you know the cause for it

16:13 borkdude: bordatoue did you cd to a project in emacs?

16:13 bordatoue: no

16:13 borkdude: bordatoue or open a file from a project that is (I guess)

16:13 raek: bordatoue: I have an idea. could you try "M-! lein"?

16:13 bordatoue: let me explain, i used lein new myProject

16:14 then opened project.clj file using emacs

16:14 raek: ok, that's good

16:14 bordatoue: then typed M-x clojure-jack in

16:14 then it follows wit an error

16:14 raek: you should be able to use clojure-jack-in from that buffer (once everything is working)

16:14 borkdude: bordatoue did you load clojure-mode.el already

16:14 bordatoue: it says it can not start swank server

16:14 should i manually start the swank server

16:15 raek: bordatoue: I think emacs can't find lein. how did you put lein on the path?

16:15 bordatoue: no need to do that

16:15 borkdude: bordatoue ok great, this means you don't have the swank plugin specified in the project

16:15 bordatoue: okay

16:15 borkdude: bordatoue or have you?

16:15 bordatoue: so i can add lein to my path, currently it is in /usr/bin directory

16:15 raek: bordatoue: can you try "M-! lein version"? does it return the lein version or an error?

16:15 bordatoue: which is in my path

16:16 wait

16:16 raek: if "M-! lein version" works, then this is not the problem

16:16 KIMAvcrp: try to run lein swank in your project directory. does it work ?

16:16 borkdude: raek I think you need to specify :plugins [[lein-swank "1.4.4"]]) in your project right?

16:17 at least with leiningen2 if it is not in your profiles.clj

16:17 bordatoue: too much information,

16:17 raek: borkdude: if using lein2, yes (but ~/.lein/profiles.clj is a better place for it)

16:17 bordatoue: let me try one thing at a time

16:17 how do i check if emacs is able to see lein

16:17 raek: bordatoue: M-! lein version

16:18 bordatoue: okay i have got emacs.app

16:18 raek: you could do "M-x shell-command RET lein version" instead

16:18 bordatoue: is it Alt+!

16:18 raek: yes

16:18 well

16:19 alt on a PC keyboard

16:19 dunno about mac

16:19 borkdude: also max

16:19 mac

16:19 bordatoue: okay

16:19 borkdude: also called the option key (alternative, option, kind of similar words)

16:19 bordatoue: leiningen version 1.7.1 on java 1.6.029

16:19 KIMAvcrp: try to run lein swank

16:19 raek: ok, good. your lein works and emacs can find it

16:20 bordatoue: how did you install swank-clojure?

16:20 bordatoue: is it the version of leinigen required

16:20 raek: bordatoue: yes, it is the latest stable

16:20 borkdude: bordatoue it matters if you work with leiningen 1 or 2, you are using 1 so this info is useful

16:20 bordatoue: i used lein plugin install swank ....

16:20 i used lein plugin install swank ….

16:20 something like that

16:20 raek: ok, that's correct for lein 1.x

16:21 bordatoue: do you get any errors if you run "lein swank" in a terminal in the project directory?

16:21 bordatoue: i am not keen on leinigen 1.x i will to use any version to get it to work

16:21 let me try that

16:22 no , it seems to be downloading from the central repository

16:22 and finally it say connection opened on port 4005

16:22 KIMAvcrp: ok thats good

16:22 borkdude: ah

16:22 raek: ah, ok. precc control-c to kill it

16:23 KIMAvcrp: now from emacs you can do m-x slime-connect

16:23 raek: clojure-jack-in should work now

16:23 borkdude: clojure-jack-in does not force leiningen to download deps?

16:23 raek: apparently not...

16:23 borkdude: maybe this is fixed in version 2..

16:23 bordatoue: well, clojure-jack-in is throwing errors

16:23 raek: still?

16:23 borkdude: gtg

16:23 raek: bordatoue: can you post the error message somewhere?

16:24 bordatoue: okay

16:25 one more thing, it say cannot find project.clj

16:25 gfredericks: well that's significant

16:25 bordatoue: should i open project .clj and then use jack-in

16:25 raek: that sounds odd

16:26 bordatoue: please instruct me on what i need to do on emacs side

16:26 eighty: what is the right way to check if something is a collection?

16:26 TimMc: eighty: coll?

16:26 raek: bordatoue: the only important thing is that you run that command while visiting a file inside the project directory

16:26 KIMAvcrp: ,(coll? [1 2 3])

16:26 clojurebot: true

16:26 bordatoue: okay,

16:26 let me do that

16:26 TimMc: eighty: Although nil can also function as one.

16:26 eighty: TimMc: nice! thanks man.

16:28 bordatoue: raek: and all others thanks, it worked

16:28 raek: bordatoue: happy hacking!

16:28 bordatoue: should i always open the project.clj file and then execute jack-in command

16:28 eighty: TimMc: nil can only function as an empty collection, right?

16:28 bordatoue: what would be the recommended way of doing this

16:29 raek: bordatoue: any file ine project is fine. I usually open a source file in src/...

16:29 bordatoue: why can't i start a repl without visiting a project

16:29 gfredericks: the repl runs in the context of a project

16:29 bordatoue: so is the repl project specific

16:30 raek: leiningen needs to know 1) what version of clojure to use 2) where your source files are and 3) what and where your dependencies are

16:30 so you usually use projects for everything, including playing at the repl

16:30 KIMAvcrp: I'm beginning to port PAIP to clojure and finished chapter 2 http://kimavcrp.blogspot.de/ any recommendations about the style of the clojure code ?

16:31 bordatoue: i have got a new entry in the project.clj :plugin [lein-swank "1.4.4"]

16:31 raek: bordatoue: yes, everything (but with a few exceptions) is project specific in lein

16:31 for example, you can run "lein repl" outside a project

16:31 bordatoue: from emacs shell

16:32 or terminal

16:32 raek: a terminal

16:32 but you can't do that with clojure-jack-in

16:32 KIMAvcrp: you can also set it the inferior lisp program with (setq inferior-lis-program "lein repl")

16:32 raek: bordatoue: that entry is for lein2. lein1 will ignore it. it replaces the "lein plugin install ..." command

16:32 KIMAvcrp: then you can type M-x run-lisp to start a clojure repl everywhere

16:33 bordatoue: that is useful ,

16:34 raek: bordatoue: I always mention the slime/swank in a project approach first, since it is the most generally useful approach

16:34 dgrnbrg: hello clojurians--if I want to make a simple page in clojure that runs various shell commands when I click on links, what's the simplest way to get there (recommended tutorial/api doc)? I have programmed Grails a while ago, and I'm very proficient with Clojure

16:34 raek: if you split your code into multiple files or need to use libraries you will need it

16:34 bordatoue: many thanks,

16:40 i have another problem, this one mac specific . hash key is not working , alt+3 is disabled .

16:41 is there any other shortcuts for hash key in emacs

16:42 jsabeaudry: bordatoue, I guess that would depend on your keyboard configuration

16:45 TimMc: eighty: Right, most or all of the collection fns treat nil as empty.

16:54 KIMAvcrp: I'm beginning to port PAIP to clojure and finished chapter 2

16:54 http://kimavcrp.blogspot.de/ any recommendations about the style of

16:54 the clojure code ?

17:03 gfredericks: dgrnbrg: I guess noir?

17:03 dgrnbrg: gfredericks: thanks, I've been looking at it

17:04 gfredericks: dgrnbrg: without a more specific question that's the most I can say :)

17:04 dgrnbrg: I just need to expose a few shell commands through a website. The shell commands change the mode of the lighting in the room

17:06 pbostrom: is there an equivalent to something like (resolve (symbol "foo")) in Clojurescript?

17:07 gfredericks: pbostrom: don't think that's possible

17:07 KIMAvcrp: hardly without eval

17:08 pbostrom: thanks

17:08 gfredericks: pbostrom: it's hacky but you could try introspecting the ns object

17:10 pbostrom: thanks, I might read up on that, I'll probably just do something similarly hacky to do what I want

17:10 emezeske: dgrnbrg: I second the suggestion of noir, and add that you might like conch for shelling out: https://github.com/Raynes/conch

17:10 dgrnbrg: emezeske: thanks, I haven't heard of conch, i'll check it out

17:11 * Raynes reins in his ego.

17:11 * emezeske only recommends conch because Raynes scares him.

17:11 Raynes: Good. s_s

17:11 emezeske: :)

17:11 michaelr525: i used conch and it worked (tm)

17:11 Raynes: Woohoo!

17:12 gfredericks: that raynes. always reining.

17:21 coventry: I'm using clojure-jack-in to start slime. What does it take to get the debugging features shown in http://www.youtube.com/watch?v=d_L51ID36w4? I get the sldb window, but there is no information about local variables or pointers to my source code (e.g. the line in the backtrace for my code is "2: NO_SOURCE_FILE:1 user/eval9816"

17:24 michaelr525: so anyone here uses the eclipse debugger with clojure?

17:24 coventry: Hmm, no one's going to watch a youtube link, are they. It's not really relevant to the question. The main issue is that the backtrace in the sldb window is missing the functionality I described in the last sentence of my last message. Is this a common problem with a known fix?

17:26 peregrine81: Anyone here use lobos at all?

17:26 raek: coventry: does that video use slime or ritz (a.k.a. slime-clj)?

17:27 michaelr525: peregrine81: wuz that?

17:27 peregrine81: sql migration library for clojure

17:27 michaelr525: oh

17:28 johnmn3: hello

17:28 peregrine81: cannot seem to get the lein repl to have src/lobos in the classpath

17:28 coventry: raek: it uses slime-clj.

17:28 Should I just move to that?

17:29 raek: coventry: it's a different implementation. if you want to follow the video you need to use it.

17:29 swank-clojure is more commonly used, though

17:30 coventry: OK, thanks.

17:30 raek: and it has debugging support too: https://github.com/technomancy/swank-clojure (section Debugger)

17:31 http://georgejahad.com/clojure/swank-cdt.html

17:31 amalloy: coventry: ritz is definitely more full-featured. last time i tried i couldn't figure out how to install it, but that was like a year ago, so probably it's improved by now

17:32 coventry: Yes, I found it easy to install. Thanks for the pointers, this is great.

17:36 johnmn3: any more documentation out there lately on how to go about implementing reducers?

17:37 amalloy: johnmn3: i wrote a few of them, in a few different ways; i was getting feedback from rich until suddenly i stopped hearing back. so for some reducers i could tell you the definitely-right answer; for others i don't think a right answer exists yet

17:38 johnmn3: amalloy: yea, I was just reading your jira comments

17:39 amalloy: ah. well, to be honest: i totally understand why rich wouldn't want defseq in core, but it's so useful and concise that when he decides not to take it i'll put it in some other library

17:39 johnmn3: how about docs on using the existing reducers functions? for the purposes of benchmarking and whatnot? how would I go about using r/map?

17:39 michaelr525: ritz looks interesting.. i never managed to get debugging support to work with swank-clojure..

17:40 coventry: The example in the swank-cdt page raek linked works for me, but it still shows NO_SOURCE_FILE for the repl interaction and [No locals] for the local variables. It shows the debugging info for clojure core just fine, but it's my own code behaviour that I really want to inspect. How should I do this? The only way suggested in the swank-clojure readme is C-x C-e, which is what I've been using until now, and which has the same problem

17:40 with the debugger.

17:40 amalloy: johnmn3: just build clojure (mvn package), then java -jar the compiled jar

17:40 (require '[clojure.core.reducers :as r]) (...play around...)

17:41 or i think there's an already-built snapshot with reducers in it

17:41 coventry: try C-c C-k to eval a whole file

17:41 johnmn3: amalloy: ah, any pointers on where to find that? I've never built clojure with mvn.. I've mostly been living in the lein world

17:42 amalloy: i dunno, the clojure snapshots repo, wherever that is

17:42 oh wait, it's an alpha

17:42 just depend on "1.5.0-alpha1" in your project.clj

17:43 coventry: amalloy: Yay, that's going to make life a whole lot easier. Thanks.

17:56 johnmn3: amalloy: thanks. I'm up with it now.

18:19 peregrine81: Anyway to have a function return a var? for example (defn x [] (fn [y] y)) I want x to return a var to the fn that returns y

18:19 its a contrived example of course.

18:20 Ive seen macros that just create a (def name [y] y)

18:21 but I'd like to return an anonymous var so I can play nice with ring handlers

18:23 kwertii: peregrine81: by "var" you mean you want a symbolic reference to the function, or are you talking about a Clojure Var (with a capital V)? and in either case, what do you mean by "anonymous var"?

18:24 peregrine81: Var, sorry

18:24 So I have a piece of code that returns me a function. I want to pass that into some ring middleware, but the specific ring middleware expects it to be a Var.

18:25 kwertii: peregrine81: no way to just pass it an anonymous function?

18:25 `rand`-AFK: #', maybe?

18:26 emezeske: peregrine81: What ring middleware are you using? It's totally broken if it's not okay with an anonymous handler...

18:26 peregrine81: neither of those worked. here is the bug repot I filed the ring-middleware https://github.com/mmcgrana/ring/issues/72#issuecomment-5971047

18:26 `rand`: I think there's a macro--justasec.

18:27 peregrine81: bishop/handler is defined here if interested https://github.com/tnr-global/bishop/blob/master/src/com/tnrglobal/bishop/core.clj#L118

18:27 johnmn3: is r/map parallelized?

18:27 kwertii: peregrine81: (defn foo [] (def bar (whatever)) seems to work

18:28 peregrine81: kwertii: hmm so if I patched bishop to use def instead of fn.. Lemme give it a shot

18:28 kwertii: though of course this is not exactly pure-functional

18:28 weavejester: peregrine81: You shouldn't need to patch bishop at all

18:29 You just need to make sure that when you reload the namespace, the adapter picks up the new handler.

18:30 peregrine81: I'm not sure how to do that...

18:30 weavejester: peregrine81: Well, you just need to have your routes referenced as a var *somewhere*

18:30 peregrine81: You could also just use lein-ring

18:31 peregrine81: Your code is basically what "lein ring server" does anyway.

18:31 peregrine81: I figured

18:32 it would be nice if bishop/handler returned something that all the middlewares can use though

18:32 instead of creating a seperate var to define my routes and then my bishop/handlers

18:33 since I will only be using them when creating my app which only happens once

18:33 weavejester: It shouldn't be the purpose of arbitrary middleware to deal with Clojure namespace reloading.

18:34 peregrine81: is that the only middleware that expects a var?

18:34 amalloy: johnmn3: yes, if the underlying collection supports folding

18:34 johnmn3: amalloy:

18:35 amalloy: ok

18:35 amalloy: you can tell because (iirc) the definition of map contains (folder ...)

18:35 johnmn3: yea, for some reason my collection is: Object[]

18:35 weavejester: wrap-reload doesn't expect a var - it's just you can't supply a value directly if you want it to change when the namespace reloads.

18:35 johnmn3: when it should be a Vector

18:35 amalloy: wellll, an Object[] could be foldable, but i don't think anyone's made it be

18:36 peregrine81: weavejester gotcha

18:36 weavejester: Plus, you don't supply the var to wrap-reload

18:36 You supply it to run-jetty

18:36 johnmn3: ah.. but a reducer is returned

18:36 so you have to do something like (into [] ...

18:36 weavejester: peregrine81: You could also use something like an anonymous function

18:37 peregrine81: Anything that avoids passing the value directly, because if you do, there's nothing to reload.

18:38 peregrine81: awesome thanks weavejester !

18:38 again

18:38 OwenOu: hi all, what's the clojure convention of naming file and method name, are words separated by "-" instead of "_"?

18:38 weavejester: peregrine81: np - you might want to experiment at the REPL to see what works when you reload a namespace

18:38 amalloy: johnmn3: that's how all the reducers work. (r/some-transform coll) returns a new reducer; the only way to "use" its contents is to reduce over it

18:39 johnmn3: amalloy: does (into [] ... reduce over it?

18:40 amalloy: ~def into

18:40 anyway, yes. into is reduce conj, basically

18:40 johnmn3: okay

18:40 and do you know what reducers default chunk size is?

18:44 peregrine81: weavejester: well the lein ring doesn't quite work either, when I point it towards the base-handler I created it loads fine the first time but no reloads, even if I set :auto-reload? true

18:46 weavejester: peregrine81: I can't think why it wouldn't work. It should do.

18:47 peregrine81: If you can provide an example project where it doesn't work, I can look into it.

18:48 peregrine81: weavejester sure! It is in pretty terrible shape cause I am learning.

18:48 johnmn3: amalloy: looks like 512

18:49 peregrine81: weavejester I wasn't really ready to push it public yet, but why not https://github.com/jeregrine/gamesapi

18:50 weavejester: peregrine81: Okay, I can't look at it tonight (UK time, so nearly midnight here), but I can try to look tomorrow.

18:50 peregrine81: weavejester perfect, hopefully I can clean it up by then. Thanks a ton!

18:53 johnmn3: well, I'm getting 14 seconds on my automaton with vanilla functions and 13 seconds with reducers, naively bolted on.

18:53 I think my algorithm is not tweaked for parallelization though

18:53 10,000 cells wide, 1,000 iterations

18:56 interestingly, though, r version still appears to only rev 2 of my cores. win7, quad core i7

18:56 peregrine81: now I just gotta figure out why lobos hates me

18:57 clojure's learning curve for the language is fairly shallow. The learning curve for libraries, lirbary usage and java is deadly steep

18:57 johnmn3: my naive implemenation of the same with pmap seems to rev 6 out of 8 threads, but runs at 16 seconds

19:14 yea, reducers does not appear to be using my other cores

19:15 is there a way to get the java version from within the repl?

19:16 from the command line, java -version says "1.7.0_04-ea"

19:17 but, from the repl:

19:17 test=> jsr166y.ForkJoinPool.

19:17 CompilerException java.lang.ClassNotFoundException: jsr166y.ForkJoinPool., compiling:(NO_SOURCE_PATH:1)

19:18 jblomo: if clojure was compiled with java 6, it will try to use jsr166y

19:18 johnmn3: yea

19:18 jblomo: the decision is made at compile time, i believe

19:18 johnmn3: I wonder if when rich said:

19:18 +;;todo - dynamic java 7+ detection and use

19:18 he meant he was using java 6 and we needed to detect java 7

19:19 well that complicates things

19:19 jblomo: no, i think it means when a program runs it should detect, 7 vs 6. right now, *when clojure is compiled* it decides

19:20 are you compiling or using a snapshot?

19:20 johnmn3: right, so it's hardwired for java 6 with the jsr in the classpath, right now

19:24 I guess I could build a new lein project, paste in the reducers code, modify the fj bits to use java7, build with lein and install, and then add that to my projects dependencies...

19:29 amalloy: johnmn3: you should probably just build your own copy of clojure.jar - that's what i did when i was working on them

19:31 dnolen: hmm, what would be a good type-hint name for return values which are guaranteed to not be host false-y?

19:32 jblomo: johnmn3: agreed. it is quite simple. git clone git://github.com/clojure/clojure.git, mvn install

19:37 emezeske: dnolen: Have you considered things like AlwaysTruthy or NeverFalsey?

19:37 dnolen: I'm trying to find a synonym for one of those, no luck yet

19:39 dnolen: ^Axiomatic or ^Indubitable are my entries :)

19:40 dnolen: emezeske: heh, would like something short

19:40 emezeske: dnolen: ^1

19:42 jblomo: ^TrueDat

19:45 dnolen: sadly ^object won't work, since 0 and "" are objects.

19:46 ^clj to denote CLJS value?

19:47 amalloy: ^truthy and ^falsey?

19:48 simple and plenty short

19:48 johnmn3: test=> (java.util.concurrent.ForkJoinPool.)

19:48 #<ForkJoinPool java.util.concurrent.ForkJoinPool@3a8dee36[Running, parallelism = 8, size = 0, active = 0, running = 0, steals = 0, tasks = 0, submissions = 0]>

19:48 still only pushes on 2 threads though

19:48 dnolen: amalloy: I don't see a use case for ^falsey.

19:49 making ^truthy less compelling.

19:49 johnmn3: my pmap version pushes on six

19:50 but both parallel versions are slower than the non-par version. which may say more about my decomposition of the problem

19:50 amalloy: dnolen: what are you planning to use this for? eliminating if-tests that depend on always-true functions?

19:51 dnolen: amalloy: eliminating truth tests

19:51 amalloy: has nothing to do w/ always true functions - just hinting that we returning a sensible value that doesn't need to be tested.

19:52 amalloy: we're not returning 0 or ""

19:53 johnmn3: I take it back.. the reducers version is a hair faster than the non-par version

19:53 amalloy: so instead of emitting `if (cljs.core.truth(x)) ...` you want to know when you can emit `if (x) ...`? that's a sensible thing to want but doesn't seem to line up with your first question so i'm making sure i'm following

19:54 dnolen: amalloy: yes that's what we want to eliminate

19:54 amalloy: johnmn3: reducers are like 5-15 times faster in the few cases i've tested. if you're not noticing a huge speedup you're probably not actually using reducers very well

19:54 johnmn3: amalloy: that is probably the case

19:54 dnolen: amalloy: currently we can avoid that with ^boolean or ^seq which covers many cases.

19:55 johnmn3: gonna rethink the problem.. thanks for the help.. bbiab

19:55 dnolen: amalloy: but custom code which wants to really deliver host perf (like core.logic) needs something else - so we know we will only return sensible Clojure values - never 0 or ""

19:56 amalloy: this applies to any host that allows 0 as a false-y value of course.

19:57 amalloy: ^host-safe, ^testable, ^plain, ...

19:58 dnolen: amalloy: naming is hard

19:58 amalloy: indeed. that's why i'm spewing bad names and hoping you'll decide one is good

19:59 what about just ^if-safe - it's short-ish, and describes exactly the technical quality you're indicating

20:08 mmarczyk: dnolen: hi! more fantastic improvements to cljs during EuroClojure, I see :-)

20:10 dnolen: mmarczyk: hullo!

20:10 mmarczyk: yes got some new ideas :)

20:10 mmarczyk: dnolen: :-)

20:13 jblomo: what is the gvec.clj used for?

20:14 mmarczyk: jblomo: vector-of

20:15 jblomo: vectors of primitives, that is

20:15 dnolen: mmarczyk: I think that ensuring that no ops are much more than > 2X slower than Clojure on the JVM for V8 is a realistic goal.

20:15 jblomo: ah cool. i saw vectors of primitives, but didn't connect with that function. thanks

20:16 mmarczyk: dnolen: that is amazing

20:17 dnolen: mmarczyk: yes, anything that takes longer than 100ms for 1000000 iterations in the benchmarks means we're not doing enough.

20:18 emezeske: dnolen: That's a really aggressive goal. I love it!

20:19 mmarczyk: dnolen: right -- must get our act together on those cases -- can't wait to do just that :-D

20:19 dnolen: so, do you have any particular roadmap in mind?

20:20 dnolen: mmarczyk: right now pondering higher order fn invocation.

20:20 mmarczyk: (incidentally, one thing I've wanted to do for a while -- cache hashing on records -- patch @ CLJS-281)

20:24 * TimMc throws a type-system at dnolen

20:25 dnolen: mmarczyk: nice looking now.

20:28 mmarczyk: applied

20:28 mmarczyk: dnolen: cool, thanks :-)

20:30 dnolen: mmarczyk: chunked seqs are bizarrely slow ATM, so I created array-reduce - but I haven't integrated it yet with ChunkedCons or ChunkedSeq

20:31 mmarczyk: dnolen: I'll look into it then

20:32 dnolen: mmarczyk: cool! thx

20:32 mmarczyk: one of the largest bottelnecks was eliminated with INext

20:33 mmarczyk: optional protocol for much faster iteration - since the logic of whether to return nil or () can be in the collection .

20:33 mmarczyk: dnolen: looking at the INext patches now actually -- great stuff

20:37 dnolen: mmarczyk: oh forgot to mention the big problem really was that because next had so many nested tests Closure wasn't lifting fns.

20:39 mmarczyk: dnolen: interesting

20:39 dnolen: hence CLJS-277, right?

20:40 dnolen: mmarczyk: yes, I don't think there are many cases but we should remove them and pay attention to introducing them - if it didn't lift/unwrap with simple optimizations then it won't at all.

20:40 mmarczyk: dnolen: good to know

20:40 dnolen: mmarczyk: I was extra happy to remove coercive-not and coercive-=

20:41 mmarczyk: dnolen: oh yeah!

20:41 dnolen: mmarczyk: also seq, next and rest are type-hinted now that means no pointless truth tests for common pattern.

20:41 mmarczyk: dnolen: I seem to recall there was a place in the code where undefined use to come up in arrays

20:41 dnolen: but it doesn't now

20:41 dnolen: any idea as to what might have fixed that? (or am I misremembering sth?)

20:42 dnolen: mmarczyk: yes nil? was poorly defined.

20:42 mmarczyk: nil? is the one place where we need coercive-=

20:42 mmarczyk: dnolen: ah, I see

20:43 dnolen: mmarczyk: it used be based on identical? which caused the problems.

20:43 mmarczyk: dnolen: makes sense

20:45 dnolen: re: 0e0aa7fdd -- is peek/pop slower than first/next now?

20:46 dnolen: mmarczyk: the issue was just that pop can return ().

20:46 mmarczyk: switched to first/next to follow rhickey's version and avoid seq call.

20:47 mmarczyk: dnolen: I see, thanks

22:17 wolkefm: Hello all - I'm picking up a new machine tomarrow (thinkpad t410) and going to buy one of the clojure books - I've minimal lisp experience and I would say that I'm an incredibly inexperienced programmer. What books would you recoomed knowing my intent is to develop a swing application?

22:17 *reccomend

22:21 tmciver: wolkefm: I didn't have much lisp experience when I started clojure and I read Halloway's 'Programming Clojure' which I think is an excellent book for a beginner. I have the first edition, which is now a little dated, but I recommend the second edition.

22:22 'Clojure Programming' is a new book that is also excellent but I think might be a little fast-paced for someone with no lisp experience.

22:24 wolkefm: I might as well grab both I suppose. I've no job with nothing but time on my hands to make plenty of mistakes. I was also thinking about grabbing 'the joy of clojure'. I remember reading somewhere that it is 'the rabbit hole' or somthing to that effect

22:30 ivan: wolkefm: I really like Joy of Clojure but it is an advanced book with compressed explanations

22:40 wolkefm: Noted.

23:20 johnmn3: so, I'm trying to figure out how to split out work for parallel execution

23:21 and so I'm breaking work up in to managable chunks:

23:21 (defn chunk [coll size] ...)

23:21 (chunk [1 2 3 4 5 6] 3)

23:21 -> [[1 2 3][3 4 5][6 7 8]]

23:21 Can I get what I want with reducers? : (into [] (r/flatten (r/map #(map inc %) (chunk [1 2 3 4 5 6 7 8]] 3))))

23:33 jblomo: reducers will automatically split up the datastructure, so you shouldn't have to do it manually

23:33 if you do want to split up a vector like that, take a look at partition

23:33 johnmn3: ^

23:46 johnmn3: jblomo: thanks

23:47 what about: (into [] (flatten (pmap #(map inc %) (chunk [1 2 3 4 5 6 7 8]] 3))))

23:48 will pmap finish incing the whole collection faster for large collections?

23:49 jblomo: pmap is semi lazy. it tries to stay ahead of the consumer while using all cores

23:49 however, there's a cost to coordinating across threads. pmap is only worth it if your function is relatively expensive

23:49 johnmn3: it appears that inc is too easy gets very little benefit from parallel

23:50 jblomo: probably

23:50 johnmn3: I still don't get that though

23:51 cause if I make my coll 10,000 wide and my window 100 wide

23:51 my chunking window.

23:51 you'd think a larger chunk size -- 1000, for instance -- would make the job more epensive

23:51 expensive

23:52 so just increase the window and apply it to a larger data set and we should see savings, I'd think.

23:52 but I'm not seeing it.

23:54 jblomo: inc'ing 1000 integers is going to take like 50 usec

23:54 to test it out, you may want to make a sleeper function

23:55 something that just sleeps for a 50 msec or something

23:55 johnmn3: inc'ing 20,000 integers with window of 100 takes 7 seconds

23:56 same parallel as non-parallel though. 7 seconds

23:56 jblomo: how are you running those tests?

23:56 johnmn3: that's twenty chunks though.

23:57 (defn pfn [afn arange awindow](into [] (flatten (pmap #(map afn %) (chunkify (range 1 arange) awindow)))))

23:58 (let [_ (time (pfn inc 20000 100))] (println "done"))

23:59 oh, chunkify is a little messy

23:59 where's the clojure pastebin?

23:59 jblomo: wwnot sure. i usually just use github gists

23:59 buti don't have chunkify

Logging service provided by n01se.net