#clojure log - Oct 11 2012

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

0:05 AtKaaZ: ##((juxt name symbol) 'a)

0:05 lazybot: ⇒ ["a" a]

0:07 ivan: &(apply str (repeat 10 "\uFFFF"))

0:07 lazybot: ⇒ "￿￿￿￿￿￿￿￿￿￿"

0:08 AtKaaZ: ,(.length (str (macroexpand '((juxt namespace symbol) `'`'`'`a))))

0:08 clojurebot: 333

0:09 AtKaaZ: ,(* 2 (.length (str (flatten (macroexpand '((juxt namespace symbol) `'`'`'`a))))))

0:09 clojurebot: 58

0:10 AtKaaZ: ,(* 2 (.length (str (macroexpand '((juxt namespace symbol) `'`'`'`a)))))

0:10 clojurebot: 666

0:14 wingy: im reading about interactive development using nrepl

0:14 "Immutant provides two methods for connecting to an application's runtime with a REPL: Swank (for emacs & possibly vim if you are feeling adventurous) and nREPL (for any nREPL client)."

0:14 what does Immutant means?

0:17 muhoo: it's a project

0:18 ,google immutant

0:18 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: google in this context, compiling:(NO_SOURCE_PATH:0)>

0:18 AtKaaZ: $google immutant

0:18 lazybot: [Immutant | Home] http://immutant.org/

0:18 muhoo: clojurebot: google immutant

0:18 clojurebot: First, out of 1760 results is:

0:18 Immutant | Home

0:18 http://immutant.org/

0:29 wingy: after reading this https://github.com/clojure/tools.nrepl i still dont get how to connect to a remote nrepl instance

0:32 AtKaaZ: wingy, like: lein repl :connect nrepl://localhost:50821

0:32 in my case that's the url for the ccw/eclipse started one

0:33 Sgeo: Can nREPL servers be password protected?

0:33 wingy: AtKaaZ: cool it worked

0:33 where did you get that info?

0:34 AtKaaZ: wingy, I remembered it from a video, not sure but maybe it was chas emerick

0:34 in this vid: https://www.youtube.com/watch?v=VVd4ow-ZcX0

0:35 wingy: AtKaaZ: lein help repl

0:35 ill watch it now :)

0:35 i love your video recommendations

0:35 wow 1.30 h :)

0:36 AtKaaZ: ikr, I'm only at 28min :)

0:36 wingy: we should watch a video together some time

0:36 so we can live discuss :)

0:36 i watched movies with my pal like that many times :)

0:37 AtKaaZ: I usually have a few open and paused , do other stuff and randomly continue

0:37 wingy: yeah

0:37 AtKaaZ: wingy, it talks about your :join false which I saw earlier recommended for you, at about minute 28 in the video

0:38 wingy: cool

1:46 uvtc: ,(str/replace "score is 22" #"(\d+)" #(str "1" %1))

1:46 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: str, compiling:(NO_SOURCE_PATH:0)>

1:46 uvtc: ,(clojure.string/replace "score is 22" #"(\d+)" #(str "1" %1))

1:46 clojurebot: "score is 1[\"22\" \"22\"]"

1:46 uvtc: How can I get "score is 122"? ^^

1:47 I want to take the whole thing that matched the regex, then (str "1" whole-thing).

1:51 ivan: ,(clojure.string/replace "score is 22" #"(\d+)" "1$1")

1:51 clojurebot: "score is 122"

1:52 ivan: ,(clojure.string/replace "score is 22" #"(\d+)" #(str "1" (first %1)))

1:52 clojurebot: "score is 122"

1:53 uvtc: Thanks, ivan. But why is that `first` call required there?

1:53 ivan: ,(clojure.string/replace "score is 22" #"\d+" #(str "1" %1))

1:53 clojurebot: "score is 122"

1:53 AtKaaZ: ,(clojure.string/replace "score is 22" #"(\d+)" #(when-let [[x] %] (str "1" x) ))

1:53 clojurebot: "score is 122"

1:53 ivan: something to do with matching groups giving you a vector

1:54 you have a matching group, and a "whole match" (in my vague non-understanding)

1:54 uvtc: Ah, didn't see that if you left out parens, the whole match is $1

1:54 Thanks, ivan!

1:55 Oh wait I'm wrong there.

1:55 ,(str/replace "score is 22" #"\d+" "1$1")

1:55 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: str, compiling:(NO_SOURCE_PATH:0)>

1:55 wei_: how do you traverse a list with an atom that represents the current item? for example, I'm displaying one image in a list of images, and i want to be able to get the next or previous image.

1:55 AtKaaZ: ,(clojure.string/replace "score is 22" #"(\d+)" #(println %&))

1:55 clojurebot: ([22 22])

1:55 #<NullPointerException java.lang.NullPointerException>

1:56 uvtc: AtKaaZ: Wait ... $% vs. %& ...

1:57 AtKaaZ: uvtc, I was only showing what the param(s) are to that function it's that [22 22] vector

1:57 aka 1 param

1:57 but it is due to the grouping parens near the (\d+) right?

1:57 uvtc: AtKaaZ: Oh, right. Forgot about %& in literal function syntax.

1:59 Seems like it would be handy if "$&" meant "the whole match"...

2:00 amalloy: uvtc: $0, i think

2:00 AtKaaZ: ,(clojure.string/replace "score is 22 33" #"(\d+)" "1$0")

2:00 clojurebot: "score is 122 133"

2:00 uvtc: Holy malloy! Avast!

2:00 Thanks, amalloy, that's it. :)

2:00 amalloy: it would be pretty silly for clojure's & notation to sneak into java's regex replacer :P

2:01 AtKaaZ: ,(clojure.string/replace "score is 22 33" #"(\d+)" "1$1")

2:01 clojurebot: "score is 122 133"

2:02 AtKaaZ: wish I knew the answer to wei_ 's question

2:02 wei_: thanks AtKaaz

2:02 I was beginning to wonder whether it was too newb a question

2:03 Sgeo: wei_, maybe two lists, with the head of one of them representing the current item?

2:03 wei_: so i can pop to find the next one. but how to get prev?

2:04 Sgeo: ['(3 2 1) '(4 5 6)] could be, for example, the list 1 2 3 4 5 6 with the current position being on 4

2:04 AtKaaZ: wei_, was the atom the index to an immutable "list" ?

2:04 Sgeo: The previous would be the head of the left list, current is the head of the right list

2:06 wei_: works for me. thanks Sgeo!

2:06 Sgeo: You're welcome

2:06 Note that I don't know if that's idiomatic Clojure style, but it avoids the need for mutability

2:06 wei_: the atom can be that whole structure, i guess

2:07 Sgeo: Note that this concept is, I think, what clojure.zip is about

2:07 AtKaaZ: Sgeo, so when you go to the next, you'd get new lists like ['(4 3 2 1) '(5 6)] ?

2:07 Sgeo: AtKaaZ, yes

2:08 ,(-> '(1 2 3 4 5 6) clojure.zip/seq-zip)

2:08 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.zip>

2:09 Sgeo: ,(require 'clojure.zip :as 'zip)

2:09 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>

2:09 Sgeo: ,(require '[clojure.zip :as zip])

2:09 clojurebot: nil

2:09 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip)

2:09 clojurebot: [(1 2 3 4 5 ...) nil]

2:09 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next)

2:09 clojurebot: [4 {:l [1 2 3], :pnodes [(1 2 3 4 5 ...)], :ppath nil, :r (5 6)}]

2:10 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next zip/prev)

2:10 clojurebot: [3 {:l [1 2], :pnodes [(1 2 3 4 5 ...)], :ppath nil, :r (4 5 6)}]

2:10 wei_: what's with the zip/down?

2:10 AtKaaZ: yep I'm totally lost :)

2:10 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next zip/prev zip/node)

2:10 clojurebot: 3

2:11 Sgeo: wei_, in clojure.zip, when you make a zipper out of something, your "location" starts out as the entire structure itself

2:11 ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/node)

2:11 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: zip, compiling:(NO_SOURCE_PATH:0)>

2:11 Sgeo: ,(require '[clojure.zip :as zip])

2:11 clojurebot: nil

2:11 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/node)

2:11 clojurebot: (1 2 3 4 5 ...)

2:11 Sgeo: ,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/node)

2:11 clojurebot: 1

2:12 wei_: so in this case the list itself is the parent node for the items

2:13 Sgeo: ,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/root zip/node)

2:13 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>

2:14 Sgeo: ..?

2:15 At any rate, the two list structure I showed you is, to the best of my understanding, a form of zipper, even if it doesn't support descending and isn't clojure.zip compatible

2:15 wei_: ,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/up zip/node)

2:15 clojurebot: (1 10 3)

2:16 ori-l: wei_: konami code?

2:16 wei_: right, your implementation does resemble a zipper

2:17 ori-l haha, i think you need a tree for that

2:17 Sgeo: ,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/root)

2:17 clojurebot: (1 10 3)

2:19 Sgeo: I should really sleep now, I have class in less than 6 hours

2:20 AtKaaZ: ,(-> '(1 2 3) zip/seq-zip zip/down zip/right zip/right (zip/replace 4) zip/up)

2:20 clojurebot: [(1 2 4) nil]

2:21 AtKaaZ: oh right, forgot root

2:29 ,(quote a b c)

2:29 clojurebot: a

2:32 AtKaaZ: how would you replace the numbers with d a b c here: ##(-> 4 (list 1 2 3))

2:32 lazybot: ⇒ (4 1 2 3)

2:32 AtKaaZ: other than this ##(-> 'd (list 'a 'b 'c))

2:32 lazybot: ⇒ (d a b c)

2:34 AtKaaZ: ,(-> 'd (list (map symbol '(a b c))))

2:34 clojurebot: (d (a b c))

2:43 AtKaaZ: how do you make a list of params become non-list, in non-macros

2:43 ,(#(do (-> (last %&) (list (reverse (pop (reverse %&)))) ) ) 1 2 3)

2:43 clojurebot: (3 (1 2))

2:46 tomoj: huh?

2:46 AtKaaZ: :) I want to pass 2 param but they are in a list

2:46 there was a simple way but I'm missing it now

2:47 rigth apply?

2:47 tomoj: say what you want like (= (__ + '(1 2)) 3)

2:47 where __ is the blank you want to fill in

2:48 AtKaaZ: it's "apply" what I was looking for

2:48 ,(apply list '(1 2 3))

2:48 clojurebot: (1 2 3)

2:50 AtKaaZ: ok appply would've worked but not in my example: (#(do (-> (last %&) (list (___ (reverse (rest (reverse %&)))) ) ) ) 1 2 3)

2:53 basically I want to do this: (list 1 (2 3)) without flatten and return (1 2 3)

2:53 ,(flatten (list 1 '(2 3)))

2:53 clojurebot: (1 2 3)

2:54 AtKaaZ: that, but without flatten :)

2:55 tomoj, ,(list 1 (____ '(2 3)))

2:57 in other words, is it possible to return a non-collection list of things heh

2:58 I guess macros then

3:11 wingy: clj is such a good repl lang

3:11 AtKaaZ: ok i give up, i wanted a generic way to see the difference between -> and ->> by being able to pass any number and type of params to be added to a list by ie. (funxion-any -> a b 2 ) or (funxion01 a b 2) which would return (2 a b) or (a b 2) if ->>

3:11 ,(#(do (flatten (-> (last %&) (list (reverse (rest (reverse %&))) ) ))) 'a 'b 'c)

3:12 clojurebot: (c a b)

3:13 AtKaaZ: ,(defmacro x [& coll#] `(-> (last '~coll#) (list ~@coll#))) (x 1 2 3)

3:13 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

3:14 tomoj: AtKaaZ: what do you want (list 1 (____ '(2 3))) to be?

3:14 AtKaaZ: (1 2 3)

3:15 tomoj: that's not possible

3:15 ##(apply list 1 '(2 3)) is possible

3:15 AtKaaZ: i was afraid of that

3:15 lazybot: ⇒ (1 2 3)

3:15 tomoj: -> and ->> aren't functions

3:15 AtKaaZ: if I do apply like that, then I can't use it with -> and ->>

3:15 tomoj: ,(clojure.walk/macroexpand-all '(-> a b 2))

3:15 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>

3:16 AtKaaZ: yeah I know it's a macro

3:16 tomoj: ,(clojure.walk/macroexpand-all '(-> a b 2))

3:16 clojurebot: (2 (b a))

3:19 AtKaaZ: ok I guess this is the best I can do ##(#(do (flatten (-> (last %) (list (reverse (rest (reverse %))) ) ))) '(a b c 2))

3:19 lazybot: ⇒ (2 a b c)

3:19 AtKaaZ: ,(#(do (flatten (->> (last %) (list (reverse (rest (reverse %))) ) ))) '(a b c 2))

3:19 clojurebot: (a b c 2)

3:20 tomoj: I guess I still don't understand what you're trying to do

3:21 AtKaaZ: experimenting, but well I wanted to make a generic way of this structure (-> 1 (list 2 3)) where -> 1 2 and 3 etc. would be changable

3:22 so in my example above, I can change/add anything in the (a b c 2) part and the ->>

3:22 the ->> can be one of -> or ->> :) just to see the result

3:28 ok considering the latest revisions: (defmacro x [f# coll#] `(flatten (~f# (last ~coll#) (list (reverse (rest (reverse ~coll#)))) ))) (x ->> '(a b c d))

3:31 or this one might be better: (defmacro x [f# & coll#] `(flatten (~f# (last '~coll#) (list (reverse (rest (reverse '~coll#)))) ))) (x -> a b c d)

3:32 I just wish I could get ~@coll# without the last param

3:32 tomoj: ~@(butlast coll#)?

3:32 clojurebot: Cool story bro.

3:33 tomoj: note you don't need to # the x params

3:33 also ##(#(cons (last %) (butlast %)) '(a b c d))

3:33 lazybot: ⇒ (d a b c)

3:37 AtKaaZ: lol @clojurebot , but how come that works hmm, i tested it that's pretty awesome

3:37 why don't I need to # the params?

3:38 tomoj: you only need gensyms in the code your macro returns

3:39 those params are in the macro code, not its result

3:39 'x#

3:39 &'x#

3:39 lazybot: ⇒ x#

3:39 tomoj: &`(let [x# 3] x#)

3:39 lazybot: ⇒ (clojure.core/let [x__11709__auto__ 3] x__11709__auto__)

3:40 tomoj: why not just macroexpand to see the difference between -> and ->>?

3:43 AtKaaZ: I was already aware of that, so kinda trying experimenting other ways; started from (-> 1 (list 2 3)) and then what if I wanted to allow a b c, then what if I didn't want to manually quote them like (-> 'a (list 'b 'c)) then what if I wanted to pass only the relevant inputs -> a b c to a function

3:44 so far you taught me this important thing: ~@(butlast coll#) and I'm still not yet to the part with x#

3:45 oh right x# I got the part with gensyms not being needed

3:51 ,(apply quote '(a b c))

3:51 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: quote in this context, compiling:(NO_SOURCE_PATH:0)>

3:52 AtKaaZ: ,(map symbol '(a b c))

3:52 clojurebot: (a b c)

3:52 AtKaaZ: ,(map symbol '(a b c 1))

3:52 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String>

3:53 AtKaaZ: actually I want this: (map quote '(a b c))

3:54 wingy: AtKaaZ: you never sleep

3:54 AtKaaZ: maybe in here: (defmacro y [& c] `(list ~@(map quote c))) (y 1 2 3 4 d e)

3:54 wingy, I sleep when I am offline

3:55 wingy: me 2

3:55 sleep code sleep code

3:55 AtKaaZ: I don't code, yet, I'm nowhere near there:)

3:56 wingy: learn code learn code

3:57 AtKaaZ: ,(list (symbol 'quote) 'a)

3:57 clojurebot: (quote a)

3:57 wingy: the best way to learn something is to code something though

3:57 code an app you wanna launch for real

3:58 AtKaaZ: ,(println (symbol "'a"))

3:58 clojurebot: 'a

3:59 AtKaaZ: ,(println 'a)

3:59 clojurebot: a

3:59 AtKaaZ: wingy, yeah but I need to learn some more, experiment randomly

3:59 wingy: use Light Table for that

3:59 its the best learning env

4:00 http://www.chris-granger.com/2012/08/17/light-table-reaches-010/

4:00 AtKaaZ: thanks, I think I've seen it before, but not lately

4:01 wingy: it will make learning clj 1000 times more fun

4:06 AtKaaZ: 18mb launcher wonder why it needs to connect to the internet, not allowing =)

4:07 wingy: for stats

4:07 you got firewall?

4:07 AtKaaZ: yep, I it won't start without internet, oh well

4:07 wingy: heh .. its probably nothing harmful

4:08 trust me .. its worth it

4:08 AtKaaZ: I'll just fake a local server for it lol

4:08 wingy: its like lein .. doing some checks and installing things

4:08 AtKaaZ: in lein we trust :))

4:08 wingy: trust ibdknox

4:08 he is harmless

4:09 it will save you 1000 hours

4:09 when final is here im sure i will ignore "lein repl" :)

4:12 tomoj: datomic should have a pricing plan where you give rich equity for a temporary license

4:13 wingy: they should have a cloud alternative

4:13 providing it as a heroku addon with full managed scalability

4:13 me hate sysadmin works

4:15 tomoj: yeah heroku addon would be cool

4:15 wingy: https://groups.google.com/forum/?fromgroups=#!topic/datomic/6uh2edM-i1g

4:15 no answer though

4:15 tomoj: the peer limit seems weird

4:20 well

4:21 you could pretty easily do in-memory datomic on heroku I think

4:22 though you don't have a lot of ram so..

4:25 wingy: in memory is only for development though

4:25 clojurebot: Ik begrijp

4:26 tomoj: yeah

4:30 wingy: if i make a transaction with datomic: @(d/transact conn [{:db/id #db/id[:db.part/user -1000001] :name "foo"}])

4:30 how do i get back the entity (id) immediately?

4:54 michaelr525: is there anything like that function in core? http://clojuredocs.org/clojure_contrib/clojure.contrib.map-utils/deep-merge-with

4:55 merges a map recursively

4:56 hmm

4:57 i'll just copy that function over to my code :)

5:31 edlich: Sorry first time here. Looking if something happens...

5:59 Kototama: I don't understand people complaining about the Lisp syntax, it's so much better than JavaScript. After writing a few macro here is what I get http://paste2.org/p/2322970

6:02 tomoj: cool

6:02 we can do better than backbone, though :)

6:03 Kototama: probably :-)

6:04 wingy: how do i require the test files in repl?

6:05 it usually is looking for namespaces in the src/ dir

6:05 not the test/ >

6:05 ?

6:08 tomoj: maybe lein with-profiles test repl ?

6:08 just a guess

6:09 er

6:09 edlich: and lein test in another shell is not possible?

6:10 tomoj: with-profile

6:10 edlich: Or possible lein repl and then require the test file (but I didn't test if this works)

6:10 wingy: i just required the namespace that was defined

6:11 it worked since test/ must be in the class path

6:11 edlich: So problem solved?!

6:12 wingy: yeah

6:12 just trying to find a good testing workflow now

6:13 i run it atm with (run-tests 'testing-ns)

6:13 edlich: By the way is someone working with travis-ci.org ?

6:14 The clojure part needs more documentation as: what could be written in the script part etc.

6:15 This might be how you wingy should test ;-)

6:15 wingy: edlich: have not used travis yet

6:16 i'll get there :)

6:16 edlich: it's cool

6:16 but beta.

6:16 wingy: whats the benefits?

6:16 edlich: You can set a github hook.

6:16 So every commit gets an automatic build. Have a look:

6:16 wingy: cool

6:17 edlich: https://travis-ci.org/#!/edlich/rasbojnik

6:17 (but my project is also just starting... (not much code in there...)

6:22 What would be really great would be a clojure coach. There should be a platform to hire one.

6:22 wingy: would be so much better if the failures in clojure.test gave some different colors

6:23 there is a lot of info about clj already

6:23 consult http://thinkrelevance.com/

6:24 edlich: I have ALL books and I am studying them.

6:24 I am thinking more of something as a neat help like small feedback 50 cents, middle Feedback = 2$ big Feedback 5$

6:25 I think I ask Stu when meeting him at the next conference. Good hint. Thanks.

6:25 wingy: yeah he should know

6:27 edlich: By the way do you know a forum to ask technical questions beside the toplevel Google Group #!forum/clojure ?

6:28 wingy: stackoverflow :)

6:29 edlich: OK have to build up a credibility there ;-)

6:33 wingy: is using (with-test) preferable since your tests are coupled with your code

6:33 could it yield better TDD behavior?

6:33 or should we decopule them with (deftest) instead in different files

6:37 edlich: (someone else should jump in here. Not yet a Clojure testing Guru).

6:38 clgv: wingy: separating tests from code is done in a lot of clojure projects.

6:39 wingy: clgv: i've noticed .. but what i like with looking at clj code is that i can read the doc and meta data for the fns as well

6:39 they are all in one place

6:39 perhaps the testing would make it easier to understand how to use the code?

6:40 since if they are in different files i would probably never look at them

6:40 too much work when browsing in github

6:40 :)

6:40 but it seems that no one likes this

6:41 clgv: oh, if I want to see typically use cases and there are tests, I often read them to get an impression

6:41 wingy: it would be nice though, to have some connection between tests and code. maybe via metadata or something

6:42 wingy: what are the bad things with having them in one place

6:42 bloat?

6:42 clgv: depending on the size of your namespaces it could get very crowded

6:42 wingy: yeah .. but that would force everyone to write/read tests :)

6:42 first class citizens

6:43 like doc!

6:43 clgv: I cant follow that conclusion

6:43 wingy: i prefer to read the doc in source code rather than from external places since its all there

6:43 yeah .. just preferences

6:43 ill try both out and see how it works out

6:49 how do i mock http requets?

6:49 clgv: morning laurent ;)

6:50 noidi: wingy, if you're using Ring or something based on it, the requests are just Clojure maps. there's nothing to mock.

6:51 wingy: noidi: im using clj-http to make requests in some fns

6:51 noidi: but ill test the route handlers as well later , thx for the tip

6:51 clgv: wingy: mock the clj-http functions you are using ^^

6:51 hyPiRion: Humm, defrecords doesn't support destructuring for record elements. In hindsight, that may be a good thing.

6:51 wingy: clgv: with dynamic binding?

6:52 clgv: wingy: if you use midje, you can just use its related features...

6:52 wingy: im using clojure.test

6:53 dynamic binding should do mocking pretty easy

6:53 clgv: hyPiRion: huh? defrecord has a 100% map implementation. or what exactly do you mean?

6:53 wingy: if there isnt another mocking way

6:53 no mocking libs in clj?

6:53 clgv: wingy: there are some macros like with-redefs ...

6:54 noidi: wingy, in midje you can do (fact ... (provided (some-fn arg1 arg2) => return-value))

6:54 clgv: noidi: thats one of the features I chose midje for ^^

6:55 wingy: noidi: is there a way to programmatically run midje from repl?

6:55 noidi: wingy, e.g. (provided (client/get "http://www.google.com") => {:fake "response"}))

6:55 hyPiRion: clgv: (defrecord Foo [[bar] baz] ...) isn't legal.

6:56 noidi: wingy, the facts are run upon evaluation. just re-evaluate the fact, and you'll get error printouts in the repl if the tests fail.

6:56 clgv: hyPiRion: ah, you want to define a structuring in the definition. right, that's not going to work

6:56 wingy: noidi: how do you run the tests?

6:57 clgv: wingy: lein test or evaluating the namespace should work

6:57 hyPiRion: Oh, while I remember: Is there any way of making a clojure-set/map/vector/list/seq which contain itself?

6:59 X = #{X} seems to be impossible, which picked my curiosity

6:59 noidi: wingy, there's also the midje plugin for leiningen

6:59 clgv: hyPiRion: yeah cycle references are not possible with immutable datastructures- you'll need some indirection. but you can manage it with transient

7:00 hyPiRion: clgv: not possible with immutable datastructures in Clojure*

7:00 ;)

7:00 clgv: hyPiRion: I think that is general

7:01 noidi: hyPiRion, you can add in laziness with (delay)

7:01 clgv: ok. lazy sequences can have cycles ^^

7:01 hyPiRion: clgv: If you have unbound variables, then it's doable.

7:01 noidi: oops, I mean promise

7:02 clgv: hyPiRion: right. but the variable is then not immutable and thats the trick

7:02 noidi: (let [a (promise), b (promise)] (deliver a {:b b}) (deliver b {:a a}))

7:02 hyPiRion: clgv: I suppose that's depending on the definition of immutable.

7:02 noidi: or something like that >(

7:02 :)

7:03 then you can do (:a @(:b @(:a @(:b a))))

7:03 clgv: hyPiRion: well take maps and vectors. you definitly can't do it with them.

7:04 hyPiRion: clgv: Again, not in Clojure. Say X = {:foo Y}, and Y is unbound. You can then assign Y = X.

7:05 /s/assign/unify/

7:05 clgv: hyPiRion: well if immutable means that the data structure rflects changes by returning a modified version of itself, than you can't do it in general

7:05 hyPiRion: noidi: I know of that one. The sad part is that you have to dereference the items :(

7:06 clgv: hyPiRion: try to build a graph representation with deftype/defrecord (without transients) as edges and nodes where the edges contain both nodes and each node contains its edges

7:07 and :volatile-mutabile and :unsynchronized-mutable are not allowed

7:07 hyPiRion: clgv: yeah, I know. It's not possible in Clojure.

7:08 tomoj: I started implementing inductive graphs

7:08 clgv: hyPiRion: no, with the above definition of immutable it is not possible in general for those immutable data structures

7:08 your unbound variable is a mutable thing which is the trick

7:09 tomoj: is a promise mutable?

7:09 hyPiRion: tomoj: Depends on who you ask :p Clojurians say no, CTMCP says yes

7:09 clgv: tomoj: no but its assignment is defereed

7:09 hyPiRion: * I mean reverse

7:09 clgv: tomoj: you can't change it once it was delivered.

7:09 tomoj: clgv: that seems like a good description of the unbound variable case too

7:10 I think IPending makes clojure's promise's mutable in one sense

7:11 hyPiRion: Yeah, clojure's promise is mutable. If you e.g. do (let [a (promise)] (run-thread (deliver a 10)) (run-thread (deliver a 20))), then a could be either 10 or 20

7:11 clgv: hmm promise is not a value though - it's something you can deref to get a value^^

7:11 hyPiRion: Well, that's my thought.

7:11 clgv: hence the mutable/immutable attributes are not really fitting

7:12 tomoj: my promises can't be delivered that way

7:12 hyPiRion: It's an iffy subject. If I defer the computation of a value, is it immutable or mutable?

7:12 clgv: tomoj: yeah the second deliver will loose and throw an exception

7:12 hyPiRion: ,(let [a (promise)] (deliver a 10) (deliver a 20))

7:12 clojurebot: nil

7:13 hyPiRion: ,(let [a (promise)] (deliver a 10) (deliver a 20) @a)

7:13 clojurebot: 10

7:13 hyPiRion: ,(let [a (promise)] (deliver a 20) (deliver a 10) @a)

7:13 clojurebot: 20

7:13 clgv: huh, was that old 1.2.1 which did throw an exception?

7:13 hyPiRion: clgv: Well, I was actually kind of hoping an exception would be thrown now.

7:13 :(

7:14 clgv: that got changed in 1.3 it seems

7:14 maybe it's useful in some case to have the first deliver win silently

7:15 tomoj: the problem is to let functional clojure code easily get determinism

7:15 hyPiRion: clgv: It's okay if the values you deliver are the same, but well.. it's not deterministic now, is it?

7:15 tomoj: so that you never deliver different values, except when you don't care (IO? random numbers?)

7:16 clgv: hyPiRion: hm yes, it's in your duty to guarantee the determinism

7:24 hyPiRion: &'foo

7:24 lazybot: ⇒ foo

7:30 clgv: &(#(% %) #(% %))

7:30 lazybot: java.lang.StackOverflowError

7:30 Cheiron: Hi, would you please help me with this? http://pastie.org/5034598

7:46 noidi: Cheiron, check out group-by http://clojuredocs.org/clojure_core/clojure.core/group-by

7:46 (group-by :a records-2) will give you a map from the :a value to the record

7:48 Cheiron: I need to match by values . for example (Record-1 :a "1") , i need to match the record in records-2 where its :as also equals to "1" . not sure how group-by will help

7:49 noidi: (for [r1 records-1, :let [r2 (first ((group-by :a records-2) (:a r1)))]] (update-in r1 [:vals] concat (:vals r2)))

7:49 something like that

7:50 note that that's untested semi-pseudocode :)

7:50 Cheiron: noidi: yes thanks :)

7:52 noidi: just look up each (:a r1) in the map produced by group-by and you'll get all r2s with the same :a

7:52 michaelr525: maybe (index) and (join) from clojure.set is worth checking

7:53 inspired by jay fields` post

7:54 Cheiron: noidi: group-by ins't going to work for me

7:54 i don't know, it is hairy ....

7:57 michaelr525: hairy?!

7:57 wtf

7:57 what's hairy about group by?

8:02 Cheiron: not group-by . my data . :a values in records-1 aren't repeated . same true for :a values in records-2

8:03 :a values are unique within the vector but there is a match value in the other vector

8:06 so the question, is how to find by value, not by key

8:07 clgv: Cheiron: the just use something like (for [x r1, y r2 :when (= (:a x) (:a y))] ...build-combined-data...)

8:07 that has quadratic complexity though, in case that matters.

8:07 Cheiron: what the Big(O) of that line?

8:08 Big (N * N) ?

8:08 clgv: O(N²) yes

8:08 Cheiron: any ideas for more efficient code?

8:08 clgv: you will need to sort both collections to get N*log(N)

8:09 you can sort both and then do a recursion over both collections

8:11 Cheiron: what about something like select-value ? http://blog.jayfields.com/2011/01/clojure-select-keys-select-values-and.html

8:14 clgv: Cheiron: you can have O(1) access and a total of O(N) if you build maps of them before. but thats some how cheating since the constants will differ. when sorting you only need comparisons. using a map you need to evaluate a hash function

8:14 but you can try both and see what fits best for your data

8:20 *"constant factors" I meant ^^

8:25 Cheiron: i see

8:44 Cubic: Hi

8:44 I have a bit of a problem with java overloaded methods and reflection

8:45 I'm trying to write a function that calls a static method that has an overload for CharSequence and ByteBuffer

8:46 I want to avoid reflection, and I suppose I can do this somehow, but putting type hints before the argument or the call hasn't really helped

8:48 Basically I have this: (defn glBindAttribLocation [program index name] (GL20/glBindAttribLocation program index ^java.lang.CharSequence name))

8:49 and this: (defn glBindAttribLocationbb [program index name] (GL20/glBindAttribLocation program index ^java.nio.ByteBuffer name))

8:49 clgv: Cubic: you need a typehint for "program" as well

8:50 Cubic: usually you need the first type hint for the first argument if it can not be inferred.

8:50 Cubic: It's int in both cases though, the overloads only differ in the last argument

8:53 clgv: ah ok. then wrap it like (int program)

8:55 Cubic: Huh? Attaching typehints to all args actually fixed it. I don't really understand why, but thanks anyway.

8:57 jweiss: does anyone write tests in the namespace as code, surrounded by a macro that runs tests at compile time unless a "development" flag is not on, in which case the macro just emits nothing? if not, what's the drawback vs separate tests?

8:57 s/namespace/same namespace/

9:03 cberg: I'm feeling stupid today: Running lein repl in a project base dir, I can't access the project namespaces from the repl. What could I be doing wrong?

9:05 edlich: Paste your equivalent as (require 'my-stuff.core)

9:06 then we can see...

9:07 clgv: I'd start with an actual error message ;)

9:07 if you have none, what exactly did you do and what did not happen as expected

9:08 edlich: so you do not even get the REPL prompt?!

9:08 cberg: Ok, so the require worked...

9:09 edlich: what was the mistake?

9:09 cberg: I may be completely wrong but I thought I used to be able to just jump to a namespace with in-ns and work with the symbols there without requiring?

9:12 clgv: cberg: yes, that is completely wrong. in-ns just switches the namespace asnd creates it if it does not exist already. hence you end up in an "empty" namespace if you did not load it's implementation previously via use/require

9:14 cberg: Yeah, sorry. I couldn't use Clojure for a few months and apparently my brain leaked. Never mind.

9:15 clgv: that error seems pretty common. I wonder where `in-ns` is introduced without explaining it properly

9:25 pyrhho: My project depends on two other packages, which each depends on a different version of the org.codehaus.jackson library (which conflict). I'm new to java (and clojure) how should I fix this??

9:25 lazybot: pyrhho: What are you, crazy? Of course not!

9:25 TimMc: $mail antares_ seqs-and-colls is now under dual-license for inclusion into clojure-doc, if desired.

9:25 lazybot: Message saved.

9:26 TimMc: pyrhho: I believe you can put a "hard version" of jackson into your dependency list.

9:26 pyrhho: ah. so if I have a version specified in my project.clj it will override those project's dependencies?

9:26 TimMc: pyrhho: This is really a Maven issue, and for reference these are called conflicting transitive dependencies.

9:27 pyrhho: TimMc: ok. thanks. that is helpful to goodle

9:27 *google

9:28 TimMc: I *think* if you say "[1.2]" (instead of "1.2") in your dependency list it will fix it, but best to look around.

9:28 Do the two Jackson versions have the same major version?

9:29 You might even be able to use a soft version ("1.2").

9:29 pyrhho: TimMc: ah, actually it looks like just setting the version in my project.clj has worked

9:29 duck1123: pyrhho: You might want to check out lein pedantic. It'll identify all the conflicts and help you choose the right versions

9:29 pyrhho: TimMc: erm. maybe

9:30 TimMc: Yeah soft version has worked. thanks

9:30 duck1123: ok will check that out. thanks

9:30 TimMc: What version of lein are you on? 1.x or 2.x (master)?

9:31 pyrhho: TimMc: Leiningen 2.0.0-preview10 on Java 1.6.0_32 Java HotSpot(TM) 64-Bit Server VM

9:36 quadrocube: Hey, anyone out there?) Can smone help me with this stuff: why is these piece of code throw the clojure.lang.ArityException: Wrong number of args (2) passed to: PersistentVector ? Trying to find it out for a couple of hours now..

9:36 ((fn flat[x] ( if (coll? x) (reduce [] #(concat % (flat %2)) x) [x])) '(1))

9:36 just simple flatten

9:37 TimMc: pyrhho: lein classpath is ugly, but it will tell you exactly what's being included.

9:38 pyrhho: TimMc: oh cool.. didn't realise 'lein classpath' existed. thanks

9:46 clgv: quadrocube: because you have the wrong parameter order for reduce ##(doc reduce)

9:46 lazybot: ⇒ "([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, etc. If coll contains no items, f must accept no arguments as... https://www.refheap.com/paste/5716

9:46 dark_element: I am trying to build a project with this as dependency https://github.com/samaaron/serial-port

9:46 clgv: reordering your example: (reduce #(concat % (flat %2)) [] x)

9:48 quadrocube: arrrgh, thx so much, lazybot, dark_element and clgv! Can't forgive myself's stupiditness.. Thx again)

9:48 dark_element: getting this error "java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path" when running the uberjar created from leiningen

9:49 clgv: quadrocube: try to build your code incrementally to avoid such mistakes

9:50 dark_element: I think this project https://github.com/samaaron/serial-port should be used with cake but its discontinued

9:53 any help would be appreciated

9:55 jsabeaudry: dark_element, What are your needs in terms of serial comm?

9:55 clgv: dark_element: I think there was a difference how cake and leiningen packed native dependencies. so you might just need to change the jar layout of the RxTx lib

9:56 dark_element: jsabeaudry just playing around with it reading some string from serial port

9:56 jsabeaudry: dark_element, Then I'd say just read/write to the device using a file stream

9:58 dark_element: clgv will try that out

9:59 jsabeaudry will most probably have to run the jar on windows

10:00 jsabeaudry i am helping somebody to plot volatge ratings from a device in graph, maybe even show it in browser.

10:06 AWizzArd: When I can type „javac” in the shell and get a reply, how can I then find out at what path Leiningen tries to find my javac? Cause Leiningen doesn’t find it…

10:11 bhenry: can i queue up futures to limit how many will run simultaneously?

10:11 nDuff: AWizzArd: My impression was that leiningen used tools.jar directly, rather than invoking javac.

10:14 clgv: bhenry: not until 1.5 I guess. in 1.5 you may change the executor it seems

10:14 bhenry: but you can just use a self configured ThreadPoolExecutor for parallel execution

10:19 bhenry: in update-message here: https://gist.github.com/06cdd93dadcbe68c2378 can i just call each move-data block in a future, then deref the futures so that it will do those three in parallel but not move on to the next three until they finish?

10:19 clgv: no

10:20 bhenry: you can use pmap to have bounded parallel execution - but you can't set the bound yourself with it

10:20 bhenry: hm

10:21 clgv: bhenry: the easiest way to set how many parallel computations are done, is to create a ThreadPoolExecutor yourself

10:23 AWizzArd: nDuff: do you have an idea how I can let Leiningen know where my jdk is installed? JAVA_HOME seems to get ignored.

10:23 mpenet: bhenry: you can also use pallet-thread, a thin wrapper around java executors, if you really dont want to touch java interop

10:24 bhenry: i'll check it out thanks

10:30 lpetit: clgv: hello

10:30 clgv: lpetit: hi

10:31 lpetit: clgv: will start looking at your pull request

10:31 clgv: lpetit: =)

10:32 lpetit: clgv: when you think you're ok with a code in a branch, you should change the corresponding issue' status to Fixed:to-be-integrated

10:33 clgv: lpetit: ah ok. I thought I wait for feedback first. good to know

10:33 lpetit: Since it's ready to be integrated into main, but not done yet (and I'll either change it to Fixed:to-be-delivered, either to Accepted or New if the code needs rework)

10:34 Also, a mention (link) to the github pull request or commit to integrate in the issue comments, so that e.g. Chas or Christophe can take a look at it in a click ;)

10:35 clgv: so, before I dig into the code and into the actual behavior, would you please tell me what it's supposed to do ? ;)

10:36 clgv: lpetit: ok. noted for next time.

10:36 lpetit: ok

10:36 thx

10:38 clgv: lpetit: the patch enables to search the history for entries starting with the text in front of the cursor. the patch unifies the implementation with already existing stepping through history

10:41 lpetit: clgv; ok

10:42 clgv: so we should change the default keyboard bindings … but to what ?

10:42 clgv: lpetit: good question. I thought it good to have them "near to" the history stepping

10:43 lpetit: something like ctrl+alt+up , ctrl+alt+down ?

10:43 clgv: lpetit: we could use "page up/down"

10:44 lpetit: I don't know where "page up/page down" buttons are on my Mac keyboard :)

10:44 AdmiralBumbleBee: fn-up and fn-down probabply

10:44 clgv: lpetit: would be the same as on lein repl with reply

10:45 lpetit: clgv: oh really?

10:45 clgv: lpetit: yeah. it has search there as well

10:46 lpetit: and what about just having search enabled by default? :p

10:46 TimMc: I love it when people thank the bots.

10:46 clgv: humm I'd like to have both available. since sometimes you know I definitely want one of the last three commands

10:47 lpetit: clgv: then you just trigger the history with an empty content in the log area?

10:47 or with the cursor at the beginning of the log area's content ?

10:48 clgv: I think it does not do that yet

10:48 lpetit: clgv: should it do that, what would you think about the suggestion?

10:49 clgv: lpetit: I would have to try if it makes sense. currently it jumps to the end of the line so that you can easily evaluate the entry with trailing enter

10:50 lpetit: if you have both, you can search for something and still go one step back or forth with the other key bindings

10:51 lpetit: I dont know if I or others do or will do that often. I would need to check my behavior on that

10:51 lpetit: clgv: you mean, via the search going to a certain point in history, and then from this point, start browsing the history without the filter to refine the search?

10:53 clgv: lpetit: yeah somethimes you have very similar entries since you only used different parameters. I would suggest to keep both history modes and maybe ask the users if they really need both after a while

10:54 lpetit: clgv: which raises my question again: maybe we could make the new behavior with the search the default, and have new key bindings for the old behavior ?

10:54 clgv: lpetit: ah you meant it like that.

10:54 lpetit: just an idea

10:55 clgv: that could work. and maybe adding only one modification key for the old behavior?

10:56 lpetit: I haven't tested the code yet, but also, out of my mind: it should be possible to come back to what was typed, with the cursor at the same place, if finally the search does nothing. Is this already how it works?

10:56 clgv: yes, the old behavior could be triggered by adding ALT => Ctrl+Alt+Up, Ctrl+Alt+Down

10:56 clgv: lpetit: if you do not change the cursor position you will come back to the initial statement

10:57 lpetit: clgv: and if you change the cursor position?

10:57 clgv: lpetit: if you change the cursor position you changed the query and you wont. hmm that could be added.

10:58 lpetit: currently, it would only go back to retained-input

10:58 lpetit: clgv: needs some real life testing.

10:58 clgv: yeah. fire it up and try ;)

10:59 lpetit: clgv: another idea: have considered doing a less restrictive search? Like you just type "foobar" and every history entry containing "foobar" will be filtered?

10:59 clgv: lpetit: I saw you changed nrepl dep again before my commit. can't the currently used nrepl lib be added to the repository in a third-party directory?

11:00 lpetit: clgv: I understand what you're saying, and your pain. I'm reluctant (currently) to not play by OSGi rules when possible.

11:02 clgv: lpetit: no, I did not consider that kind of search. that would be like in the code completion, I guess. I am only used to the prefix search due to repl-y and rlwrap. but maybe it would be worth it

11:03 lpetit: clgv: would depend whether the ineluctable increasing "noise" introduced would make it doable or not. Of course, this should then go hand by hand with a way to "highlight" the matching portion (but that could be saved for another day)

11:03 clgv: in leiningen I often do something like "(u" -> complete -> "(use '...)" or "(def s" -> complete -> "(def server (create ..."

11:04 I do that a lot if I have a certain debug/test scenario that I recently used

11:04 lpetit: where you could write "serve" -> history -> "def serer (create ...)"

11:06 Sometimes, also, the most "unique" part of the history entry you can think of is not at the start of the line. Think about unique local names, etc. ?

11:06 clgv: maybe the "search" function could be specified as a preference :)

11:06 s/search/filter/

11:12 clgv: lpetit: that's an option

11:13 I justed wanted to name my frequent use case on the repl ;

11:17 lpetit: que

11:17 sure

11:19 clgv: lpetit: well, it's implemented with exchangeable filter anyway ;)

11:19 lpetit: clgv: :)

11:19 clgv: I've got some urgent emails to answer to, bbl

11:20 clgv: lpetit: np

11:47 holo: hi

11:48 jsabeaudry: helo

11:48 holo: anyone here is being able to use heroku commands with default app in a directory with multiple apps?

12:00 Cubic: Is anyone here that uses emacs with clojure-mode?

12:01 Frozenlo`: Sure

12:02 Cubic: I've been trying to find a cheat sheet (or something the like) for it for a while now

12:02 AdmiralBumbleBee: Cubic: lots of people do

12:02 Cubic: basically just a list with the things it actually does

12:02 Right now I'm quite desperately trying to comment out a section of my code and it won't let me

12:03 AdmiralBumbleBee: Cubic: c-h b?

12:03 Frozenlock: You mean ';' won't comment the line?

12:03 AdmiralBumbleBee: Cubic: are you using any other modes?

12:03 Frozenlock: M-x comment-region is really useful too.

12:03 uvtc: Cubic: M-;

12:04 Cubic: I'm using paredit with clojure-mode. And ; always starts a new line

12:04 AdmiralBumbleBee: you could also mark a region, c-x r t, and ;;

12:04 M-; is preferred though

12:04 uvtc: Oh, paredit.

12:04 * Frozenlock runs away when he sees paredit

12:05 Cubic: Oh great what now? Is that bad? Everyone and their dog told me paredit was the best thing since the invention of chocolate

12:05 TimMc: It is!

12:05 Frozenlock: It is, but I don't like it :p

12:06 AdmiralBumbleBee: Cubic: it's fine, you have to mark and use M-; or use rectangle commands or c-q ;;

12:06 uvtc: Cubic: my understanding is that paredit is wonderful, and most folks here recommend it unconditionally, but you've got to dive in head-first and power through the initial learning curve. I haven't yet done so myself.

12:07 TimMc: Cubic: You can also use #_ if you're commenting out syntactically valid code.

12:07 ,[1 2 3 #_ 4 5 6]

12:07 AdmiralBumbleBee: Cubic: in general, if you find something like that again, you can just use c-q to avoid triggering any mode-related bindings

12:07 TimMc: clojurebot: hello?

12:07 AdmiralBumbleBee: then find the 'real' solution later

12:07 Bronsa: woah, what happened to clojurebot

12:08 TimMc: &[1 2 3 #_ 4 5 6]

12:08 lazybot: ⇒ [1 2 3 5 6]

12:08 uvtc: Cubic: I wrote up a little Emacs+Clojure tut, if you're interested: http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html

12:08 Frozenlock: uvtc: 10 minutes emacs tutorial is quite misleading I would say :P

12:08 Cubic: Eh thanks everyone. I'm pretty much new to emacs (I used it barely enough to be able to open and edit files without accidentally installing DOS in the process)

12:09 uvtc: Though, I really need to look into how to find out when there's an Ubuntu Emacs 24 so I don't have to add the cassou ppa...

12:09 Frozenlock: I don't think so. It takes a while to internalize the key-combos, but I'd say 10 minutes is somewhere in the right ballpark for just getting your bearings straight. :)

12:10 AdmiralBumbleBee: in my experience, learning emacs is more about learning how to find help, not so much memorizing combos and chords

12:11 Frozenlock: uvtc: Must have took me around 2 hours the first time... buffers? Windows? Frame? Wtf am I doing AHHHHHHHH

12:11 zilti: Frozenlock: lol

12:11 Cubic: I got that down, but I still accidentally close windows and kill buffers I shouldn't all the time

12:11 Frozenlock: Coming from windows, I was utterly lost.

12:12 uvtc: Frozenlock: I may need to add those terms to my little tut. Thanks.

12:12 AdmiralBumbleBee: how would you accidentally kill a buffer you don't want to1?

12:12 Cubic: You'd be surprised

12:13 AdmiralBumbleBee: I already am

12:13 Frozenlock: AdmiralBumbleBee: If it hasn't changed since last save it will not ask you "are you really sure"

12:14 Cubic: Well, I definitely managed to kill my REPL at least once when I tried to close an error window

12:14 AdmiralBumbleBee: Frozenlock: I'm unsure of how you'd kill the wrong buffer, it's pretty obvious where you are (at least I think it is)

12:14 maybe you guys are just using a crappy theme :)

12:15 Frozenlock: Yes, but if you misclick you could click the little "x" thingy and close emacs :P

12:15 uvtc: Cubic: might be better to just start off for now with Emacs+clojure-mode, and then interact with Clojure in a repl in a separate terminal.

12:15 Frozenlock: That's before you learn the way and remove the menu bar of course :)

12:16 AdmiralBumbleBee: Frozenlock: if you're using the mouse when you're in emacs, I think that's probably a big problem :)

12:16 uvtc: Cubic: then, once you're comfortable with that, add in paredit. And then later nrepl.el.

12:16 Frozenlock: Amen to that.

12:17 Cubic: uvtc: I usually just throw in everything at once and then just try until I get some kind of flow. Worked with Vim anyways

12:17 clgv: Is clojure.core/require threadsafe when multiple threads try to require the same namespace dynamically?

12:17 Frozenlock: Cubic: Then lean elisp and make your own modes :)

12:17 technomancy: clgv: no =(

12:17 no transactional loading

12:17 Cubic: clgv: is there actually a good reason to want to do that?

12:18 clgv: technomancy: ok that explains an observation of mine. so I have to wrap it in some coordination on my application level

12:19 Cubic: yes. remote code execution. all the code base is on the remote classpath and only function symbols are send to the remote side along with parameters

12:22 technomancy: is something like this in work?

12:22 technomancy: transactional loading, I mean

12:22 technomancy: clgv: I don't think so

12:23 clgv: technomancy: humm it shouldnt be hard to do or do I miss a major problem?

12:23 technomancy: clgv: ever try to contribute to clojure?

12:23 clgv: technomancy: ok, apart from that ;)

12:24 lpetit: clgv: I have tried the feature. It's easier to remember the keyword by still having the up/down arrows do their job, and just with an additional modifier (alt works for me on Mac keyboard, so ctrl+alt+UP / ctrl+alt+DOWN to be precise)

12:24 clgv: but when I started moving in the history, even if I don't move the cursor, I lose what was currently typed

12:25 clgv: lpetit: it should work like stepping through history which can come back to what was typed.

12:25 lpetit: clgv: I'm wrong. It's if I move the cursor. But see? Moving the cursor is easy, so I'd prefer not lose what was type should I go back to it

12:25 clgv: leptit: I tried that one out before commiting ;)

12:26 Cubic: Is there something like Vim C-v i b in Emacs?

12:27 jsabeaudry: What does that do?

12:27 clgv: lpetit: ok I guess that could be fixed.

12:27 lpetit: clgv: I mean, I think this should get special treatment and be retained whatever the filter function at the end of the history list (really, it is not part of the history list yet, just appended to it during the search, I guess)

12:27 AdmiralBumbleBee: Cubic: what is that?

12:27 Cubic: Selects the inner parts of the current block (S-expression in Lisps) and if that already is selected, goes to the next outer scope

12:28 clgv: lpetit: yes. it could be removed from the forward search and put in an `or` form with the result of the forward search, or similar

12:28 Cubic: Well the C-v part is just for entering visual mode

12:29 wingy: is there a way to remove all removed vars when i use (require ns :reload-all) in the repl

12:30 lpetit: clgv: cool

12:31 intranation: Cubic: try expand-region: https://github.com/magnars/expand-region.el

12:31 clgv: lpetit: will you change that yourself or shall I fix that next time?

12:32 lpetit: I'd prefer if you fix that and submit a new pull request

12:32 AdmiralBumbleBee: Cubic: why are you trying to do that?

12:34 Cubic: For commenting out (or removing comments) in front a function definition (or similar) also, I want to select (and copy) the contents of a vector all the time cause I'm writing some OpenGL glue code at the moment

12:34 where I'm just writing (defn glSomething [args] (GLSomeVer/glSomething args))

12:34 AdmiralBumbleBee: Cubic: you want to prepend a selection of lines with text?

12:35 or remove text?

12:35 Cubic: I want to select the lines in the first place

12:35 lpetit: clgv: I found a bug

12:35 AdmiralBumbleBee: Cubic: ideally you'd use C-M-f and C-M-b to navigate and set mark

12:35 lpetit: clgv: say the history is "1 :a", "2 :b", "3 :c", "4 :d".

12:36 clgv: say I start searching for "b" => I jump to "2 :b". Now I start editing. And I change my mind, erase the content, and start searching for "c" => I don't find it, because it starts searching from "2 :b" in the history

12:37 AdmiralBumbleBee: Cubic: there's also C-M-h

12:37 Cubic: AdmiralBumbleBee: I don't really know what that does. At least I see no difference to M-f and M-b

12:37 clgv: lpetit: hmm ok. so we need some kind of reset when editing

12:37 lpetit: do you want me to add comments on the ticket for all this ?

12:38 clgv: lpetit: yes, please

12:39 lpetit: ok

12:39 AdmiralBumbleBee: Cubic: M-f is forward word, C-M-f is forward-sexp

12:41 Cubic: AdmiralBumbleBee: Ah I see. That's still rather unwieldy though ;)

12:42 lpetit: clgv: ok, issue updated. We're on the right track !

12:42 :-D

12:42 AdmiralBumbleBee: Cubic: you could always make a macro real quick

12:43 clgv: lpetit: is the pull request closed? or should it be updated somehow when the corrections are done?

12:43 lpetit: clgv: I don't no much about pull requests. I don't know if it can be updated, or should be discarded.

12:44 clgv: lpetit: ah ok. I thought you might have a default workflow there. so I'll just figure that out, when I commited again

12:44 lpetit: clgv: while we're at it: would be great if that could be done in a branch reflecting the issue name. I'm used to this with cemerick, works great because I won't accidentally pull more than expected

12:45 clgv: lpetit: ok

12:45 lpetit: those "lightweight" branches work then like easier to manage patch files :)

12:46 clgv: one last word please - consider rebasing your branch on the last master before issuing the new pull request

12:47 clgv: lpetit: yes. I did that with last too ;)

12:47 lpetit: :)

12:50 clgv: I'm glad you started working on this

12:54 clgv: lpetit: it was bugging me for a while. there are also two additional REPLView things I want to fix

12:54 hyPiRion: ,(clojure.pprint/cl-format true "~9f~%" 3.045236495677389)

12:54 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.pprint>

12:54 hyPiRion: (require '[clojure.pprint])

12:54 ,(require '[clojure.pprint])

12:54 clojurebot: nil

12:54 hyPiRion: ,(clojure.pprint/cl-format true "~9f~%" 3.045236495677389)

12:54 clojurebot: 3.0452365

12:54 wingy: what are the diffs between with-redefs and with-redefs-fn

12:55 hyPiRion: ,(clojure.pprint/cl-format true "~,9f~%" 3.045236495677389)

12:55 clojurebot: #<NumberFormatException java.lang.NumberFormatException: For input string: "3045236495">

12:55 lpetit: clgv: spoilers please :)

12:55 wingy: im doing mocking for tests but dont know why i would wanna use the latter .. the former works great already for fns

12:55 clgv: lpetit: they are not as big as search: repl history size as option and removing "noise" from history

12:55 hyPiRion: Okay, why is not "~,9f" working properly here? Is this a bug in cl-format?

12:56 lpetit: clgv: tell me more about "removing noise" from history, please

12:57 clgv: lpetit: there are clojure comments in the history as well as (in-ns ' ...) statements that came from CCW and not from the user

12:57 Cubic: ,(clojure.pprint/cl-format true "~{~a ~}" [1 2 3 4])

12:57 clojurebot: 1 2 3 4

12:57 Cubic: Ohh I didn't know that

12:57 lpetit: clgv: ok, you should probably talk to cemerick about this one

12:58 clgv: lpetit: ok. I'll ask him before I start anything

13:13 lpetit: finishing time for today. good evening.

13:20 Sgeo: *sigh*

13:21 In Incanter, I saw some code that modifys refs... several refs, but each modified ref is modified in a separate dosync

13:21 Doesn't that kind of eliminate the point of STM in the first place?

13:21 Admittedly, since it's occuring in a macro, it's not likely to be a big deal in actual usage, but still...

13:22 duck11231: does each change need to pass or fail together?

13:23 Sgeo: Hmm, not entirely sure. It doesn't make conceptual sense for one to pass and another to fail, but I think if other changes occur mixed in with those it's not a big deal?

13:25 https://github.com/liebke/incanter/blob/077cde547363afe675fd8400de11dda0a4b47952/modules/incanter-core/src/incanter/infix.clj#L42

13:26 Also, ref-set where alter would be more stylistically appropriate, but since it's a ref in a transaction rather than an atom, it shouldn't make a semantic difference the way it would with an atom and reset! vs swap!

13:28 Oh hey, there actually is a significant problem with that code due to the split of dosyncs

13:29 * nDuff has had to split dosyncs in a situation where one branch needed some expensive IO; that wasn't fun.

13:29 Sgeo: +highest-precedence+ could receive a lower highest-precedence in a race condition

13:30 Although... does macro code ever get run in different threads?

13:30 Or is the compiler/macroevaluator/whatever single threaded?

13:34 Oh wait defop is a function not a macro

13:34 So yeah, that doesn't matter

13:34 It should be fixed. I will fix it when I have time.

14:16 Frozenlock: Weird... In noir I have a page showing me "{:status 302, :headers {"Location" "/subscribe"}, :body ""}" Instead of redirecting. Any idea what might be happening?

14:17 Could the special form 'do' be messing things up here?

14:31 amalloy: you're rendering a map with hiccup as the response body, instead of making it the whole ring response

14:36 Frozenlock: So it seems. I've found the function causing this, but I don't know why.. https://www.refheap.com/paste/5728

14:36 Oh wait it might be because 'body' is returned inside a list.

14:46 jcromartie: Noir: because sessions are magic

14:47 cemerick: jcromartie: snarky, much? ;-)

14:47 jcromartie: very much

14:47 cemerick: Sessions are sorta magic everywhere, really.

14:47 Frozenlock: What's not to like?

14:47 cemerick: !, !, !, generally

14:48 meanwhile, native ring sessions are simple, but hard

14:48 Frozenlock: By ! you mean mutations?

14:48 cemerick: yah

14:48 jcromartie: mutating thread-local bindings

14:50 Frozenlock: Any simple example of ring sessions?

14:50 jcromartie: cemerick: what's so hard about Ring sessions?

14:50 xeqi: heh, there are some fun rules about updating them

14:51 cemerick: jcromartie: if you're passing around full response maps, you need to be very careful about consistently applying downstream changes/additions to the existing state from the request

14:51 I ran aground on that myself last week with Friend.

14:51 jcromartie: hmm

14:52 I actually don't really have a problem with stateful sessions as middleware

14:52 cemerick: well, maybe you've been doing it right this whole time :-)

14:52 l1x: , (/ (System/currentTimeMillis) 1000)

14:52 jcromartie: I also think the word "actually" is actually useless in most cases

14:52 clojurebot: 269996228887/200

14:53 cemerick: it *works*, it's just easy to forget the rules.

14:53 l1x: hmm, how can i get back long rounded after the division?

14:53 jcromartie: what are the rules?

14:53 I always use merge/update-in/etc. when dealing with response maps

14:53 duck11231: ,(long (/ (System/currentTimeMillis) 1000))

14:54 clojurebot: 1349981214

14:54 cemerick: jcromartie: weavejester can probably state them more succinctly, but basically: you need to consistently propagate any :session provided by a downstream handler

14:55 jcromartie: and by "downstream" you mean like, an "inner" handler

14:55 I always get a little mixed up with middleware terminology

14:55 weavejester: Right, the base session middleware is very simple - you can only read the session or replace the session.

14:55 cemerick: yes, or any other function that returns a response map you're going to pass along

14:55 duck11231: it's hard to know which way is up

14:56 l1x: duck11231: thanks

14:56 jcromartie: my middleware basically follows the pattern: (if-let [resp (handler req)] (-> resp …))

14:56 or rather when-let

14:56 l1x: i guess this variable is always 64 bit on every platform

14:58 tmciver: weavejester: I'm having trouble getting compojure.route/files to serve static files when I run my compojure app using 'lein run'. I see that 'public' is the default root directory. Does that mean files will be served from <project-dir>/public? It doesn't seem to work for me.

14:58 jcromartie: but aren't sessions just a convention and not any sort of standard?

14:58 you could really do whatever you want

15:00 weavejester: tmciver: That's correct. What does your route look like?

15:00 tmciver: (route/files "/") ?

15:00 tmciver: weavejester: yes. let me do a quick sanity check.

15:00 weavejester: tmciver: Incidentally, route/resources is usually preferred over route/files.

15:02 tmciver: weavejester: I have test.js in <project_dir>/public. If I go to localhost/test.js, I get the 'not-found' route.

15:03 weavejester: tmciver: Could you show me what your routes look like?

15:08 tmciver: weavejester: https://www.refheap.com/paste/5729

15:09 cemerick: jcromartie: Sure, but it all ends up needing to boil down to a token/cookie that will round-trip on the next request, etc.

15:09 jcromartie: yes

15:12 tmciver: weavejester: I also noticed that the 'file-path' local in the files function is 'test' when I try to get my test.js file.

15:15 weavejester: tmciver: Hm… let me look into this

15:15 tmciver: Out of interest, is there any reason you're using files instead of resources?

15:17 tmciver: weavejester: none at all. But I just tried to use resources with the same result.

15:18 weavejester: am I correct to assume that the dir that 'public' is supposed to in is the project dir?

15:18 amalloy: weavejester: fwiw i use files instead of resources because there's better support for things like Last-Modified, MIME types and so forth

15:19 weavejester: tmciver: Yes, and I can't reproduce your problem… How are you accessing your routes? By running the adapter and accessing them through a browser or HTTP client?

15:19 duck11231: hmmm... for some reason, it looks like I'm using wrap-files and wrap-file-info

15:19 weavejester: amalloy: Ring 1.2 should have better support for last-modified on non-file resources

15:21 tmciver: weavejester: yes, I'm running the Jetty adapter through 'lein run' and using a browser. The other routes work fine with that setup.

15:21 weavejester: I've no doubt I'm doing something silly, I just don't know what.

15:22 weavejester: tmciver: What happens if you run the following code in a REPL:

15:22 ((route/files "/") {:uri "/test.js", :scheme :http, :request-method :get, :headers {"host" "localhost"}})

15:24 tmciver: weavejester: that seems to work correctly . . . hmm

15:25 weavejester: tmciver: Okay, next try passing the same request map to your routes

15:25 e.g.

15:25 (routes {:uri "/test.js", :scheme :http, :request-method :get, :headers {"host" "localhost"}})

15:25 tmciver: weavejester: 404

15:26 TimMc: antares_: ping

15:26 antares_: TimMc: pong

15:26 TimMc: Mail for you!

15:26 weavejester: tmciver: Innnnnteresting…

15:26 TimMc: lazymail

15:26 weavejester: tmciver: Try cutting out all the routes except for the files route and the not-found route?

15:26 tmciver: weavejester: I'd love to tell you that I'm doing something strange, but I don't think so.

15:27 weavejester: tmciver: Then if that works, add the other routes back in until the 404 appears

15:27 antares_: TimMc: I see no new emails. Or is it this IRC/lazybot mail thing? I don't know how to use it :)

15:27 lazybot: lazymail

15:28 clojurebot: lazymail

15:28 clojurebot: No entiendo

15:28 TimMc: Yeah, I don't know how to use it either. :-P

15:28 antares_: clojurebot: mail

15:28 clojurebot: if you can access the email account that is signed up then you winn

15:28 TimMc: Anyway, the seqs-and-colls repo is dual-licensed compatibly with clojure-doc now.

15:28 antares_: TimMc: ah, nice

15:28 tmciver: weavejester: 404 still. :(

15:29 TimMc: $mail TimMc test

15:29 lazybot: Message saved.

15:29 antares_: I am finishing dinner and going to work on namespaces and collections/sequences guides

15:29 TimMc: thank you

15:29 TimMc: lazybot: Mail for me?

15:29 weavejester: tmciver: Hm...

15:29 tmciver: weavejester: I've got (route/resources "/") for the static files route.

15:29 weavejester: tmciver: Oh! You switched?

15:29 TimMc: antares_: "/msg lazybot mail" seems to be the thing

15:30 weavejester: tmciver: If you're going with resources, the directory changes to "resources/public"

15:30 antares_: does lazybot use /dev/null for mail? :)

15:30 ah, cool

15:30 thanks TimMc

15:30 tmciver: weavejester: so my test.js file should be in 'resources/public'?

15:31 weavejester: tmciver: If you're using resources. If you're using files, it can be in 'public'

15:31 tmciver: weavejester: OK, went back to files and it seems to work with the other routes commented out.

15:31 from the repl

15:32 weavejester: tmciver: Okay, try adding all the other routes back and trying it from the REPL again

15:32 Hodapp: I read "REPL again" as "Republican". I eagerly await election season in the US being over.

15:33 TimMc: I, too, need new glasses.

15:33 I read "electron season".

15:34 weavejester: Hodapp: Now I need to resist jokes about functions that return different results for the same arguments...

15:34 tmciver: weavejester: yeah, seems to work from the repl now with all the routes, but not from a browser. I'm baffled.

15:34 ToBeReplaced: i'm getting confused with the information out there regarding SLIME/swank-clojure/nREPL >> i can't figure out what the intended use is now that swank-clojure is deprecated >> am i supposed to "lein repl" then "M-x nrepl" to it from emacs?

15:35 weavejester: tmciver: Well, we can peek at the request map being passed in with some middleware

15:35 tmciver: (defn wrap-prn [h] (fn [r] (prn r) (h r)))

15:36 tmciver: weavejester: OK, I'll try that. Let me get back to you with the result; got to go do my 'real' work :(

15:38 Somelauw: jcromartie: Aren't all irc clients textual?

16:09 TimMc: ,alive?

16:09 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: alive? in this context, compiling:(NO_SOURCE_PATH:0)>

16:10 ddeaguiar: ,(doc alive?)

16:10 clojurebot: Gabh mo leithscéal?

16:10 ddeaguiar: hm

16:10 fractaloop: WTF?

16:11 ddeaguiar: what was that..

16:11 Somelauw: ,dead?

16:11 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dead? in this context, compiling:(NO_SOURCE_PATH:0)>

16:11 TimMc: I was just checking if clojurebot was back.

16:11 ddeaguiar: o

16:14 jcromartie: was clojurebot speaking Gaelic?

16:15 scriptor: most clojure devs speak Irish, didn't you know?

16:15 fractaloop: ....

16:16 devth: anyone know an up-to-date reference on clojure.data.zip.xml? most results are for old contrib and don't work anymore.

16:24 Somelauw: can all languages be implemented as a macro in clojure?

16:24 is there prolog?

16:25 emezeske: Somelauw: You might be interested in core.logic

16:26 Somelauw: it's even in the core

16:29 technomancy: ToBeReplaced: M-x nrepl-jack-in is the way to go. if you have slime set up and working you can keep using it though; it's not going away

16:30 ToBeReplaced: technomancy: thanks >> i was missing the prefix argument to make it more awesome

16:33 technomancy: this page needs editing to match the current state of the world if you're feeling generous; i'm not signed up yet >> http://dev.clojure.org/display/doc/Getting+Started+with+Emacs

16:36 AtKaaZ: how can I see all fields/methods of a class? which is like of this type: clojure.core$future_call$reify__3499

16:37 in an attempt to get the difference between java's Future, clojure's future and @future

16:38 antares_: AtKaaZ: do you need to use it from Java? Why would you need to instapect methods on a future implementation?

16:38 AtKaaZ: ,(def f (future (Thread/sleep 1000) nil )) (cancel-future f) f

16:38 antares_: @future is the same as (deref future), which basically calls #deref on it

16:38 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

16:38 AtKaaZ: ok but what is the underef-ed future supposed to be?

16:38 antares_: you can treat Clojure futures as Java futures if you need to.

16:39 AtKaaZ: true I tested that a bit

16:39 antares_: just like j.u.c. future, it is a reference to a value that may or may not be available

16:39 if you call #get on it, it will block the current thread until it is available

16:40 AtKaaZ: ok, in other words it also knows if it's pending, completed or cancelled?

16:40 if it were cancelled what would f and @f look like?

16:40 it seems to me that @f should throw, but maybe f shouldn't?

16:41 antares_: AtKaaZ: and what should it do then?

16:41 AtKaaZ: but since f also shows the @f then it should throw also , I don't know:)

16:41 antares_: if it is cancelled, you never will get the value it is supposed to reference

16:41 AtKaaZ: yes I agree

16:42 so when you try showing f, you also invoke @f if the future is done ?

16:42 or even if it's cancelled? in an attempt to show all

16:43 if the future is pending, showing f shows #<core$future_call$reify__3499@7c9391d9: :pending>

16:43 but if it's cancelled shouldn't it show cancelled?

16:43 yet it thows instead

16:43 but @f should definitely throw in this case

16:43 reactormonk: I have a bit of an idea of lisp, what do I start with for closure?

16:43 hiredman: well, getting the name right helps with googling

16:44 brehaut: AtKaaZ: have you done a (source future-call) ?

16:44 TimMc: reactormonk: Are you asking how to get started developing in Clojure?

16:44 reactormonk: TimMc, exactly

16:44 except I might call it coding

16:44 TimMc: Sure.

16:45 Grab Leiningen and you can get a REPL that way (and set up projects, etc.)

16:45 reactormonk: I'd like to use emacs

16:45 pandeiro: is using aget to retrieve dynamically resolved javascript object property names a bad approach?

16:46 reactormonk: TimMc, oh, nice

16:46 TimMc: reactormonk: I generally write in Emacs (with clojure-mode and paredit) and use lein for the REPL, so I'm the wrong person to ask. :-)

16:46 AtKaaZ: brehaut: I have now but can't pretend to understand :) btw, I only asked because someone reported it on clojure ML

16:46 _ulises: reactormonk: you can use nrepl for that

16:47 reactormonk: TimMc, sounds like the way I'd do it

16:48 AtKaaZ: brehaut, but thanks that is actually what I wanted to know, methods/fields

16:48 jweiss: i have an apparently large datastructure in memory (not so large that i'm almost out of heap space - set to 1G and taking up 500mb). but i can't figure out how to dump this to disk without going OOM. spit won't do it. nor will any prn/print variant. any suggestions?

16:48 patchwork: Is there any way to tell lein to start up without checking the net for deps?

16:49 trying to use lein sometimes when I don't have a connection

16:49 and it just hangs

16:49 technomancy: patchwork: sure; `lein -o whatever`

16:49 ChongLi: I'm having a weird issue with nrepl

16:49 it's adding a bunch of newlines whenever I press enter at the repl

16:50 reactormonk: TimMc, I ♥ paredit. I even edit syntax trees for linguistics with it :-)

16:50 patchwork: technomancy: Thanks!

16:50 ChongLi: causing my history entries to be full of newlines that I have to delete in order to read the entries

16:50 does this happen to anyone else?

16:50 technomancy: patchwork: that will remove other profiles, so if you want dev/user etc you may be better off with `lein with-profile offline,user,dev,default repl`

16:54 aperiodic: jweiss: maybe try a doseq? won't be a printable form unless you do some work, but seems worth a shot

16:54 s/printable/readable

16:55 jweiss: aperiodic: interesting, might work. i just don't get why the various print functions gobble up so much memory

16:56 way more than the original data takes up in heap space.

16:56 aperiodic: jweiss: they probably build up the entire string for the datastructure before dumping it to disk

16:59 hmm, reading in the result might cause problems too, if your plan is to gobble the whole thing up and call read-string

17:00 jweiss: aperiodic: i don't need to read it back. problem is probably some loop out of control adding too much data, i should be able to tell if i can just look at it.

17:03 ah appears to be a function that produces infinite seq that i accidentally traced. woops.

17:09 ticking: hmm I was wondering what is the best way to check if a potentially infinite list has still 2 elements?

17:10 (if-let [sec (second myseq)] foo) seems flawed because of data transparency considering nil

17:11 technomancy: ticking: (get (into [] (take 2 my-vec)) 2 :not-found) I guess?

17:11 rather: (count (take 2 my-seq))

17:11 amalloy: (nnext my-seq)

17:12 or just next, i guess, since you only want to check for two. that checks for three

17:12 ticking: right

17:12 amalloy: &(map next [[] [1] [1 2] [1 2 3]])

17:12 lazybot: ⇒ (nil nil (2) (2 3))

17:12 ticking: yeah makes sense thanks ^^

17:13 AtKaaZ: ,(nnext (range))

17:13 clojurebot: (2 3 4 5 6 ...)

17:13 ticking: '(empty (next [1]))

17:13 ,(empty (next [1]))

17:13 clojurebot: nil

17:14 ticking: right yeah thanks ^^

17:15 amalloy: ticking: don't call (empty) on the result. that's a disaster

17:15 ticking: ah right because it already returns nil if it is empty

17:16 amalloy, also I meant empty? ^^

17:16 amalloy: ticking: but don't use empty? either, because there's no reason

17:16 ticking: right

17:17 AtKaaZ: ,(next [1])

17:17 clojurebot: nil

17:17 AtKaaZ: ,(next [1 2])

17:17 clojurebot: (2)

17:17 AtKaaZ: ,(next [1 2 3])

17:17 clojurebot: (2 3)

17:17 AtKaaZ: ,(next [])

17:17 clojurebot: nil

17:17 AtKaaZ: nice

17:18 ,(empty? nil)

17:18 clojurebot: true

17:18 AtKaaZ: amalloy, why not?

17:19 amalloy: did you read the part where i said why not?

17:19 AtKaaZ: because there is no reason?

17:19 ticking: AtKaaZ, if and most if like constructs test for nil non nil as well as true false

17:19 amalloy: yes

17:19 ticking: nil is falsy and non nil is thuthy

17:19 AtKaaZ: oh right, thank you for that

17:21 callen: amalloy: how long did it take you to solve all those 4clojure problems?

17:22 amalloy: *shrug*

17:22 callen: amalloy: don't want to sound smug, or don't want to recollect all that time you'd spent?

17:24 mattmoss: What's wrong with empty?

17:24 brehaut: ~empty?

17:24 clojurebot: empty is amalloy: therfor I return [previous] if rest

17:27 AtKaaZ: mattmoss, well I was trying to use empty? to map nil to false and non-empty to true, but if-like constructs already do this mapping (so to speak)

17:27 mattmoss: oh, I thought amalloy (or whoever it was) was saying something like "never use empty?"

17:28 but right, no need for empty in that situation

17:28 duck1123: don't use empty?. reverse the clauses and use seq

17:28 technomancy: ugh no

17:28 empty? is an actual english word

17:28 mattmoss: duck1123: empty? already uses seq. And I prefer positive checks where possible.

17:28 technomancy: so much more readable

17:28 tmciver: weavejester: from earlier: here's the request map when I try to get a js file through the browser: https://www.refheap.com/paste/5732

17:29 mattmoss: And what technomancy said.

17:30 weavejester: tmciver: You could try passing that map (minus the body inputstream) to your routes to see what happens

17:30 AtKaaZ: actually I correct myself, when I said non-empty I meant non-nil :)

17:31 duck1123: my point was, I'd rather see (if (seq x) :foo :bar) than (if (empty? x) :bar :foo) but that's mostly because I tend to find the non-empty case to be more interesting

17:32 ticking: duck1123, I'd argue to use it so that it complements documentation, if the empty case is the one you want to emphasize use that otherwise don't

17:32 AtKaaZ: yeah that would make it more readable for newbz like I

17:36 tmciver: weavejester: Ugh, I got it working. It seems to be a problem with a middleware I tried wrote that alters the 'accept' header depending on the extension of the resource in the URL. Doh!

17:37 weavejester: thanks for bearing with me.

17:54 weavejester: tmciver: No problem - glad you got it sorted out.

18:30 devth: suggestions on how to turn [{:g 1, :v "foo"} {:v "bar"} {:v "qux"} {:g 2, :v "baz"} {:v "quux"}] into {:1 ["bar" "qux"], :2 ["quux"]} ?

18:30 sorry, wrong structure, let me try that again

18:30 [{:g 1} {:v "bar"} {:v "qux"} {:g 2} {:v "quux"}] to {:1 ["bar" "qux"], :2 ["quux"]}

18:33 arrdem: ,(doc zipmap)

18:33 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

18:33 arrdem: so (zipmap (map :g datastructures) (map vals datastructures))

18:35 devth: thanks, trying that.

18:36 jamii: Now with real documentation - https://github.com/jamii/strucjure#examples

18:37 devth: arrdem: that's close but there are a different number of keys and values, so i get nil keys. i'll keep playing w/ it tho. thanks.

18:39 reduce might actually be what i need.

19:30 wingy: this test is passing since i mock the http/post with with-redefs https://gist.github.com/3876287

19:30 i wonder how/why to use with-redefs-fn .. there is no example in the doc for it

19:31 what is the difference

19:34 amalloy: devth: https://gist.github.com/0864360312f804c37cd9

19:35 devth: amalloy: wow, nice. thanks, i was still messing around with a really nasty reduce / update-in mess

19:35 emezeske: wingy: with-redefs-fn is a function instead of a macro, so it might be useful for things like e.g. generating test input data on the fly

19:36 wingy: That is, it might be useful when you don't know what the bindings will be at compile-time

19:36 arrdem: herm... anyone know how to access the com.mongodb.ObjectId constructor in Congomongo?

19:36 amalloy: into/for solves an awful lot of problems that would otherwise require a hairy reduce

19:36 wingy: emezeske: i c

19:36 so if i know i might as well use with-redefs?

19:37 emezeske: wingy: with-redefs is probably more convenient most of the time

19:37 wingy: Since you can just pass an arbitrary body to it, instead of a function to run

19:37 wingy: emezeske: i c

19:38 yeah since its a fn i have to wrap the expression inside a callback

19:38 also i cant use bindings in a fn right?

19:38 so i have to provide a map

19:40 emezeske: https://gist.github.com/3876287

19:41 pretty straightforward

19:41 i should probably add the example with with-redefs-fn to do?

19:41 doc

19:42 emezeske: I thought the docs for with-redefs-fn were pretty explanatory, but I guess an example never hurt anyone

19:43 wingy: no examples

19:45 http://clojuredocs.org/clojure_core/clojure.core/with-redefs-fn

19:45 since the doc says its used for mocking during testing i added a test oriented example

19:45 emezeske: Seems reasonable.

20:01 gert: is there a recommended way to run tests on clojurescript code?

20:01 dnolen: gert: not really.

20:03 emezeske: gert: Webapp?

20:04 gert: emezeske: I'm writing ring-like chaining on the client side and would like to write tests for my code

20:05 emezeske: gert: So, yes?

20:05 gert: I suppose so yes :)

20:05 emezeske: gert: :P

20:05 gert: I'm looking at Clojurescript One's one.test atm

20:05 emezeske: gert: For that, I write a bunch of cljs functions that just use assert, and run the tests in PhantomJS

20:06 gert: that's a good idea - and possibly more lightweight than one.test

20:06 emezeske: I've been meaning to look at this too: https://github.com/kumarshantanu/clip-test

20:07 Seems very promising.

20:07 gert: it does!

20:07 I'm going to check that out. cheers!

20:13 wingy: how do i check if an id exists in datomic

20:13 (q '[:find ?id :in $ ?id :where [?id _ _]] (db conn) id)

20:15 didn't work and threw no error

20:15 AtKaaZ: should've worked

20:15 but you also don't have to specify the _ _

20:15 wingy: perhaps ?id cannot be the same as the ?id passed in

20:16 AtKaaZ: this might be relevant: https://groups.google.com/forum/?fromgroups=#!topic/datomic/rJxgqnI4hz0

20:19 wingy: it worked now

20:19 i passed a string as an id :[

20:19 AtKaaZ: oh

20:19 wingy: should be converted to a long

20:19 AtKaaZ: yep, reminds me of yesterday:)

20:19 wingy: yeah

20:20 cant clojure implement static typing!

20:20 saves so much manual checking

20:20 AtKaaZ: it's curious however that the entity id exists even without any attributes... I've yet to test that out

20:21 "stated another way, having no attributes is as nonexistent as an entity can be." -Stu

20:21 wingy: i think the attrs exists

20:21 but you arent quering them

20:21 [?id]

20:21 the same as [?id _ _]

20:22 AtKaaZ: how can I delete erm retract an entity with a specific id?

20:23 ok I guess like so: @(d/transact conn [[:db.fn/retractEntity easton-id]])

20:24 yep the two are the same: [?id] or [?id _ _] same result

20:35 tomoj: should java.util.Set etc be added to pprint's dispatch?

20:36 ..bit bothersome that the HashSets datomic returns don't pprint. of course (comp pprint set) works

20:43 AtKaaZ: doesn't seem to work ?

20:44 works, my set was just empty

20:50 emezeske: tomoj: Could you maybe define a pprint multimethod for datomic sets?

20:50 tomoj: well they're just HashSets

20:51 but yeah

20:51 wondering why pprint shouldn't do that

20:56 ChongLi: hmmm

20:57 this new version of ac-nrepl or nrepl is adding a lot of latency to my keystrokes

20:57 I have no idea how to figure diagnose this

21:11 Sgeo: ,(-> 10 [1 2 3])

21:11 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

21:11 Sgeo: Well, that's an interesting way to fail

21:13 TimMc: &(macroexpand-1 '(-> 10 [1 2 3]))

21:13 lazybot: ⇒ ([1 2 3] 10)

21:13 AtKaaZ: what was it supposed to do?

21:13 emezeske: Sgeo: Interesting? Isn't that what you'd expect?

21:13 Sgeo: emezeske, I expected some kind of error

21:13 But wasn't sure what kind

21:14 emezeske: IndexOutOfBounds seems pretty reasonable and uninteresting to me :)

21:14 TimMc: ,(-> 1 [:a :b :c])

21:14 clojurebot: :b

21:14 AtKaaZ: how would you add that 10 to that vector, using the same construct

21:15 TimMc: You wouldn't.

21:15 AtKaaZ: ,(-> 10 (cons [1 2 3]))

21:15 Sgeo: emezeske, I was wondering if it would try to insert into the vector or something

21:15 clojurebot: (10 1 2 3)

21:15 Sgeo: ,(macroexpand-1 '(-> 10 (1 2 3)))

21:15 clojurebot: (1 10 2 3)

21:15 Iceland_jack: evil..

21:15 AtKaaZ: lol

21:15 TimMc: ,(macroexpand-1 '(-> 10 '(1 2 3)))

21:15 clojurebot: (quote 10 (1 2 3))

21:16 AtKaaZ: that was pretty epic with macroexpand

21:17 * Sgeo wasn't intending it to be like that, really

21:17 amalloy: &(-> 10 (1 2 3) quote)

21:17 TimMc: ,(-> 10 '(don't mind me))

21:17 clojurebot: 10

21:17 lazybot: ⇒ (1 10 2 3)

21:17 TimMc: ((juxt inc dec) amalloy)

21:17 amalloy: hah

21:18 AtKaaZ: lol

21:18 TimMc: I can't believe mine worked.

21:18 AtKaaZ: why not?

21:18 TimMc: ,(quote 1 2 3 4)

21:18 clojurebot: 1

21:18 amalloy: TimMc: you've made the comment macro obsolete

21:18 TimMc: :-D

21:19 amalloy: well, i guess not. since it quotes

21:19 AtKaaZ: ,(->> 10 '(don't mind me))

21:19 clojurebot: (don't mind me)

21:19 amalloy: &(-> (+ 1 2) '(comment whatever))

21:19 lazybot: ⇒ (+ 1 2)

21:20 TimMc: Good for obfuscated code.

21:20 * TimMc makes a note

21:20 AtKaaZ: ,(macroexpand '(-> (+ 1 2) '(comment whatever)))

21:20 clojurebot: (quote (+ 1 2) (comment whatever))

21:20 AtKaaZ: makes sense ##('(1 2) 3)

21:20 lazybot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

21:20 AtKaaZ: to not believe :)

21:21 ,(macroexpand '('(1 2) 3))

21:21 clojurebot: ((quote (1 2)) 3)

21:50 Sgeo: How long do the Incanter unit tests usually take?

21:50 I'm planning on making a minor change to Incanter

21:50 Not one that should be API visible though

21:52 I still don't like the thought of making a new project each time I want to use some library from the REPl

21:52 REPL

21:52 tomoj: you could add pomegranate to your user profile

21:53 Sgeo: Hmm

21:53 tomoj: the example in the readme is actually incanter..

21:53 jcromartie: what about an option for lein repl?

21:54 tomoj: I've thought it'd be nice to have repl-in

21:54 `lein repl-in incanter` ?

21:55 Sgeo: Having to merge with clojars seems annoying

21:55 Erm, manually specifying the repositories like that

21:55 tomoj: so write a helper

22:00 ohpauleez: $(doc find-fn)

22:00 ,(doc find-fn)

22:00 clojurebot: I don't understand.

22:01 ohpauleez: $find-fn

22:03 TimMc: $findfn 2 3 5

22:03 lazybot: [clojure.core/+ clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-add-int]

22:03 TimMc: slobot

22:03 ohpauleez: thank you TimMc

22:04 $findfn [1 2 3 4] ((1 2)(3 4))

22:04 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

22:04 ohpauleez: $findfn [1 2 3 4] '((1 2)(3 4))

22:04 lazybot: []

22:05 TimMc: partition 2?

22:05 ohpauleez: THANK YOU!

22:05 TimMc: haha, np

22:05 ohpauleez: I was drawing a blank, "step, group, grab"

22:05 it was killing me

22:12 AtKaaZ: $findfn {:a 1} {:a 2} {:a 3}

22:12 lazybot: []

22:18 TimMc: technomancy: I think I'm getting pretty close to having a working lein2 version of lein-otf -- the trouble now is to get lein-otf into the dependencies list of the target project!

22:18 "Who am I" is always a hard thing to solve.

22:20 Is there some way I can ask what version of a dependency is in use?

22:21 Sgeo: $findfn {:a 1} [:a]

22:22 lazybot: [clojure.core/keys]

22:22 Sgeo: Cool

22:22 AtKaaZ: $findfn {:a 1} [1]

22:23 that space:)

22:24 TimMc, from inside a lein plugin?

22:24 TimMc: Yep.

22:24 * Sgeo should write a do-> generalized on jimduey's protocol monads

22:25 TimMc: AtKaaZ: This plugin needs to add itself to the :dependencies listing of the project it is run in.

22:25 AtKaaZ: so this is not needed? Specify the plugin as a development dependency: :dev-dependencies [[org.timmc/lein-otf "1.1.0"]]

22:26 oh wait, I assumed it's already added in profiles.clj

22:26 actually, I don't know what I'm talking about lol

22:29 Sgeo: What's a higher priority, fixing a theoretical but unlikely race condition in Incanter, or doing something cool

22:29 AtKaaZ: the latter, but not in my view:)

22:30 amalloy: TimMc: i don't think so, aside from looking through the project.clj to find yourself in the plugins list. but i'm definitely not a lein dev, so take that with a grain of salt

22:33 AtKaaZ: TimMc, I failed to follow the Usage, getting: uberjar-otf is not a task. Use "lein help" to list all tasks.

22:34 or maybe the part with "Get the plugin" is implied?

22:37 wingy: hey

22:37 what is the best way to handle something unexpected in clj

22:38 i did (throw (Exception.)) but my compojure server is still running and nothing was logged in console

22:39 Sgeo: What's the difference between (ensure someref) and (deref someref) in a transaction?

22:39 amalloy: Sgeo: very subtle, whatever it is

22:40 TimMc: Looking through :plugins *works*, although I'm not sure that will always work.

22:40 AtKaaZ: ,(throw (Exception. "boo"))

22:40 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.Exception: boo>

22:40 AtKaaZ: ,(pst)

22:40 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>

22:40 AtKaaZ: ,(pst)

22:40 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>

22:40 TimMc: Sgeo: The question is really: What's the difference between (ensure foo) and (ref-set foo @foo)?

22:41 Sgeo: TimMc, what's the difference between (ref-set foo @foo) and @foo

22:41 TimMc: AtKaaZ: "Specify the plugin as a development dependency: ..."

22:41 AtKaaZ: TimMc, I definitely did that

22:42 in project.clj

22:42 TimMc: Are you using lein1 or lein2?

22:42 AtKaaZ: 2

22:42 TimMc: There's your problem.

22:42 AtKaaZ: ah, sorry, I kinda just realized

22:42 TimMc: lein-otf isn't ready for lein 2.x yet.

22:43 so the usage instructions haven't been updated for that.

22:43 AtKaaZ: can say it's for lein1 maybe

22:45 TimMc: Oh! I thought I did. Let me fix that...

22:48 Bad connection, I'll do it tomorrow. Go'night.

22:48 Sgeo: Um.

22:48 Does ensure just change the timing of things, or does it actually have a semantic effect on correctness?

22:49 amalloy: Sgeo: my understanding is that it affects correctness in certain unusual algorithms

22:49 but tbh i've never gotten a grasp on ensure

22:49 TimMc: write-skew

22:49 AtKaaZ: TimMc, bad RAM too "Go'night." :))

22:50 ,(doc ensure)

22:50 clojurebot: "([ref]); Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-transaction-value of ref. Allows for more concurrency than (ref-set ref @ref)"

22:50 AtKaaZ: ,(doc ref-set)

22:50 clojurebot: "([ref val]); Must be called in a transaction. Sets the value of ref. Returns val."

22:50 TimMc: AtKaaZ: too much lag for backspace to be useful

22:50 Sgeo: But my understanding is that with deref in a transaction, the transaction should not see an outside transaction change the ref

22:51 TimMc: ensure is only intended to be used when you are reading the ref somewhere else in teh xaction.

22:53 Sgeo: TimMc, but shouldn't reading the ref itself ensure that the transaction will restart if anything else tries to write it?

23:00 jcromartie: when I use a certain fn to paint a JPanel, I see output from prn, etc., but I don't see exception messages

23:00 in the SLIME REPL

23:00 how can I see those?

23:00 AtKaaZ: maybe (pst) ?

23:05 jcromartie: no, (pst) doesn't see the exception from the AWT thread

23:05 Sgeo: ,(doc pst)

23:05 clojurebot: "([] [e-or-depth] [e depth]); Prints a stack trace of the exception, to the depth requested. If none supplied, uses the root cause of the most recent repl exception (*e), and a depth of 12."

23:05 AtKaaZ: maybe you can call it on AWT?

23:05 Sgeo: Are those any more understandable than Java stack traces?

23:05 AtKaaZ: thread

23:08 jcromartie: trying from lein repl instead of SLIME

23:09 AtKaaZ: something with javax.swing.SwingUtilities/invokeLater but I don't know how to exactly pass that Runnable

23:10 jcromartie: yeah, in the plain lein repl it shows up

23:10 but not in SLIME

23:10 seems like a swank bug?

23:10 I've seen this in other things too

23:10 like running a ring jetty server

23:12 AtKaaZ: how did you call it? I'm failing :) ##(javax.swing.SwingUtilities/invokeLater ^Runnable ((pst)) )

23:12 lazybot: java.lang.RuntimeException: Unable to resolve symbol: pst in this context

23:12 AtKaaZ: ,(javax.swing.SwingUtilities/invokeLater ^Runnable ((pst)) )

23:12 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>

23:13 jcromartie: hm

23:14 AtKaaZ: jcromartie, I mean, how did you call (pst) on AWT thread?

23:14 jcromartie: I didn't

23:14 AtKaaZ: from repl?

23:14 jcromartie: I'm saying that I just see exception stack traces

23:14 from the repl

23:14 but not the SLIME repl

23:14 AtKaaZ: oh

23:14 jcromartie: just when I run it with "lein repl"

23:16 AtKaaZ: ,(javax.swing.SwingUtilities/invokeLater #(pst))

23:16 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.ExceptionInInitializerError>

23:17 jcromartie: doesn't seem to work, AtKaaZ

23:17 just tried it

23:17 AtKaaZ: not even sure I'm doing it right though

23:17 jcromartie: (defmacro g-do [& forms] `(SwingUtilities/invokeLater #(do ~@forms)))

23:17 seems to work except for printing exceptions

23:18 AtKaaZ: ,(javax.swing.SwingUtilities/invokeLater (fn [] (println *ns*)))

23:18 clojurebot: #<RuntimeException java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit>

23:18 jcromartie: yeah don't count on clojurebot doing Swing

23:18 AtKaaZ: lol

23:18 jcromartie: clojurebot doesn't Swing that way ;)

23:18 AtKaaZ: maybe can use binding to reditect stderr?

23:20 I'm curious how you'd do that, my noobish tried isn't doing anything: (g-do (binding [*err* *out*] (pst)) )

23:21 jcromartie: I don't think there's anyway to bind *err* to *out* across threads

23:21 is there?

23:21 that's the trick

23:22 maybe let

23:22 AtKaaZ: i don't know if across threads, I only tried on same thread

23:23 Sgeo: alter-var?

23:23 ,(doc alter-var)

23:23 clojurebot: Gabh mo leithscéal?

23:23 Sgeo: ,(doc alter-var-root)

23:23 clojurebot: "([v f & args]); Atomically alters the root binding of var v by applying f to its current value plus any args"

23:23 jcromartie: let over lambda :)

23:23 xeqi: (doc bound-fn)

23:23 clojurebot: "([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."

23:24 jcromartie: I don't think (pst) works on the current thread

23:26 (pst) uses *e, which is only for the REPL thread

23:26 so

23:27 I need to catch and print the stack trace myself

23:27 AtKaaZ: how do you do that?

23:28 jcromartie: (g-do (try (/ 1 0) (catch Exception e (pst e))))

23:28 just to illustrate

23:28 but yeah, just try/catch

23:28 AtKaaZ: cool thanks

23:28 jcromartie: not hard at all but not what I'm used to in Clojure :)

23:43 Sgeo: ,(-> #'reify meta :added)

23:43 clojurebot: "1.2"

23:43 Sgeo: :/

23:43 http://lispetc.posterous.com/hello-jwt-from-clojure

23:43 This code uses a macro to produce a proxy. Wouldn't reify work better without needing the macrology?

23:43 * Sgeo may be wrong

23:50 JvJ: a

23:50 hey does anyone in here use penumbra?

23:53 AtKaaZ: JvJ, I may want to use it eventually unless there's something better, but not currently using it.

23:54 JvJ: AtKaaZ, Just wondering. I'm having some diffuculty using penumbra with my lein projects, and wanted to know if anyone had similar problems.

23:55 AtKaaZ: JvJ: which fork are you using?

23:56 JvJ, just wondering if you saw the ML

23:56 JvJ: AtKaaz. What do you mean ML?

23:56 AtKaaZ: mailing list for clojure

23:56 JvJ: oh, I don't think I have

23:57 AtKaaZ: your dependency: [prismofeverything/penumbra "0.6.9"]]) maybe try just [penumbra "0.6.9"] or later version

23:57 hmm actually 0.6.0 I notice it's on https://github.com/ztellman/penumbra/blob/master/project.clj

23:57 JvJ: yeah, I've tried 0.6.0 and 0.6.9

23:59 gert_: emezeske: in a leiningen test profile I have a :cljsbuild > :compiler > :source-path "test-cljs" entry; this has a .cljs file with asserts in it, but how would it find my main "cljs" source path?

23:59 * gert_ is confused

Logging service provided by n01se.net