#clojure log - Mar 16 2014

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

0:22 joelt: newbie question: how do i take two equal length sequences and return a seq of items that match by index?

0:23 (a b b b) (a b c c) should return (a b)

0:36 mysamdog: In a project I'm working on, I have a form with a text input and a textarea. The form's action is /submit, and the method is post.

0:37 In my app-routes, I have this: (POST "/submit" [title content] (db/save-page title content)), and I know that the save-page function works

0:38 However, both the title and the content always appear as nil in the post request

0:38 What am I doing wrong?

0:40 Galmagneet: mysamdog, is it important that you pray 5 times per day to God, the wisest and most merficul.

0:41 * mysamdog prays to god 5 times

0:42 mysamdog: Also, the whole project is here: https://github.com/mysamdog/soar

0:43 The html file with the form in it is src/soar/templates/editor.html, and the handler is src/soar/handler.clj

0:45 tmciver: joelt: not sure if you've found a solution yet but: https://www.refheap.com/59378

0:47 joelt: i was using a generator but seemed odd.

0:47 thx

0:48 tmciver: np

0:49 jebberjeb: (map first (filter #(= (first %) (second %)) (map vector x y)))

0:49 bleh

0:51 dissipate: jebberjeb, what's that for?

0:52 xeqi: mysamdog: try adding wrap-keyword-params to the middleware stack

0:52 mysamdog: xeqi, thats in ring.middleware.params, right?

0:53 xeqi: or using compojure.handler/api or compojure.handler/site

0:53 mysamdog: I think its in ring.middleware.keyword-params

0:54 jebberjeb: was responding to joelt

0:54 (map first (filter (partial apply =) (map vector x y)))

0:54 dissipate: ,(doc vector)

0:54 clojurebot: "([] [a] [a b] [a b c] [a b c d] ...); Creates a new vector containing the args."

0:55 dissipate: weird, the doc for 'vector' on my android phone repl is different

0:56 joelt: jebberjeb: ah cool. that seems even cleaner.

0:56 dissipate: ,(doc partial)

0:56 clojurebot: "([f] [f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & ...]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."

0:57 dissipate: joelt, they seem the same to me

0:57 what am i missing here?

0:59 mysamdog: Hmmm, compojure/handler.site doesn't seem to work

1:01 joelt: dissipate: sorry, no offense... i think mine is imperative looking, jebber's is functional, and yours is slightly in between (only because of the if).

1:01 none are "better"

1:01 they all work... just interesting to see the differences though.

1:03 tmciver: joelt: jebberjeb's is more idiomatic than mine; my clojure is rusty. :/

1:03 dissipate: joelt, mine? i didn't have one, must have been someone else. but i hear ya. i've been looking at all the different ways to implement the fibonacci lazy sequence

1:05 xeqi: (for [[a b] (map vector x y) :when (= a b)] a)

1:06 jebberjeb: wow, that's dense but still very expressive

1:06 love it

1:06 joelt: xeqi:vector is a verb?

1:07 xeqi: joelt: vector is a function ##(vector 1 2)

1:07 lazybot: ⇒ [1 2]

1:07 dissipate: xeqi, i thought 'for' was 'imperative' heresy

1:09 xeqi: dissipate: nope, it is pretty close to a different syntax for `map` in simple cases

1:10 `doseq` would be closer to a for loop in impertive languages

1:11 joelt: i didn't realize the for [a b] part decomposed the second part... that threw me.

1:11 i like it though.

1:11 dissipate: ,(doc :when)

1:11 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Symbol>

1:11 xeqi: joelt: it looks better with a line break before the :when, so the destructuring lines up

1:11 dissipate: hmm, what's this ':when' keyword thing

1:12 xeqi: dissipate: its a special keyword understood by the `for` macro -- http://clojuredocs.org/clojure_core/clojure.core/for

1:13 not really special in any other sense, just when used in that spot for the `for` macro

1:13 dissipate: xeqi, ah, i see. interesting

1:14 joelt: could of said for [[a x] [b y]... no?

1:15 but that would of generated combinations i guess.

1:15 xeqi: joelt: [a x b y] will do the cross product of the vectors

1:15 dissipate: xeqi, why does this remind me of a list comprehension in python? :P

1:15 xeqi: dissipate: because it is a list comprehension?

1:15 defn: ,(remove #(= %) [1 "" nil])

1:15 clojurebot: ()

1:15 dissipate: xeqi, looks like a vector comprehension, no?

1:16 defn: ,(= "nil")

1:16 clojurebot: true

1:16 xeqi: `for` returns a list, though I don't really think in terms of list vs vector most of the time

1:16 defn: ,(= nil)

1:16 clojurebot: true

1:17 defn: ,(= false)

1:17 clojurebot: true

1:17 defn: Hmm

1:18 ,(= '())

1:18 clojurebot: true

1:18 dissipate: xeqi, so what is the enclosing vector notation used for, with 'for'?

1:19 defn: Destructuring

1:19 xeqi: dissipate: bindings for naming and destructuring, much like function declarations [] around params

1:20 defn: You can use :let as well in the binding form

1:21 dissipate: xeqi, makes sense now. thanks.

1:24 defn: ,(for [[k v] [[1 2]] :let [a (str k)]] a)

1:24 clojurebot: ("1")

1:25 defn: That took a long time on a phone.

1:25 Jesus.

1:25 Maybe 200 keystrokes.

1:26 Thanks iphone.

1:26 dissipate: wow, 'for' list comprehensions can get gnarly

1:27 nest collection bindings that can refer to previous bindings

1:27 er, nested

1:28 joelt: Is there a way for the loop to return nil when it doesn't match?

1:29 instead of filtering it returns something else?

1:29 l2x: ,(for [[k v] [[1 2] [x y]] :let [a (str k)]] a)

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

1:29 l2x: ,(for [[k v] [[1 2] ["x" "y"]] :let [a (str k)]] a)

1:29 clojurebot: ("1" "x")

1:30 trap_exit: , (doc take)

1:30 clojurebot: "([n coll]); Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n."

1:30 trap_exit: , (doc nth)

1:30 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

1:30 trap_exit: why does one take [n coll] and another take [coll n]

1:31 I thought I was an idiot for not memorizing this properly

1:31 but now I feel this is inconsistent

1:31 amalloy: ,(mapcat (fn [a b] (when (= a b) [a])) '(a b b b) '(a b c c))) is another plausible option, joelt

1:31 clojurebot: (a b)

1:33 amalloy: trap_exit: there's no good reason. nth takes its arguments in the "wrong" order for historical reasons (that's the order common lisp used)

1:33 mischov: "take x number items from this collection" "return from this collection the nth item"

1:33 trap_exit: amalloy: hmm, I actually like [coll n] more

1:34 it goes along better with assoc, dissoc

1:34 i.e. datastructuer first, then args later

1:34 amalloy: sure, it goes okay with collection functions, but not with sequence functions

1:34 eg, take, drop, filter, map

1:34 mischov: take makes more sense the other way because you're taking that number from the collection, so it reads kinda like a sentence of intent.

1:34 trap_exit: well, if we made filter/map also use collection first, then -> works better too

1:35 take from LST n elements

1:35 drop from LST n elements

1:35 filter LST for items that match ...

1:35 amalloy: trap_exit: (map coll1 coll2 f)?

1:35 arrdem: .... wat

1:35 trap_exit: amalloy (map (zip coll1 coll2) f) ... :-)

1:35 dissipate: trap_exit, one problem with drop is that if you drop from an infinite lazy sequence, you get an infinite result

1:36 amalloy: mischov: your phrasing argument makes no sense. "return the nth item from this collection" is just as reasonable a phrasing, or "take from this collection x items"

1:36 arrdem: dissipate: you get infinite _realized_ results :P

1:36 trap_exit: dissipate: I fail to see how laziness effects this

1:36 mischov: amalloy: It makes sense for take in particular.

1:36 dissipate: trap_exit, it doesn't. just saying it's generally not good. :P

1:37 mischov: amalloy: which is why I always assumed take was ordered as it is.

1:37 amalloy: mischov: of course it's the natural way to phrase take

1:37 but the very awkward wording of "take from this coll the nth item" doesn't support any position at all

1:38 arrdem: ,(doc zip_

1:38 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

1:38 arrdem: ,(doc zip)

1:38 clojurebot: Gabh mo leithscéal?

1:38 amalloy: ~zip

1:38 clojurebot: zip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))

1:38 trap_exit: alright, let's forget english

1:38 I thikn this complects things

1:38 I'd be happier if everything that operates on sequences had sequence as first argument

1:38 mischov: amalloy: no, not really.. :D

1:38 trap_exit: frees up limited memory to remember important things

1:39 arrdem: amalloy: well I knew that (map (partial apply vector) ..) was a thing, I was just checking :P

1:39 amalloy: trap_exit: nth is (almost?) the only thing that takes a sequence as its first arg. just remember that everything takes sequences last, and nth is the (rarely-used) exception

1:39 dissipate: amalloy, does it make sense to say 'take nth item' from this sequence when the items prior have to be calculated anyways?

1:41 amalloy, how about (first (drop n ...))

1:41 defn: Example?

1:41 What is "it"?

1:42 mischov: dissipate: (take (create-a-bunch-of-items-over-a few-lines-of-function) 5) or (take 5 (create-a-bunch-of-items-over-a-few-lines-of-function))

1:42 arrdem: eh.. we have as->... this is kinda a moot issue besides the inconvenience of not always being able to use ->

1:42 dissipate: mischov, the latter

1:44 mischov: dissipate: I always figured that way why seqs/collections are usually last in functions.

1:44 dissipate: way why*

1:44 dissipate: was why*

1:44 I can't type. Huzzah!

1:45 amalloy: now that you mention it.. yea, nth drives me nuts!

4:17 yuri_niyazov: Hey guys

4:17 What is the expected result from the following piece of code?

4:17 (let [a (transient {})] (dotimes [x 16] (assoc! a x :ok)) (persistent! a))

4:17 pyrtsa: yuri_niyazov: You should always use the *result* of the (assoc! ...) call.

4:18 Don't think it's in-place. It's destructive to its first argument but not necessarily in-place.

4:18 So instead of dotimes, use reduce.

4:18 yuri_niyazov: thx!

4:19 pyrtsa: The documentation should be more explicit of this.

4:19 (doc assoc!)

4:19 clojurebot: "([coll key val] [coll key val & kvs]); When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."

4:20 pyrtsa: ^ The documentation isn't correct, actually. It should say something like "Returns coll with the arguments associated." or something like that.

4:21 The postcondition (identical? coll %) does *not* hold for conj! or assoc!, in general.

4:22 (Where % is the return value.)

4:27 yuri_niyazov: I understand now, thank you very much

4:28 It's confusing because it's a different object being returned *sometimes*, not always

4:32 pyrtsa: Agreed. Especially since the documentation doesn't highlight this fact in any way.

4:36 dsrx: ,(let [a (transient {})] (dotimes [x 16] (assoc! a x :ok)) (persistent! a))

4:36 clojurebot: {0 :ok, 1 :ok, 2 :ok, 3 :ok, 4 :ok, ...}

4:39 pyrtsa: dsrx: The gist of it is, transient maps do (if I remember right) eight assocs in-place but then return a new instance.

4:40 dsrx: ahh, I see

4:40 pyrtsa: The doc comment doesn't point this out, which actually makes either the behavior or the doc incorrect.

4:41 Granted, transients have been marked as alpha in Clojure 1.5.x.

4:47 SegFaultAX: dsrx: You should use assoc! like assoc

5:00 amalloy: pyrtsa: well, the only behavior you should count on is that transient maps do any number of assocs in place, at any time

5:00 and return a new object any number of times

5:01 pyrtsa: amalloy: See the docs?

5:01 (doc assoc!)

5:01 clojurebot: "([coll key val] [coll key val & kvs]); When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."

5:01 pyrtsa: "Returns coll." is not right.

5:01 Likewise for conj!.

5:02 The docstring should be fixed for Clojure 1.6, nothing else.

5:02 amalloy: pyrtsa: i agree, the docstring definitely should not say "returns coll". perhaps there's still time to get that into 1.6 if you file a jira issue

5:02 pyrtsa: Filing one right now.

5:03 SegFaultAX: When does 1.6 go final? Is there a date yet?

5:03 amalloy: SegFaultAX: i always assumed clojure release dates were "whenever rich thinks it's done"

5:03 maybe with slight biasing to coincide with clojure/conj

5:04 pyrtsa: http://dev.clojure.org/jira/browse/CLJ-1385

5:05 SegFaultAX: Did you set the priority or is it auto-set?

5:06 amalloy: i think it defaults to major

5:06 pyrtsa: Ouch. I tried to set it to Major but it shows up as Minor now.

5:06 Can it be changed?

5:06 Nevermind.

5:07 It probably should be Minor, it's Major. (I had a different issue open, hence my confusion.)

5:07 Looks like I can't edit it anymore, can I+

5:07 ?

5:08 SegFaultAX: I don't usually consider copy changes to be major, but meh. Whomever triages the ticket will update its status appropriately.

5:08 pyrtsa: Yah, I guess it's alright.

7:33 cYmen: Good morning.

7:34 I can't start the nrepl con in my emacs and I only get 7 lines of error the most useful part of which is just a "Compilation failed: Subproces failed"

7:34 What should I do?

7:35 Ah the output is in the *Messages* buffer

7:53 liflash: hi, I asked a question about macros and thought it was solved, but it isn't. So here another try: why is the result of a function call within a macro evaluated again?

7:54 that is, the function returns a list of strings and I get the exception that string cannot be cast to fn

7:54 ,(defn foo [] '("hello" "world"))

7:54 clojurebot: #'sandbox/foo

7:54 liflash: ,(foo)

7:54 clojurebot: ("hello" "world")

7:55 liflash: ,(defmacro bar [] (foo))

7:55 clojurebot: #'sandbox/bar

7:55 liflash: ,(bar)

7:55 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:02 dsrx: ,(macroexpand (bar))

8:02 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:03 dsrx: ,(macroexpand-1 (bar))

8:03 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:03 dsrx: oops

8:03 liflash: hmmm

8:03 dsrx: ,(defmacro baz [] '(foo))

8:03 clojurebot: #'sandbox/baz

8:04 dsrx: ,(macroexpand (baz))

8:04 clojurebot: ("hello" "world")

8:04 liflash: yeah, this works, because the call to foo is delayed until runtime

8:05 does the macro has to return a function?

8:05 dsrx: a macro needs to expand to a form that can be evaluated

8:05 liflash: hmm

8:05 i see

8:06 dsrx: sorry, I screwde up my use of macroexpand

8:06 liflash: actually the list is within a map

8:06 dsrx: ,(macroexpand '(when 42))

8:06 clojurebot: (if 42 (do))

8:06 dsrx: ,(macroexpand '(bar))

8:06 clojurebot: (bar)

8:06 liflash: ,(defn foo [] {:foo '("hello" "world")})

8:06 clojurebot: #'sandbox/foo

8:06 dsrx: er..

8:06 liflash: ,(bar)

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

8:07 dsrx: ,(defmacro bar [] (foo))

8:07 clojurebot: #'sandbox/bar

8:07 dsrx: ,(macroexpand '(bar))

8:07 clojurebot: {:foo ("hello" "world")}

8:07 liflash: this works fine if for example:

8:08 ,(defn foo [] {:foo #{"hello" "world"}})

8:08 clojurebot: #'sandbox/foo

8:08 liflash: ,(bar)

8:08 clojurebot: {:foo #{"hello" "world"}}

8:08 liflash: it's only a problem if the result contains a real list

8:08 cYmen: man reloading the repl in emacs is a pita

8:08 dsrx: cYmen: M-x cider-reload ?

8:09 liflash: yeah, when the reader sees an unquoted list it's evaluated as a function call

8:09 ,("this" "errors")

8:09 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:10 cYmen: dsrx: that works? :o

8:10 dsrx: ,(quote {:foo ("hello" "world")})

8:10 clojurebot: {:foo ("hello" "world")}

8:10 dsrx: ,'{:foo ("hello" "world")}

8:10 clojurebot: {:foo ("hello" "world")}

8:10 dsrx: cYmen: yeah

8:11 liflash: hmmm

8:11 so how would i would have to use explicitly (quote.. ) in the function, if this function is used in a macro?

8:12 - how would

8:13 ,(defn foo [] {:foo (quote ("hello" "world"))})

8:13 clojurebot: #'sandbox/foo

8:13 liflash: ,(bar)

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

8:13 dsrx: liflash: {:foo (quote ("hello" "world"))} is equivalent to {:foo '("hello" "world")}

8:14 liflash: yes, i thought so

8:14 but this would mean in a macro i can't call functions that contain lists in their result

8:18 dsrx: ,(defn quux [] '{:foo '("hello" "world")})

8:18 clojurebot: #'sandbox/quux

8:18 dsrx: ,(defmacro baz [] (foo))

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

8:18 dsrx: err

8:19 ,(defmacro baz [] (quux))

8:19 clojurebot: #'sandbox/baz

8:19 dsrx: (baz)

8:19 ,(macroexpand '(baz))

8:19 clojurebot: {:foo (quote ("hello" "world"))}

8:19 dsrx: ,(baz)

8:19 clojurebot: {:foo ("hello" "world")}

8:21 liflash: so I have to quote the returned map in the function?

8:25 don't know how to do this, since:

8:25 ,(defn foo [] (let [s {:foo '("hello")}] s))

8:25 clojurebot: #'sandbox/foo

8:25 cYmen: dsrx: hm....technically it does but I still have to evaluate my code again and start the web server :)

8:25 liflash: and the map is generated by (map ...)

8:26 irctc: can somebody help me? I get java.lang.ClassNotFoundException when trying to clojure.core/read-string a string which includes a record. Strangely in the REPL this works fine and the class itself can be found there

8:32 liflash: dsrx: cYmen: to generate an even more realistic example:

8:33 ,(defn foo [] (reduce conj '() '("hello" "world")))

8:33 clojurebot: #'sandbox/foo

8:33 liflash: ,(foo)

8:33 clojurebot: ("world" "hello")

8:33 liflash: ,(bar)

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

8:35 liflash: dsrx: cYmen: how would I quote it, so the result isn't evaluated again?

8:36 irctc: do you have some more information? when do you get the exception? is clojure contained in your dependencies?

8:38 irctc: liflash: I have slurped a file and then I call read-string ... and I get an exception when running the application

8:38 liflash: when I try this in the repl there is no exception

8:38 liflash: so maybe this record class is not loaded in that namespace ? I am not sure

8:40 liflash: irctc: I'm new to clojure, too. so I can only guess by myself. what does the exception say?

8:41 cYmen: liflash: (defmacro bar [] '(foo))

8:41 but that doesn't do what you want I think

8:42 liflash: cYmen: this is our solution from yesterday ;)

8:42 cYmen: ,(defmacro bar [] '(foo))

8:42 clojurebot: #'sandbox/bar

8:42 cYmen: ,(macroexpand '(bar))

8:42 clojurebot: (foo)

8:42 cYmen: This just calls foo.

8:42 liflash: cYmen: the call to foo is delayed to runtime, but i need it at compile time

8:42 exactly

8:43 * cYmen experiments.

8:45 cYmen: ah got it

8:45 ,(defmacro bar [] `~(foo))

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

8:46 cYmen: ,(defn foo [] (reduce conj '() '("hello" "world")))

8:46 clojurebot: #'sandbox/foo

8:46 cYmen: ,(defmacro bar [] `~(foo))

8:46 clojurebot: #'sandbox/bar

8:46 cYmen: ,(macroexpand '(bar))

8:46 clojurebot: ("world" "hello")

8:47 cYmen: see, told you it was "just quote unquote" ;D

8:47 liflash: ,(bar)

8:47 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:47 cYmen: I know ;)

8:48 liflash: so we are at the beginning again...?

8:49 ah, no... wait a sec

8:49 cYmen: ,(defmacro bar [] `'~(foo))

8:49 clojurebot: #'sandbox/bar

8:49 cYmen: ,(bar)

8:49 clojurebot: ("world" "hello")

8:49 liflash: ,(macroexpand '(bar))

8:49 clojurebot: (quote ("world" "hello"))

8:50 liflash: hmmm... looks good

8:50 cYmen: ,(defmacro bar [] `(list ~(foo)))

8:50 clojurebot: #'sandbox/bar

8:50 cYmen: ,(bar)

8:50 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

8:50 cYmen: ,(defmacro bar [] `(quote (list ~(foo))))

8:50 clojurebot: #'sandbox/bar

8:50 cYmen: ,(bar)

8:50 clojurebot: (clojure.core/list ("world" "hello"))

8:50 cYmen: ,(defmacro bar [] `(quote ~(foo)))

8:50 clojurebot: #'sandbox/bar

8:50 cYmen: ,(bar)

8:50 clojurebot: ("world" "hello")

8:50 cYmen: oh whatever

8:51 liflash: thx for the experiments, I'll have a look in the repl

8:52 cYmen: http://i.imgur.com/4orTtew.jpg

8:52 liflash: :D

8:55 cYmen: basically, foo returns a list, too stop clojure from trying to call that as a function it needs to be quoted

8:55 s/too/to

8:55 but '(foo) will also quote the call to foo

8:56 liflash: exactly

8:56 cYmen: `'~(foo) quotes the quote but unquotes the call to foo

8:56 ``~(foo) seems to work, too

8:57 liflash: `'~(foo) quotes the result of foo

8:57 so the returned map/list is quoted in the result of the macro

8:57 cYmen: right

8:57 liflash: would that be a problem for the caller of the macro and therefore the 'user' of the map?

8:58 cYmen: uh depends an what that caller expects, I suppose

8:59 right now he gets a list back

9:00 liflash: in my situation foo returns a map, that contains the list which we are talking about. so now the map would be quoted by the macro

9:01 so would something like (:foo (bar)) work?

9:01 assuming the quoted map contains the key :foo

9:02 cYmen: you mean you want bar to be executed?

9:03 write down some examples of input and output for your macro ;)

9:04 liflash: ok, i just tried it and seems to work perfectly

9:04 thank you very much for your help

9:06 cYmen: oh, it's a learning experience for me, too so thank you :)

9:06 liflash: don't you think it's a pain to think about the returned data types when calling a function?

9:21 cYmen: what do you mean?

9:21 Am I not calling the function because I am interested in the returned data and hence its type? :)

9:21 liflash: only in the data ;)

9:22 all this wouldn't have happened if the returned type was not a list

9:22 cYmen: But data without a type is just a mess of bits. :)

9:24 tristanStrange: hey all... how can i cast a lazySeq to an ints suitable for passing to a Java method?

9:26 cYmen: tristanStrange: into-array?

9:26 Not quite sure what you mean by "ints"

9:27 tristanStrange: i'll take a look thanks. Erm... i mean an array of integer primitives

9:28 cYmen: in that case that should work :)

9:28 http://clojuredocs.org/clojure_core/clojure.core/into-array

9:40 steckerhalter: any suggestions for storing/querying data? what's the least painful way?

9:41 it could probably get quite a lot of data, a few GB maybe

9:42 cYmen: depends on what kind of data but basically I think this question is language agnostic

9:50 steckerhalter: cYmen: I'm asking for something that works well with Clojure. where you don't have to jump through all the hoops as often necessary

9:51 tristanStrange: I'm trying to call .setPixels on a WritableRaster... but get the following error:

9:51 IllegalArgumentException No matching method found: setPixels for class sun.awt.image.IntegerInterleavedRaster clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)

9:51 cYmen: steckerhalter: Well, yeah but what kind of data do you have? I mean using a database from clojure is pretty straightforward, for example...

9:51 tristanStrange: docs for java method here: http://docs.oracle.com/javase/7/docs/api/java/awt/image/WritableRaster.html#setPixels(int, int, int, int, int[])

9:51 and I'm feeding it four integers and an array of ints as arguments

9:52 can anyone guess why?

9:52 cYmen: tristanStrange: because one of the arguments doesn't match? is an array maybe an Array and not a []? Just guessing.

10:07 ghanim01: hi

10:11 mercwithamouth: hola

10:19 tristanStrange: ah thanks cYmen. I needed an int[] not an Integer Array... int-array did the job

10:30 cYmen: tristanStrange: so where are you at with your image processing experiments?

10:31 tristanStrange: hey cYmen... not too far at all yet.. still trying to get used to Clojure

10:32 I'm hoping to get a Sims style GA set up that modifies the expression trees that create images

10:32 and was expecting lisp to make that a lot easier....

10:33 this paper is my inspiration: http://www.karlsims.com/papers/siggraph91.html

10:34 I've got something going that generates the image files from functions now

10:34 cYmen: huh

10:34 looks cool

10:34 not that i understand what it is about ^^

10:35 ktos: Hi

10:35 tell me please, does clojure like lisp can use "system image"?

10:36 cYmen: hm... I have no clue

10:44 wagjo: ktos: no

10:44 ktos: see https://groups.google.com/forum/#!topic/clojure/UlkoDy_YyKU

10:59 ktos: wagjo: thank you

11:02 borkdude: Should this be considered an error in the spec of clojure? https://gist.github.com/borkdude/9584500

11:28 raven1: Howdy! I'm a noob on clojure so maybe this could sound silly, but there's a way where i can write a client for memcached that would have syncronous and async commands ?

11:29 I clarify, I am trying to write a simple memcached client with method for get and set key but I want to implement the syncronous and async methods for the same action (with thread pooling) how I should proceed ?

11:29 cYmen: borkdude: What's that *1 thing you're using?

11:30 borkdude: *1 is the last evaluated value in the repl

11:35 cYmen: I don't even understand your problem. :)

11:38 [raven]: cYmen: mine or borkdude one ?

11:38 cYmen: borkdude's

11:39 [raven]: cYmen: gotcha :) you've 2 cents for mine?

11:39 cYmen: no, I'm just starting myself

11:39 Far too advanced. :)

11:39 borkdude: Normally (read-string (pr-str x)) == x

11:39 this is not the case with keywords that are created from certain strings, like those with a whitespace in it

11:40 tristanStrange: ok, how does one make the functions in clojure.math.numeric-tower availiable to themselves?

11:40 cYmen: borkdude: so you're saying (keyword "foo bar") should be something like :foo-bar?

11:40 borkdude: cYmen I'm not saying that per se.

11:40 cYmen maybe it should not even be allowed to create such a keyword

11:41 tristanStrange: I'm getting file notfound exception when i include (:require clojure.math.numeric-tower) in my namespace

11:41 [raven]: cYmen: fair enough :)

11:42 tristanStrange: sketchy found out how to do it. ignore me :/

12:01 benmoss: is it specified behavior that ,(:foo {:foo "bar"} {:foo "baz"}) always returns "bar"?

12:02 don't know where the docs would be for keyword access

12:03 oh nevermind

12:09 cYmen: benmoss: If it only returns bar, I'm surprised it takes another argument.

12:10 oh the second argument is a default value

12:10 benmoss: yeah

12:10 cYmen: ,(:foo {:bla "bar"} {:foo "baz"})

12:10 clojurebot: {:foo "baz"}

12:10 cYmen: seems fine :)

12:10 benmoss: at first i thought it was variadic but only cared about the first map

12:10 but yeah realized that just after i asked :)

12:11 cYmen: apparently your IDE is lacking description of variables for function calls :)

12:22 gfredericks: is there a standard file-store impl of ring.middleware.session.store?

13:09 AmandaC: should this work? (for [y (range 32) (println “Foo”))

13:10 I mean, I’d think it’d work, but it doesn’t seem to in my code. o.o

13:11 katox: ,(for [y (range 3)] (println "Foo"))

13:11 clojurebot: (Foo\nFoo\nFoo\nnil nil nil)

13:12 gfredericks: AmandaC: what you pasted isn't even syntactically valid, so it's not clear if that's your problem or whatever else

13:13 AmandaC: Hold on, I’ll upload the code I’m actually using real quick.

13:13 gfredericks: refheap.com

13:13 AmandaC: http://amanda.darkdna.net/p/43277 <— I’ve got my own little pastebin. :p

13:14 gfredericks: fancy

13:14 ah ha

13:14 arrdem: notbad.jpg

13:14 gfredericks: so your for expression is probably fine

13:14 the problem is that for creates a lazy seq, and you're using it for side effects

13:14 you should probably just s/for/doseq/

13:15 arrdem: yep. doseq is the tool you want, not for.

13:15 AmandaC: ah

13:15 bufferloss: is clojurescript on topic in here?

13:15 arrdem: bufferloss: msotly

13:15 *mostly

13:15 Bronsa: actually you probably want simply dotimes

13:15 gfredericks: Bronsa: good catch

13:15 Bronsa: you can avoid the range then. (dotimes [i 32] ..)

13:15 bufferloss: ok cool I'm trying to run this tutorial http://clojurescriptone.com/getting-started.html but when I run `lein bootstrap` I get "'bootstrap' is not a task. See 'lein help'."

13:16 I cloned the repo, I cd'd into the directory, ran lein bootstrap, and that ^

13:16 any ideas what might be going wrong?

13:16 Bronsa: AmandaC: also (* i (* y 16)) can be written as (* i y 16)

13:17 bufferloss: I'm a coder of many years, noob to clojure - I've set up a basic non-web app that connects to postgres and runs queries and saves data back to postgres - I've also written a super basic compojure app with a couple basic endpoints, one to deliver HTML and another couple to deliver some postgres queries as EDN

13:17 was hoping to get started with clojurescript, but... yeah, this happened

13:17 Bronsa: and those 4 (.method g ..) can be rewritten as (doto g (.method ..) ..)

13:17 AmandaC: Bronsa: Math isn’t my strong point, so I was unsure if that was valid

13:17 arrdem: bufferloss: it looks like lein bootstrap is an odd little command for when lein is used to build itself...

13:18 bufferloss: you shouldn't need it or be using it.

13:18 bufferloss: arrdem: hmm, so maybe I only need to use lein repl

13:18 gfredericks: clojurebot: multiplication is commutative

13:18 clojurebot: Ack. Ack.

13:18 bufferloss: ok cool thx

13:18 AmandaC: Rather, if it would produce the wanted result

13:18 arrdem: bufferloss: probably

13:21 bufferloss: erg, ok well after running lein repl - it installs deps, and then boots the nREPL but after I try to run (dev-server) I get this https://gist.github.com/anonymous/9586650

13:21 TravisD: Hazzah for associative multiplication

13:21 arrdem: associativity is a lie... the NaNs wait for you...

13:22 bufferloss: so much for an easy to use tutorial :/

13:22 AmandaC: Hrm, now I need to figure out how to get the HeapByteBuffer that the pprint says for :pattern out of what is apparently a gloss.data.bytes.core.SingleBufferSequence

13:24 ahha, first

13:26 bufferloss: well I was going to try to use EDN, but honestly at this point I think I'm going to fall back to Backbone and use JSON

13:26 are there any common JSON output libs that'll take what is, effectively EDN and render it as JSON from ring?

13:26 TravisD: arrdem: Because you might overflow for some "bracketings" and not others?

13:27 arrdem: TravisD: Yep. All sorts of evil things can happen...

13:28 TravisD: yeah :( I hate evil things.

13:32 One of my friends was telling me about some cool algorithm for summing or multiplying or averaging a list of numbers that had nice numerical properties. Somehow it split the data up into a tree and managed to avoid loss of precision. I also think it was related to the fibonacci numbers, maybe

13:32 Does anyone know what I'm talking about?

13:36 The lie:

13:36 ,(let [big Double/MAX_VALUE] (= (* 0.5 2 big) (* (* 0.5 2) big) (* 0.5 (* 2 big))))

13:36 clojurebot: false

13:39 TravisD: Similarly, commutativity is a lie:

13:39 ,(let [big Double/MAX_VALUE] (= (* 0.5 2 big) (* big 2 0.5)))

13:39 clojurebot: false

13:39 TravisD: sadness :(

13:40 whodidthis: do the usual ring session middlewares allow using different cookie lifetimes

13:52 oh sweet, found :session-cookie-attrs from source

14:27 ro_st: technomancy: what's the quickest way to resolving "java.util.zip.ZipException: error in opening zip file" when doing lein deps? lein stacktrace is at leiningen.core.classpath$extract_native_deps

14:27 DEBUG=true lein deps doesn't give me any useful info, and i'd like to avoid redownloading my entire .m2

14:48 bufferloss: how does compojure/ring serve or decide from where to serve static files?

14:48 it seems the default is resources/public, is that a setting in ring? I don't see any reference to this in the compojure wiki

14:52 cYmen: bufferloss: lein compojure-app?

14:52 bufferloss: the compojure docs for route/resources are not clear to me

14:53 cYmen: uhh, not sure, I just added compojure to my project.clj and set up some basic routing

14:53 I see now that the example I followed uses (route/resources "/") which obviously looks in the resources folder, yet the docs make no mention of a resources folder

14:53 http://weavejester.github.io/compojure/compojure.route.html

14:55 cYmen: hm...

14:55 bufferloss: hmm, so it seems route/files serves from the actual project root, wheras route/resources serves from a folder called resources

14:55 of which, there is no mention in the docs that this is the case

14:55 cYmen: so the repl.clj that I get generated has (wrap-file "resources")

14:55 bufferloss: what is the difference exactly then?

14:57 cYmen: looking at the source I think it might be that files serves everything as a file

14:57 while resources might serve images as image content type or something

14:59 xeqi: bufferloss: files come from the file system, resources come from the classpath

14:59 in general lein puts "resources/*" on the classpath

14:59 bufferloss: xeqi: k, I'm not sure what the implications of that are to how I should develop or which I should choose

14:59 xeqi: bufferloss: I choose resources. Then you can ship jars

14:59 cYmen: I though a class path was just a list of folders where java looks for classes.

15:00 xeqi: that contain js/css and refer to them

15:00 bufferloss: xeqi: ah, ok that makes sense

15:00 cYmen: What IS a classpath? :)

15:00 bufferloss: cYmen: yeah I think that's pretty accurate for a definition of classpath, though there may be other implications for builds etc

15:00 xeqi: cYmen: pretty much, but then they found out they wanted to ship non-classes in jars, so resources also load from them

15:01 for css/js in web apps, or icons in desktop apps

15:01 as examples

15:02 cYmen: Ah, so they are somehow relative to a "project" and included in magic zips like jars?

15:03 And that's why you can access resources therein from a deployed jar?

15:07 xeqi: close enough

15:08 cYmen: okay :)

15:08 thanks

15:39 TravisD: Is there a function like (def enumerate (partial map-indexed vector)) in the clojure libraries?

15:41 amalloy: TravisD: there used to be, but it was removed. i think because it encourages inefficiency (building a big old lazy list just to map over it, instead of just using map-indexed to begin with)

15:42 TravisD: Ah, yeah, I guess often you would do (map f (enumerate coll)) or something

15:43 I wanted to filter a list, but remember the indices of the values I kept

15:44 gfredericks: does anybody have any ideas for making :repl-options :nit composable?

15:44 init*

15:45 or some other way to put default util stuff in the :user profile?

15:45 technomancy: gfredericks: :injections is more composable

15:45 hyPiRion: TravisD: I usually implement a function I call aside

15:46 ,(defn aside [& fs] (fn [& xs] (mapv #(%1 %2) fs xs)))

15:46 clojurebot: #'sandbox/aside

15:46 hyPiRion: ,(map-indexed (aside identity :val) [{:val 42} {:val 23}])

15:46 clojurebot: ([0 42] [1 23])

15:47 hyPiRion: not sure if the naming makes sense, though

15:48 TravisD: hyPiRion: Ah, cool. For some other things I was considering writing a function (fn-pair [f g] (fn [x y] [(f x) (g y)])), but your aside is much nicer

15:48 (defn fn-pair...)

15:56 One downside of using erc is that I often almost type things I wish to evaluate in the cider repl in the #clojure buffer instead :P

15:59 amalloy: TravisD: keep-indexed?

15:59 TravisD: amalloy: Could work, but I was bothered by filtering nils rather than having a predicate

16:00 I guess it might work nicely with when-let

16:00 amalloy: TravisD: but if you want to remember the indexes, you'll never have a boolean anyway. it'll be either an [index value] pair, or something you want to remove

16:01 TravisD: amalloy: Yeah, in the code I was writing I was being sloppy about making it clear what was being filtered

16:09 gfredericks: technomancy: oh hey this might work

16:09 thamks

16:09 (inc technomancy)

16:09 lazybot: ⇒ 100

16:10 * gfredericks confetti drops from the ceiling

16:10 hyPiRion: still < 0x100

16:11 gfredericks: lazybot: who has teh most karma

16:12 I don't imagine :injections gets eval'd in any particular namespace?

16:12 hyPiRion: oh, that's årobably a good PR for lazybot, some list of people with the most karma

16:13 *probably

16:15 gfredericks: oh using a vector for :init would be pretty composable actually,

16:15 amalloy: gfredericks: i think it's got to be technomancy

16:15 gfredericks: and not crazy obnoxious like the ((comp last list) ...) stuff I'm doing currently

16:16 TravisD: Can you decrement karma also?

16:17 gfredericks: (dec rubby)

16:17 lazybot: ⇒ -1

16:17 TravisD: :O

16:17 is there a count of the number of karmic operations done on a user?

16:18 (karma rubby)

16:18 amalloy: $karma rubby

16:18 lazybot: rubby has karma -1.

16:18 hyPiRion: (identity rubby)

16:18 lazybot: rubby has karma -1.

16:18 TravisD: heh

16:18 you are all just numbers!

16:18 gfredericks: $karma TravisD

16:18 lazybot: TravisD has karma 2.

16:19 TravisD: $karma gfredericks

16:19 lazybot: gfredericks has karma 42.

16:19 TravisD: (inc not-a-real-user)

16:19 lazybot: ⇒ 1

16:19 TravisD: Ah..

16:20 gfredericks: woooah 42

16:20 that's better than 100!

16:20 TravisD: heh, yeah!

16:20 (inc gfredericks)

16:20 lazybot: ⇒ 43

16:20 TravisD: D:

16:20 gfredericks: now I just gotta find a way to get decremented

16:20 hey guys why aren't you using haskell yet

16:20 TravisD: (dec gfredericks)

16:20 lazybot: ⇒ 42

16:21 gfredericks: that was quick

16:21 TravisD: Preemptive, even

16:33 amalloy: gfredericks: just checked in lazybot's db, technomancy is the karma winner, followed by me; TimMc, Raynes, and you round out the top 5

16:33 also someone on another irc network has a karma of 9002, probably as some kind of inside joke?

16:34 Raynes: $karma 44

16:34 lazybot: 44 has karma 0.

16:34 Raynes: $karma Raynes

16:34 lazybot: Raynes has karma 44.

16:38 isaacbw: $karma technomancy

16:38 lazybot: technomancy has karma 100.

16:43 gfredericks: I would not have expected to be #5

16:44 * gfredericks looks around for his internet money

16:52 * TravisD showers gfredericks in internet points

17:08 patrickod: I'm having issues at the moment with java.lang.NoClassDefFoundError errors when trying to run an ubjerjar compiled with 'lein ring uberjar'. I'm new to clojure and unsure of the cause of this. https://gist.github.com/patrickod/e70edeba39652f663029

17:08 Googling seems to suggest that adding (:gen-class) into the namespace definition for the handler.clj would fix this but that hasn't helped.

17:11 seangrove: bbloom: ping

17:11 bbloom: You around to check the clarity and sanity of a proposal?

17:16 patrickod: No warnings when creating the uberjar?

17:16 patrickod: one second I'll paste the output of that

17:17 seangrove updated the gist with the output of lein ring uberjar

17:19 seangrove: patrickod: AOT can be a bit of pain when you're first getting started with it, don't let it get you down too much.

17:19 patrickod: haha no worries. :) part of the learning curve

17:19 seangrove: patrickod: Have you looked at https://devcenter.heroku.com/articles/getting-started-with-clojure ?

17:19 patrickod: I just happened across that googling. reading now

17:20 seangrove: Oh, sorry, maybe not that one..

17:20 There we go https://devcenter.heroku.com/articles/clojure-support

17:20 :profiles {:uberjar {:main myproject.web, :aot :all}}

17:21 Excess flood from bbloom...

17:21 * seangrove wonders what he was doing

17:22 * patrickod needs to read up on aot

17:23 seangrove: patrickod: Yeah, it's great once you get it, but it can be frustrating in the meantime

17:26 patrickod: seangrove it worked :)

17:26 thanks!

17:26 seangrove: Glad to hear it

17:37 AeroNotix: where can I find a list of all clojure namespaces? All things I usually wouldn't stumble across?

17:38 brehaut: AeroNotix: http://clojure.github.io/clojure/

17:39 AeroNotix: hmm, ok. Was just looking here

18:07 TimMc: $karma TimMc

18:07 lazybot: TimMc has karma 55.

18:07 TimMc: huh

18:10 shep-home: I'm playing with trying to improve the performance of some code, and I want to tweak a lazy sequence

18:10 I think that the overhead of the lazy is too large compared to my algorithm

18:10 is there a way of making a kinda-lazy-seq?

18:10 AeroNotix: shep-home: what does this kinda-lazy-seq do?

18:11 shep-home: That is, do my recursive call 100 times eagerly, then return a lazy fn for the rest

18:11 AeroNotix: shep-home: take?

18:11 shep-home: show some code

18:11 hyPiRion: AeroNotix: is lazy

18:12 AeroNotix: doh

18:12 shep-home: AeroNotix: one sec, lemmo post

18:13 https://gist.github.com/shepmaster/9590585

18:13 That is from my editor window, so it doesn't actually work ;-)

18:15 (I've updated with the last working version)

18:16 I originally had lazy-cat, but that creates 3 anon functions, so I switched to this version, which only makes one

18:17 i havent fully benched the difference, but I think theres a tiny (<10%) speedup

18:17 could be all in my head

18:17 AeroNotix: I'm gonna bail on this-- I'm not familiar with how to optimize lazy seqs

18:17 It's quite nuanced

18:18 shep-home: A pain with profiling this in visual VM is that the call stack just goes on and on and on

18:18 deeper and deeper

18:18 AeroNotix: Me either ;-)

18:18 I also tried a core.async version

18:18 and that had reasonable speedup to 4 threads

18:19 but then flatlined (I think due to lock contention)

18:19 AeroNotix: well

18:19 one immediate thing for me is the two recursive calls are done one after the other

18:20 I'd find a way to do those concurrently

18:21 shep-home: Here's the pretty graph of the core.async version: http://i.imgur.com/HYZNqeX.png

18:21 AeroNotix: do you mean for the lazy seq version? Or for the core.async version?

18:22 AeroNotix: just in-general

18:22 bbloom: seangrove: i'm back now

18:22 what's up?

18:22 shep-home: I'm not sure that lazy-seq and concurrency play together... do they?

18:22 err, generation of lazy-seqs

18:22 AeroNotix: pass

18:23 hyPiRion: not if they are recursive

18:26 shep-home: hyPiRion: That's what I was afraid of. And I'm not sure how to disentangle this particular recursion

18:48 felher_: Hey folks. Is (or value default_if_value_nil) idiomatic in clojure when one is sure value is either nil or non-falsy, or is (if (nil? value) default_if_value_nil value)) or something different preferred?

18:49 brehaut: or is fine for defaulting values

18:49 amalloy: (or a b) is pretty cool

18:49 felher_: kay, thanks folks.

18:49 :)

18:49 brehaut: (-> some complicated thing (or b)) also works great

18:49 amalloy: there's also fnil if you get the value from a function call

18:50 brehaut: (for things that return and consume nils happily)

18:51 felher_: nice, good to know. Ty :)

19:13 AeroNotix: so

19:13 in core.map

19:13 for instance, it has a lambda. I'm looking at program now which has 37k instances of that lambda.

19:14 Wouldn't it be better if that was just a separate function?

19:14 I know it's a trivial thing to do

19:14 but

19:14 thoughts?

19:18 shep-home: AeroNotix: I wonder what the benefit would be. Any way to tell?

19:18 AeroNotix: memory

19:19 shep-home: You are referring to `step`, right?

19:19 cause there's also the anonymous one below that

19:20 AeroNotix: Same difference

19:21 shep-home: those'll both compile to separate classes

19:21 and each time you call, you make an instance of that class. IIRC?

19:21 I mean --- I'm not advocating people never use lambdas. That's crazy.

19:21 but, it'd be interesting to see what'd happen if the entire standard library implementation did not use them.

19:23 shep-home: Looks like step could be pulled out, but the anon one captures locals...

19:24 AeroNotix: sure

19:25 amalloy: AeroNotix: map's lambda takes up space because that space needs to be taken up in order to implement map. try implementing map without it

19:25 make sure it's as lazy as the existing implementation

19:25 AeroNotix: amalloy: I'm just talking generally

19:26 amalloy: in general, if the entirety of clojure.core didn't use lambdas, it would be totally awful. fire would rain from the sky

19:27 it doesn't even make sense. you can lift any lambda that doesn't close over anything into a defined function, but there are very few of those, and not much point in doing so anyway

19:30 shep-home: AeroNotix: can you tell with lambda is taking memory?

19:30 which*

19:31 amalloy: cause `step` in `map` doesn't close over anything. Is it possible that it could contribute to memory usage for each unfinished map?

19:32 amalloy: *shrug* a lambda that doesn't close over anything takes up as much space as (Object.)

19:32 ie, a pointer

19:32 AeroNotix: if you want to avoid creating lazy sequences (which is roughly the same as lambdas in this context), you can use clojure.core.reducers

19:35 shep-home: amalloy: so, a little bit, as opposed to the static / constant a top-level defn would have? Or is there more hidden?

19:38 And this amount of space is probably neglible compared to the memory used by the lazy-seq's data.

19:39 But it is a single place that could be changed to reduce memory consumption across all users

19:42 Similar with concat$cat, it seems

19:42 amalloy: if you assume instant gc, there would be one instance of map$step and one instance of map$step$fn per call to map. that is like zero space. it's just some gc churn

19:42 and you can't avoid the map$step$fn, because it's closing over cs

19:43 (map$step$fn is the lambda introduced by the lazy-seq macro, in case that's not obvious)

19:50 shep-home: Well, for my current problem, replacing concat with a version with concat$cat at the top level doesn't make any noticeable time difference

19:51 and I don't know how to quantify memory/GC activity over the entire run, so I cant say anythign there

20:29 seangrove: dnolen_: What did you use for the literate programming post? I'm looking at being more concrete with the examples than I was in the video, I think it'd be great to have it inline in a post

20:29 dnolen_: seangrove: it was just manual

20:29 seangrove: Ok, thought there might have been something else

20:50 stcredzero: I may be going crazy here, but it seems like the keys in a map in a defrecord object are all turning into false.

20:58 gfredericks: thewat

21:02 hyPiRion: ,(alter-var-root #'false? (constantly true))

21:02 clojurebot: true

21:02 hyPiRion: yay

21:03 xeqi: ,(false? false)

21:03 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>

21:03 hyPiRion: oh, that was probably wrong

21:03 ,(.bindRoot #'false? (constantly true))

21:03 clojurebot: nil

21:04 hyPiRion: ,(map false? (keys (apply hash-map (range 10))))

21:04 clojurebot: (true true true true true)

21:04 xeqi: ,(false? false)

21:04 clojurebot: true

21:05 xeqi: oh what fun things that can do to the bots

21:05 Raynes: https://github.com/Raynes/clhue In case you've ever wanted to program your light bulbs.

21:09 gfredericks: hyPiRion: ha you wanted (constantly (constantly true))

21:09 hyPiRion: gfredericks: yeah, I realised in hindsight

21:09 gfredericks: ,(->> true constantly constantly (alter-var-root #'false?))

21:09 clojurebot: #<core$constantly$fn__4057 clojure.core$constantly$fn__4057@6b7d38>

21:09 gfredericks: ,(false? false)

21:09 clojurebot: true

21:09 gfredericks: ,(false? ["FALSE!"])

21:09 clojurebot: true

21:10 akurilin: Hey so the peeps in here who make restful Ring apps, do you guys actually bother with any kind of MVC or do you have some sort of custom approach to decoupling your ssystem?

21:12 stcredzero: Yes, it does appear that (keys my-map) is returning '(false false false false false)

21:15 Is there any way someone can see asking (filter fn (keys a-map)) and getting '(false false false false)?

21:16 gfredericks: ,{(Boolean. false) 12 (Boolean. false) 13}

21:16 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: (Boolean. false)>

21:17 gfredericks: ,(hash-map (Boolean. false) 12 (Boolean. false) 13)

21:17 clojurebot: {false 13}

21:17 stcredzero: Yes, but then asking keys, I'd only get '(false)

21:18 gfredericks: yeah, just experimenting

21:19 sounds pretty spooky

21:19 stcredzero: This is just the most bizzaro error ever. Should I be upgrading to Clojure 1.6?

21:21 I think it might be due to the fact that I have lots of (map) and (pmap) calls in a game loop, and though I use doall, I don't ask for a vector, so these things remain lazy sequences, even though their items have been realized.

21:22 Or am I misunderstanding lazy sequences and what (doall) does?

21:23 beamso: doall doesn't return any values

21:23 stcredzero: none at all?

21:23 kras: Hello, everyone

21:23 beamso: i think it just makes everything in the lazy sequence evaluate

21:24 stcredzero: ,(doall (map identity '(1 2 3 4)))

21:24 clojurebot: (1 2 3 4)

21:24 kras: Looking for suggestions on 'lex/yacc' type libraries in clojure

21:24 stcredzero: Looks like it returns a value to me

21:25 beamso: ,(doall (map inc '(1 2 3 4)))

21:25 clojurebot: (2 3 4 5)

21:26 beamso: oops. my bad. i think i was getting dorun and doall confused.

21:26 stcredzero: Is there something that has the effect of (fn [coll] (vec (doall coll))) ?

21:26 akhudek: kras: instaparse

21:27 stcredzero: Or is (fn [coll] (vec (doall coll))) redundant to (vec)?

21:27 amalloy: stcredzero: that lambda is a lengthy way of writing vec

21:27 stcredzero: amalloy: danke

21:28 amalloy: i don't think you can ever get (keys x) to return (false false false) if x is one of clojure's built-in map types

21:29 kras: akhudek: thank you, will have a look. Any idea how the performance is? My language is simple but I need to parse huge files

21:29 akhudek: kras: no idea, we've only used it for fairly short inputs

21:31 kras: but the author does care about performance https://github.com/Engelberg/instaparse/blob/master/docs/Performance.md

21:32 stcredzero: amalloy: here's the snippet of code that makes me think that's happening: http://pastebin.com/WE3mkACS (old-grid should be a map)

21:32 amalloy: kras: aphyr recently tried giving equivalent grammars to instaparse and antlr, and his experiments suggest antlr is a lot faster. i can't vouch for his methodology, but he said the results were about 70x faster for antlr

21:33 stcredzero: So, is there any risk in going to Clojure 1.6, or should I just jump in?

21:33 kras: amalloy: antlr I guess generated Java code if I am right? it's not a pure clojure library?

21:34 amalloy: kras: he recently wrote some clojure bindings for it: https://github.com/aphyr/clj-antlr

21:34 stcredzero: ANTLR is definitely Java

21:34 amalloy: stcredzero: one possibility is that you have keys in your map that aren't false, but print the same as it

21:35 for example, i strongly recommend against using str to print data structures, since ##(str ["false" false (symbol "false")])

21:35 lazybot: ⇒ "[\"false\" false false]"

21:37 stcredzero: amalloy: what's odd is that I *never* do anything to the keys once the old-grid map is created. I never remove entries. What should I do to print keys?

21:37 amalloy: pr-str

21:38 stcredzero: i'd suggest printing the actual map, too, if you're getting behavior from it that makes no sense

21:39 stcredzero: amalloy: a sensible suggestion

21:40 kras: thanks amalloy: and akhudek: give give both antlr and instaparse a shot ...

21:41 will*

21:43 amalloy: stcredzero: none of those doalls in there make sense, by the way. and f should just be (fn [k] (not= k (f1 k))). and (> (count x) 0) should be (seq x)

21:44 SegFaultAX: I would be pretty shocked if instaparse could come close to antlr.

21:45 mr-foobar: In clojurescript + core.async ... can I use any number of (go ...)'s and channels ? Are there any performance implications ?

21:45 amalloy: SegFaultAX: incidentally, i profiled instaparse, and it was spending most of its time inside of a swap! modifying an arraymap

21:45 SegFaultAX: amalloy: How big was the arraymap?

21:45 amalloy: so persistent data structures aren't free *all* the time, as i usually claim

21:46 oh, i dunno. probably small. i just had timing information and stacktraces

21:46 SegFaultAX: Free lunch and silver bullets, etc.

21:46 amalloy: mr-foobar: http://swannodette.github.io/2013/08/02/100000-processes/

21:50 TravisD: Yowzah, that gets my processor all hot and bothered

21:50 looks cool though

21:51 Although, it's misleading how the URL makes it look like there are 100,000 processes,

21:51 Oh, I should have read the update :)

21:52 mr-foobar: amalloy: There is only one channel, returned by render-loop. Are channels also cheap ?

21:54 amalloy: i believe channels are cheap too

21:54 SegFaultAX: mr-foobar: Fairly cheap, yes.

21:55 isaacbw: anyone know what the ruby component of turbolinks does? Is it required to use turbolinks or is it just there to integrate with rails. i.e could turbolinks be used in a clojure-driven app without writing a server component

21:56 SegFaultAX: isaacbw: Sure it could, but you'd have to implement it yourself.

21:56 mr-foobar: amalloy SegFaultAX Awesome! I really feel there is a design-pattern that uses channels but I can't put a name to it. It seems something like games would use.

21:56 isaacbw: SegFaultAX: what do you mean

21:57 SegFaultAX: isaacbw: Turbolinks is basically a big fat hack that swaps out bits and pieces of the page for you so assets don't have to be reloaded.

22:04 dsrx: oh god turbolinks

22:13 beamso: a defprotocol definition, with a :gen-class directive in the namespace, generates an interface/abstract class?

22:14 with any deftypes implementing that defprotocol as classes implementing/extending the protocol?

22:15 stcredzero: amalloy: The thing that I ask (keys) of prints out as a Clojure map!

22:27 joshbamboo1: isaacbw: have a look at pjax http://pjax.heroku.com/ Turbolinks is based on this.

22:36 gfredericks: stcredzero: what is its type?

22:36 isaacbw: joshbamboo1: is the time supposed to be changing when I click on the links?

22:36 gfredericks: ,(keys (repeat 5 (first {false 42})))

22:37 clojurebot: (false false false false false)

22:37 joshbamboo1: if pjax is not enabled, then the time should update, indicating that the whole page has been returned from the server. Click the check box (it's on the waiter's serving plate - hard to spot), and the time won't change when clicking the links.

22:38 isaacbw: ah, I see!

22:38 awesome, thanks for the link

22:38 joshbamboo1: pjax essentially returns an HTML fragment and swaps out a portion of the page, rather than returning the whole page. There's nothing magical, but it's a nice visual and speed improvment.

22:39 The server needs a way of knowing whether to render a full document or just a framgment obviously. I believe pjax uses a custom header for this.

22:40 isaacbw: so is turbolinks just rails trying to be even more monolithic instead of leveraging what already exists?

22:42 joshbamboo1: The other thing you need to watch out for, is if the fragment has script such as jQuery document ready event handlers. With pjax, the document ready never fires since it's only a fragment returned, not the whole document. Not sure how pjax handles this. Turbolinks provides a similar handler which I think gets called when the ajax call returns as a way to handle this.

22:44 Only skimmed, this might help: http://geekmonkey.org/articles/28-introducing-turbolinks-for-rails-4-0

22:47 Sounds like the idea is similar to pjax, but applied in a slight different document scope. See also https://plus.google.com/+YehudaKatz/posts/A65agXRynUn?utm_source=rubyweekly&utm_medium=email for some other caveats, esp long lived JS

22:49 I guess the Turbolinks whole document approach is more what 37 Signals needed, rather than the extra overhead of pjax with marking certain sections. These kinds of features find their way in to Rails due to a really need by 37 Signals, not because the rest of the world necessarily needs them..

22:49 ^really need == real world need

22:54 dsrx: https://twitter.com/markbates/status/443490828540198912 @markbates Rails 5 will be renamed to Basecamp. This will help to end confusion over which types of apps to build using Rails.

23:04 stcredzero: gfredericks: the type of the old-map is clojure.lang.PersistentHashMap

23:07 gfredericks: but now the mismatched (keys) collection is [[0 -3]]

23:30 Fraz2: does anyone know if it's possible to use the lein kibit with custom rules defined in my project

23:31 this is possible using vanilla kibit, but the lein plugin does not support a rules argument

23:31 trying to hack it in I find that I can't even 'require' filesfrom my own project since my files are not on the classpath when lein kibit is running

23:37 seangrove: dnolen_ bbloom Hopefully getting more coherent https://dl.dropboxusercontent.com/u/412963/zenrise/zenrise.html As usual, feedback appreciated

23:40 stcredzero: So no one wants to chime in on the desirability of going to Clojure 1.6?

23:41 seangrove: stcredzero: Shouldn't be too damaging, but there's no hurry

23:42 bbloom: seangrove: hmm... seems like there has to be something an order of magnitude simpler

23:44 seangrove: bbloom: The effects aren't really apparent until you've built a medium-sized app. Almost certainly could simplify the examples though, you're right

23:44 bbloom: is the goal of a "transformer" just to itself be data, so that it's toolable?

23:45 i guess my question is why not just parameterize the nav-bar with a function which converts the provided data in to the items

23:45 probably worth looking at http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol(v=vs.110).aspx too

23:46 and for bi-directional purposes: http://wpftutorial.net/ValueConverters.html

23:47 l1x: hi, is this the right way of decomposing list or there is better way of doing that? https://gist.github.com/l1x/9593619

23:47 bbloom: seangrove: just generally "data templating" is a toolable template language that is basically just functions of data -> views & has a lot of the details sorted out. the 2-way data-binding bits are complex, but see http://msdn.microsoft.com/en-us/library/ms742521(v=vs.110).aspx anyway

23:48 i'm not sure why i need a transform-registry and a bunch of other machinery like that

23:49 SegFaultAX: ,(doc some)

23:49 clojurebot: "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

23:49 SegFaultAX: l1x: ^

23:49 bbloom: seangrove: what i really want is to be able to supply an IFn and, for tooling reasons, have that IFn also be a data record that i can inspect or manipulate for simple use cases

23:49 seangrove: bbloom: That's essentially what this is - the 'registry' is so that it can all be serialized out to edn, to keep it tooling-friendly

23:49 l1x: SegFaultAX: thanks!!

23:50 bbloom: seangrove: ah i see... lots of concepts at once

23:50 seangrove: is it possible to defer the serialization requirements?

23:51 seangrove: or at least delay introducing them until usage of the fundamentals are clear

23:51 seangrove: also, since your transform registry already just has functions it in, you can't serialize that... so why not use namespaces/vars for this?

23:51 seangrove: bbloom: I needed it while building the tooling, I'd have to think of a way to pull that out

23:51 bbloom: we've already got a definition-registry, called namespaces :-)

23:52 seangrove: bbloom: That would work as well, but having a centralized hashmap means it can be exposed in the tooling as a drop down and introspected

23:52 "This component is connected to these paths, use this function here, and validate that the function gets the keys it needs and outputs the keys the component needs"

23:53 Being able to look up the functions and get the meta-data from them (in a bit of a hobbled edn format) has been pretty useful for that

23:54 bbloom: this is the situtation in which it kinda sucks we don't have an eval or compile function in cljs

23:54 seangrove: bbloom: Hah, I was considering funding cljs-in-cljs for that very reason while building this out ;)

23:55 bbloom: this is kinda a tangent, but frankly it may be less work to port compiler stuff to run in the browser than it would be to play the server/client coordination game

23:56 stcredzero: Is pervasive laziness going to be dangerous for my game loop? Seems like I keep piling up proxies inside lazy sequences, then run into weird bugs.

23:57 bbloom: stcredzero: i'm not sure how laziness or proxies relates at all to a game loop....

23:58 seangrove: anyway, this spec makes *some* sense to me

23:58 SegFaultAX: Well I can see how laziness might relate, but proxies?

23:58 seangrove: bbloom: There's no server-side right now, but I'm happy enough with the way the system, tooling, etc. is coming out that I wouldn't be excited to back up to the point of porting the compiler ;)

23:58 bbloom: I'll continue hashing it out these are all good questions

23:59 And if the tooling is actually usable, then it's all interesting, and if not, then it's not really worthwhile anyway.

23:59 bbloom: seangrove: yeah, you're making progress, so just keep on hacking

23:59 you can figure out the theory of it all later :-P

Logging service provided by n01se.net