#clojure logs

2014-03-16

00:22joeltnewbie question: how do i take two equal length sequences and return a seq of items that match by index?
00:23joelt(a b b b) (a b c c) should return (a b)
00:36mysamdogIn 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.
00:37mysamdogIn my app-routes, I have this: (POST "/submit" [title content] (db/save-page title content)), and I know that the save-page function works
00:38mysamdogHowever, both the title and the content always appear as nil in the post request
00:38mysamdogWhat am I doing wrong?
00:40Galmagneetmysamdog, is it important that you pray 5 times per day to God, the wisest and most merficul.
00:42mysamdogAlso, the whole project is here: https://github.com/mysamdog/soar
00:43mysamdogThe html file with the form in it is src/soar/templates/editor.html, and the handler is src/soar/handler.clj
00:45tmciverjoelt: not sure if you've found a solution yet but: https://www.refheap.com/59378
00:47joelti was using a generator but seemed odd.
00:47joeltthx
00:48tmcivernp
00:49jebberjeb(map first (filter #(= (first %) (second %)) (map vector x y)))
00:49jebberjebbleh
00:51dissipatejebberjeb, what's that for?
00:52xeqimysamdog: try adding wrap-keyword-params to the middleware stack
00:52mysamdogxeqi, thats in ring.middleware.params, right?
00:53xeqior using compojure.handler/api or compojure.handler/site
00:53xeqimysamdog: I think its in ring.middleware.keyword-params
00:54jebberjebwas responding to joelt
00:54jebberjeb(map first (filter (partial apply =) (map vector x y)))
00:54dissipate,(doc vector)
00:54clojurebot"([] [a] [a b] [a b c] [a b c d] ...); Creates a new vector containing the args."
00:55dissipateweird, the doc for 'vector' on my android phone repl is different
00:56joeltjebberjeb: ah cool. that seems even cleaner.
00:56dissipate,(doc partial)
00:56clojurebot"([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."
00:57dissipatejoelt, they seem the same to me
00:57dissipatewhat am i missing here?
00:59mysamdogHmmm, compojure/handler.site doesn't seem to work
01:01joeltdissipate: sorry, no offense... i think mine is imperative looking, jebber's is functional, and yours is slightly in between (only because of the if).
01:01joeltnone are "better"
01:01joeltthey all work... just interesting to see the differences though.
01:03tmciverjoelt: jebberjeb's is more idiomatic than mine; my clojure is rusty. :/
01:03dissipatejoelt, 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
01:05xeqi(for [[a b] (map vector x y) :when (= a b)] a)
01:06jebberjebwow, that's dense but still very expressive
01:06jebberjeblove it
01:06joeltxeqi:vector is a verb?
01:07xeqijoelt: vector is a function ##(vector 1 2)
01:07lazybot⇒ [1 2]
01:07dissipatexeqi, i thought 'for' was 'imperative' heresy
01:09xeqidissipate: nope, it is pretty close to a different syntax for `map` in simple cases
01:10xeqi`doseq` would be closer to a for loop in impertive languages
01:11joelti didn't realize the for [a b] part decomposed the second part... that threw me.
01:11joelti like it though.
01:11dissipate,(doc :when)
01:11clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Symbol>
01:11xeqijoelt: it looks better with a line break before the :when, so the destructuring lines up
01:11dissipatehmm, what's this ':when' keyword thing
01:12xeqidissipate: its a special keyword understood by the `for` macro -- http://clojuredocs.org/clojure_core/clojure.core/for
01:13xeqinot really special in any other sense, just when used in that spot for the `for` macro
01:13dissipatexeqi, ah, i see. interesting
01:14joeltcould of said for [[a x] [b y]... no?
01:15joeltbut that would of generated combinations i guess.
01:15xeqijoelt: [a x b y] will do the cross product of the vectors
01:15dissipatexeqi, why does this remind me of a list comprehension in python? :P
01:15xeqidissipate: because it is a list comprehension?
01:15defn,(remove #(= %) [1 "" nil])
01:15clojurebot()
01:15dissipatexeqi, looks like a vector comprehension, no?
01:16defn,(= "nil")
01:16clojurebottrue
01:16xeqi`for` returns a list, though I don't really think in terms of list vs vector most of the time
01:16defn,(= nil)
01:16clojurebottrue
01:17defn,(= false)
01:17clojurebottrue
01:17defnHmm
01:18defn,(= '())
01:18clojurebottrue
01:18dissipatexeqi, so what is the enclosing vector notation used for, with 'for'?
01:19defnDestructuring
01:19xeqidissipate: bindings for naming and destructuring, much like function declarations [] around params
01:20defnYou can use :let as well in the binding form
01:21dissipatexeqi, makes sense now. thanks.
01:24defn,(for [[k v] [[1 2]] :let [a (str k)]] a)
01:24clojurebot("1")
01:25defnThat took a long time on a phone.
01:25defnJesus.
01:25defnMaybe 200 keystrokes.
01:26defnThanks iphone.
01:26dissipatewow, 'for' list comprehensions can get gnarly
01:27dissipatenest collection bindings that can refer to previous bindings
01:27dissipateer, nested
01:28joeltIs there a way for the loop to return nil when it doesn't match?
01:29joeltinstead of filtering it returns something else?
01:29l2x,(for [[k v] [[1 2] [x y]] :let [a (str k)]] a)
01:29clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:29l2x,(for [[k v] [[1 2] ["x" "y"]] :let [a (str k)]] a)
01:29clojurebot("1" "x")
01:30trap_exit, (doc take)
01:30clojurebot"([n coll]); Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n."
01:30trap_exit, (doc nth)
01:30clojurebot"([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."
01:30trap_exitwhy does one take [n coll] and another take [coll n]
01:31trap_exitI thought I was an idiot for not memorizing this properly
01:31trap_exitbut now I feel this is inconsistent
01:31amalloy,(mapcat (fn [a b] (when (= a b) [a])) '(a b b b) '(a b c c))) is another plausible option, joelt
01:31clojurebot(a b)
01:33amalloytrap_exit: there's no good reason. nth takes its arguments in the "wrong" order for historical reasons (that's the order common lisp used)
01:33mischov"take x number items from this collection" "return from this collection the nth item"
01:33trap_exitamalloy: hmm, I actually like [coll n] more
01:34trap_exitit goes along better with assoc, dissoc
01:34trap_exiti.e. datastructuer first, then args later
01:34amalloysure, it goes okay with collection functions, but not with sequence functions
01:34amalloyeg, take, drop, filter, map
01:34mischovtake makes more sense the other way because you're taking that number from the collection, so it reads kinda like a sentence of intent.
01:34trap_exitwell, if we made filter/map also use collection first, then -> works better too
01:35trap_exittake from LST n elements
01:35trap_exitdrop from LST n elements
01:35trap_exitfilter LST for items that match ...
01:35amalloytrap_exit: (map coll1 coll2 f)?
01:35arrdem.... wat
01:35trap_exitamalloy (map (zip coll1 coll2) f) ... :-)
01:35dissipatetrap_exit, one problem with drop is that if you drop from an infinite lazy sequence, you get an infinite result
01:36amalloymischov: 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"
01:36arrdemdissipate: you get infinite _realized_ results :P
01:36trap_exitdissipate: I fail to see how laziness effects this
01:36mischovamalloy: It makes sense for take in particular.
01:36dissipatetrap_exit, it doesn't. just saying it's generally not good. :P
01:37mischovamalloy: which is why I always assumed take was ordered as it is.
01:37amalloymischov: of course it's the natural way to phrase take
01:37amalloybut the very awkward wording of "take from this coll the nth item" doesn't support any position at all
01:38arrdem,(doc zip_
01:38clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:38arrdem,(doc zip)
01:38clojurebotGabh mo leithscéal?
01:38amalloy~zip
01:38clojurebotzip 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))
01:38trap_exitalright, let's forget english
01:38trap_exitI thikn this complects things
01:38trap_exitI'd be happier if everything that operates on sequences had sequence as first argument
01:38mischovamalloy: no, not really.. :D
01:38trap_exitfrees up limited memory to remember important things
01:39arrdemamalloy: well I knew that (map (partial apply vector) ..) was a thing, I was just checking :P
01:39amalloytrap_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
01:39dissipateamalloy, does it make sense to say 'take nth item' from this sequence when the items prior have to be calculated anyways?
01:41dissipateamalloy, how about (first (drop n ...))
01:41defnExample?
01:41defnWhat is "it"?
01:42mischovdissipate: (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))
01:42arrdemeh.. we have as->... this is kinda a moot issue besides the inconvenience of not always being able to use ->
01:42dissipatemischov, the latter
01:44mischovdissipate: I always figured that way why seqs/collections are usually last in functions.
01:44mischovdissipate: way why*
01:44mischovdissipate: was why*
01:44mischovI can't type. Huzzah!
01:45mischovamalloy: now that you mention it.. yea, nth drives me nuts!
04:17yuri_niyazovHey guys
04:17yuri_niyazovWhat is the expected result from the following piece of code?
04:17yuri_niyazov(let [a (transient {})] (dotimes [x 16] (assoc! a x :ok)) (persistent! a))
04:17pyrtsayuri_niyazov: You should always use the *result* of the (assoc! ...) call.
04:18pyrtsaDon't think it's in-place. It's destructive to its first argument but not necessarily in-place.
04:18pyrtsaSo instead of dotimes, use reduce.
04:18yuri_niyazovthx!
04:19pyrtsaThe documentation should be more explicit of this.
04:19pyrtsa(doc assoc!)
04:19clojurebot"([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."
04:20pyrtsa^ The documentation isn't correct, actually. It should say something like "Returns coll with the arguments associated." or something like that.
04:21pyrtsaThe postcondition (identical? coll %) does *not* hold for conj! or assoc!, in general.
04:22pyrtsa(Where % is the return value.)
04:27yuri_niyazovI understand now, thank you very much
04:28yuri_niyazovIt's confusing because it's a different object being returned *sometimes*, not always
04:32pyrtsaAgreed. Especially since the documentation doesn't highlight this fact in any way.
04:36dsrx,(let [a (transient {})] (dotimes [x 16] (assoc! a x :ok)) (persistent! a))
04:36clojurebot{0 :ok, 1 :ok, 2 :ok, 3 :ok, 4 :ok, ...}
04:39pyrtsadsrx: The gist of it is, transient maps do (if I remember right) eight assocs in-place but then return a new instance.
04:40dsrxahh, I see
04:40pyrtsaThe doc comment doesn't point this out, which actually makes either the behavior or the doc incorrect.
04:41pyrtsaGranted, transients have been marked as alpha in Clojure 1.5.x.
04:47SegFaultAXdsrx: You should use assoc! like assoc
05:00amalloypyrtsa: well, the only behavior you should count on is that transient maps do any number of assocs in place, at any time
05:00amalloyand return a new object any number of times
05:01pyrtsaamalloy: See the docs?
05:01pyrtsa(doc assoc!)
05:01clojurebot"([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."
05:01pyrtsa"Returns coll." is not right.
05:01pyrtsaLikewise for conj!.
05:02pyrtsaThe docstring should be fixed for Clojure 1.6, nothing else.
05:02amalloypyrtsa: 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
05:02pyrtsaFiling one right now.
05:03SegFaultAXWhen does 1.6 go final? Is there a date yet?
05:03amalloySegFaultAX: i always assumed clojure release dates were "whenever rich thinks it's done"
05:03amalloymaybe with slight biasing to coincide with clojure/conj
05:04pyrtsahttp://dev.clojure.org/jira/browse/CLJ-1385
05:05SegFaultAXDid you set the priority or is it auto-set?
05:06amalloyi think it defaults to major
05:06pyrtsaOuch. I tried to set it to Major but it shows up as Minor now.
05:06pyrtsaCan it be changed?
05:06pyrtsaNevermind.
05:07pyrtsaIt probably should be Minor, it's Major. (I had a different issue open, hence my confusion.)
05:07pyrtsaLooks like I can't edit it anymore, can I+
05:07pyrtsa?
05:08SegFaultAXI don't usually consider copy changes to be major, but meh. Whomever triages the ticket will update its status appropriately.
05:08pyrtsaYah, I guess it's alright.
07:33cYmenGood morning.
07:34cYmenI 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"
07:34cYmenWhat should I do?
07:35cYmenAh the output is in the *Messages* buffer
07:53liflashhi, 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?
07:54liflashthat is, the function returns a list of strings and I get the exception that string cannot be cast to fn
07:54liflash,(defn foo [] '("hello" "world"))
07:54clojurebot#'sandbox/foo
07:54liflash,(foo)
07:54clojurebot("hello" "world")
07:55liflash,(defmacro bar [] (foo))
07:55clojurebot#'sandbox/bar
07:55liflash,(bar)
07:55clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:02dsrx,(macroexpand (bar))
08:02clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:03dsrx,(macroexpand-1 (bar))
08:03clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:03dsrxoops
08:03liflashhmmm
08:03dsrx,(defmacro baz [] '(foo))
08:03clojurebot#'sandbox/baz
08:04dsrx,(macroexpand (baz))
08:04clojurebot("hello" "world")
08:04liflashyeah, this works, because the call to foo is delayed until runtime
08:05liflashdoes the macro has to return a function?
08:05dsrxa macro needs to expand to a form that can be evaluated
08:05liflashhmm
08:05liflashi see
08:06dsrxsorry, I screwde up my use of macroexpand
08:06liflashactually the list is within a map
08:06dsrx,(macroexpand '(when 42))
08:06clojurebot(if 42 (do))
08:06dsrx,(macroexpand '(bar))
08:06clojurebot(bar)
08:06liflash,(defn foo [] {:foo '("hello" "world")})
08:06clojurebot#'sandbox/foo
08:06dsrxer..
08:06liflash,(bar)
08:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:07dsrx,(defmacro bar [] (foo))
08:07clojurebot#'sandbox/bar
08:07dsrx,(macroexpand '(bar))
08:07clojurebot{:foo ("hello" "world")}
08:07liflashthis works fine if for example:
08:08liflash,(defn foo [] {:foo #{"hello" "world"}})
08:08clojurebot#'sandbox/foo
08:08liflash,(bar)
08:08clojurebot{:foo #{"hello" "world"}}
08:08liflashit's only a problem if the result contains a real list
08:08cYmenman reloading the repl in emacs is a pita
08:08dsrxcYmen: M-x cider-reload ?
08:09dsrxliflash: yeah, when the reader sees an unquoted list it's evaluated as a function call
08:09dsrx,("this" "errors")
08:09clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:10cYmendsrx: that works? :o
08:10dsrx,(quote {:foo ("hello" "world")})
08:10clojurebot{:foo ("hello" "world")}
08:10dsrx,'{:foo ("hello" "world")}
08:10clojurebot{:foo ("hello" "world")}
08:10dsrxcYmen: yeah
08:11liflashhmmm
08:11liflashso how would i would have to use explicitly (quote.. ) in the function, if this function is used in a macro?
08:12liflash- how would
08:13liflash,(defn foo [] {:foo (quote ("hello" "world"))})
08:13clojurebot#'sandbox/foo
08:13liflash,(bar)
08:13clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:13dsrxliflash: {:foo (quote ("hello" "world"))} is equivalent to {:foo '("hello" "world")}
08:14liflashyes, i thought so
08:14liflashbut this would mean in a macro i can't call functions that contain lists in their result
08:18dsrx,(defn quux [] '{:foo '("hello" "world")})
08:18clojurebot#'sandbox/quux
08:18dsrx,(defmacro baz [] (foo))
08:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:18dsrxerr
08:19dsrx,(defmacro baz [] (quux))
08:19clojurebot#'sandbox/baz
08:19dsrx(baz)
08:19dsrx,(macroexpand '(baz))
08:19clojurebot{:foo (quote ("hello" "world"))}
08:19dsrx,(baz)
08:19clojurebot{:foo ("hello" "world")}
08:21liflashso I have to quote the returned map in the function?
08:25liflashdon't know how to do this, since:
08:25liflash,(defn foo [] (let [s {:foo '("hello")}] s))
08:25clojurebot#'sandbox/foo
08:25cYmendsrx: hm....technically it does but I still have to evaluate my code again and start the web server :)
08:25liflashand the map is generated by (map ...)
08:26irctccan 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
08:32liflashdsrx: cYmen: to generate an even more realistic example:
08:33liflash,(defn foo [] (reduce conj '() '("hello" "world")))
08:33clojurebot#'sandbox/foo
08:33liflash,(foo)
08:33clojurebot("world" "hello")
08:33liflash,(bar)
08:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:35liflashdsrx: cYmen: how would I quote it, so the result isn't evaluated again?
08:36liflashirctc: do you have some more information? when do you get the exception? is clojure contained in your dependencies?
08:38irctcliflash: I have slurped a file and then I call read-string ... and I get an exception when running the application
08:38irctcliflash: when I try this in the repl there is no exception
08:38irctcliflash: so maybe this record class is not loaded in that namespace ? I am not sure
08:40liflashirctc: I'm new to clojure, too. so I can only guess by myself. what does the exception say?
08:41cYmenliflash: (defmacro bar [] '(foo))
08:41cYmenbut that doesn't do what you want I think
08:42liflashcYmen: this is our solution from yesterday ;)
08:42cYmen,(defmacro bar [] '(foo))
08:42clojurebot#'sandbox/bar
08:42cYmen,(macroexpand '(bar))
08:42clojurebot(foo)
08:42cYmenThis just calls foo.
08:42liflashcYmen: the call to foo is delayed to runtime, but i need it at compile time
08:42liflashexactly
08:45cYmenah got it
08:45cYmen,(defmacro bar [] `~(foo))
08:45clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:46cYmen,(defn foo [] (reduce conj '() '("hello" "world")))
08:46clojurebot#'sandbox/foo
08:46cYmen,(defmacro bar [] `~(foo))
08:46clojurebot#'sandbox/bar
08:46cYmen,(macroexpand '(bar))
08:46clojurebot("world" "hello")
08:47cYmensee, told you it was "just quote unquote" ;D
08:47liflash,(bar)
08:47clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:47cYmenI know ;)
08:48liflashso we are at the beginning again...?
08:49liflashah, no... wait a sec
08:49cYmen,(defmacro bar [] `'~(foo))
08:49clojurebot#'sandbox/bar
08:49cYmen,(bar)
08:49clojurebot("world" "hello")
08:49liflash,(macroexpand '(bar))
08:49clojurebot(quote ("world" "hello"))
08:50liflashhmmm... looks good
08:50cYmen,(defmacro bar [] `(list ~(foo)))
08:50clojurebot#'sandbox/bar
08:50cYmen,(bar)
08:50clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
08:50cYmen,(defmacro bar [] `(quote (list ~(foo))))
08:50clojurebot#'sandbox/bar
08:50cYmen,(bar)
08:50clojurebot(clojure.core/list ("world" "hello"))
08:50cYmen,(defmacro bar [] `(quote ~(foo)))
08:50clojurebot#'sandbox/bar
08:50cYmen,(bar)
08:50clojurebot("world" "hello")
08:50cYmenoh whatever
08:51liflashthx for the experiments, I'll have a look in the repl
08:52cYmenhttp://i.imgur.com/4orTtew.jpg
08:52liflash:D
08:55cYmenbasically, foo returns a list, too stop clojure from trying to call that as a function it needs to be quoted
08:55cYmens/too/to
08:55cYmenbut '(foo) will also quote the call to foo
08:56liflashexactly
08:56cYmen`'~(foo) quotes the quote but unquotes the call to foo
08:56cYmen``~(foo) seems to work, too
08:57liflash`'~(foo) quotes the result of foo
08:57liflashso the returned map/list is quoted in the result of the macro
08:57cYmenright
08:57liflashwould that be a problem for the caller of the macro and therefore the 'user' of the map?
08:58cYmenuh depends an what that caller expects, I suppose
08:59cYmenright now he gets a list back
09:00liflashin 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
09:01liflashso would something like (:foo (bar)) work?
09:01liflashassuming the quoted map contains the key :foo
09:02cYmenyou mean you want bar to be executed?
09:03cYmenwrite down some examples of input and output for your macro ;)
09:04liflashok, i just tried it and seems to work perfectly
09:04liflashthank you very much for your help
09:06cYmenoh, it's a learning experience for me, too so thank you :)
09:06liflashdon't you think it's a pain to think about the returned data types when calling a function?
09:21cYmenwhat do you mean?
09:21cYmenAm I not calling the function because I am interested in the returned data and hence its type? :)
09:21liflashonly in the data ;)
09:22liflashall this wouldn't have happened if the returned type was not a list
09:22cYmenBut data without a type is just a mess of bits. :)
09:24tristanStrangehey all... how can i cast a lazySeq to an ints suitable for passing to a Java method?
09:26cYmentristanStrange: into-array?
09:26cYmenNot quite sure what you mean by "ints"
09:27tristanStrangei'll take a look thanks. Erm... i mean an array of integer primitives
09:28cYmenin that case that should work :)
09:28cYmenhttp://clojuredocs.org/clojure_core/clojure.core/into-array
09:40steckerhalterany suggestions for storing/querying data? what's the least painful way?
09:41steckerhalterit could probably get quite a lot of data, a few GB maybe
09:42cYmendepends on what kind of data but basically I think this question is language agnostic
09:50steckerhaltercYmen: I'm asking for something that works well with Clojure. where you don't have to jump through all the hoops as often necessary
09:51tristanStrangeI'm trying to call .setPixels on a WritableRaster... but get the following error:
09:51tristanStrangeIllegalArgumentException No matching method found: setPixels for class sun.awt.image.IntegerInterleavedRaster clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)
09:51cYmensteckerhalter: Well, yeah but what kind of data do you have? I mean using a database from clojure is pretty straightforward, for example...
09:51tristanStrangedocs for java method here: http://docs.oracle.com/javase/7/docs/api/java/awt/image/WritableRaster.html#setPixels(int, int, int, int, int[])
09:51tristanStrangeand I'm feeding it four integers and an array of ints as arguments
09:52tristanStrangecan anyone guess why?
09:52cYmentristanStrange: because one of the arguments doesn't match? is an array maybe an Array and not a []? Just guessing.
10:07ghanim01hi
10:11mercwithamouthhola
10:19tristanStrangeah thanks cYmen. I needed an int[] not an Integer Array... int-array did the job
10:30cYmentristanStrange: so where are you at with your image processing experiments?
10:31tristanStrangehey cYmen... not too far at all yet.. still trying to get used to Clojure
10:32tristanStrangeI'm hoping to get a Sims style GA set up that modifies the expression trees that create images
10:32tristanStrangeand was expecting lisp to make that a lot easier....
10:33tristanStrangethis paper is my inspiration: http://www.karlsims.com/papers/siggraph91.html
10:34tristanStrangeI've got something going that generates the image files from functions now
10:34cYmenhuh
10:34cYmenlooks cool
10:34cYmennot that i understand what it is about ^^
10:35ktosHi
10:35ktostell me please, does clojure like lisp can use "system image"?
10:36cYmenhm... I have no clue
10:44wagjoktos: no
10:44wagjoktos: see https://groups.google.com/forum/#!topic/clojure/UlkoDy_YyKU
10:59ktoswagjo: thank you
11:02borkdudeShould this be considered an error in the spec of clojure? https://gist.github.com/borkdude/9584500
11:28raven1Howdy! 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:29raven1I 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:29cYmenborkdude: What's that *1 thing you're using?
11:30borkdude*1 is the last evaluated value in the repl
11:35cYmenI don't even understand your problem. :)
11:38[raven]cYmen: mine or borkdude one ?
11:38cYmenborkdude's
11:39[raven]cYmen: gotcha :) you've 2 cents for mine?
11:39cYmenno, I'm just starting myself
11:39cYmenFar too advanced. :)
11:39borkdudeNormally (read-string (pr-str x)) == x
11:39borkdudethis is not the case with keywords that are created from certain strings, like those with a whitespace in it
11:40tristanStrangeok, how does one make the functions in clojure.math.numeric-tower availiable to themselves?
11:40cYmenborkdude: so you're saying (keyword "foo bar") should be something like :foo-bar?
11:40borkdudecYmen I'm not saying that per se.
11:40borkdudecYmen maybe it should not even be allowed to create such a keyword
11:41tristanStrangeI'm getting file notfound exception when i include (:require clojure.math.numeric-tower) in my namespace
11:41[raven]cYmen: fair enough :)
11:42tristanStrangesketchy found out how to do it. ignore me :/
12:01benmossis it specified behavior that ,(:foo {:foo "bar"} {:foo "baz"}) always returns "bar"?
12:02benmossdon't know where the docs would be for keyword access
12:03benmossoh nevermind
12:09cYmenbenmoss: If it only returns bar, I'm surprised it takes another argument.
12:10cYmenoh the second argument is a default value
12:10benmossyeah
12:10cYmen,(:foo {:bla "bar"} {:foo "baz"})
12:10clojurebot{:foo "baz"}
12:10cYmenseems fine :)
12:10benmossat first i thought it was variadic but only cared about the first map
12:10benmossbut yeah realized that just after i asked :)
12:11cYmenapparently your IDE is lacking description of variables for function calls :)
12:22gfredericksis there a standard file-store impl of ring.middleware.session.store?
13:09AmandaCshould this work? (for [y (range 32) (println “Foo”))
13:10AmandaCI mean, I’d think it’d work, but it doesn’t seem to in my code. o.o
13:11katox,(for [y (range 3)] (println "Foo"))
13:11clojurebot(Foo\nFoo\nFoo\nnil nil nil)
13:12gfredericksAmandaC: what you pasted isn't even syntactically valid, so it's not clear if that's your problem or whatever else
13:13AmandaCHold on, I’ll upload the code I’m actually using real quick.
13:13gfredericksrefheap.com
13:13AmandaChttp://amanda.darkdna.net/p/43277 <— I’ve got my own little pastebin. :p
13:14gfredericksfancy
13:14gfredericksah ha
13:14arrdemnotbad.jpg
13:14gfredericksso your for expression is probably fine
13:14gfredericksthe problem is that for creates a lazy seq, and you're using it for side effects
13:14gfredericksyou should probably just s/for/doseq/
13:15arrdemyep. doseq is the tool you want, not for.
13:15AmandaCah
13:15bufferlossis clojurescript on topic in here?
13:15arrdembufferloss: msotly
13:15arrdem*mostly
13:15Bronsaactually you probably want simply dotimes
13:15gfredericksBronsa: good catch
13:15Bronsayou can avoid the range then. (dotimes [i 32] ..)
13:15bufferlossok 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:16bufferlossI cloned the repo, I cd'd into the directory, ran lein bootstrap, and that ^
13:16bufferlossany ideas what might be going wrong?
13:16BronsaAmandaC: also (* i (* y 16)) can be written as (* i y 16)
13:17bufferlossI'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:17bufferlosswas hoping to get started with clojurescript, but... yeah, this happened
13:17Bronsaand those 4 (.method g ..) can be rewritten as (doto g (.method ..) ..)
13:17AmandaCBronsa: Math isn’t my strong point, so I was unsure if that was valid
13:17arrdembufferloss: it looks like lein bootstrap is an odd little command for when lein is used to build itself...
13:18arrdembufferloss: you shouldn't need it or be using it.
13:18bufferlossarrdem: hmm, so maybe I only need to use lein repl
13:18gfredericksclojurebot: multiplication is commutative
13:18clojurebotAck. Ack.
13:18bufferlossok cool thx
13:18AmandaCRather, if it would produce the wanted result
13:18arrdembufferloss: probably
13:21bufferlosserg, 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:21TravisDHazzah for associative multiplication
13:21arrdemassociativity is a lie... the NaNs wait for you...
13:22bufferlossso much for an easy to use tutorial :/
13:22AmandaCHrm, 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:24AmandaCahha, first
13:26bufferlosswell 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:26bufferlossare there any common JSON output libs that'll take what is, effectively EDN and render it as JSON from ring?
13:26TravisDarrdem: Because you might overflow for some "bracketings" and not others?
13:27arrdemTravisD: Yep. All sorts of evil things can happen...
13:28TravisDyeah :( I hate evil things.
13:32TravisDOne 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:32TravisDDoes anyone know what I'm talking about?
13:36TravisDThe lie:
13:36TravisD,(let [big Double/MAX_VALUE] (= (* 0.5 2 big) (* (* 0.5 2) big) (* 0.5 (* 2 big))))
13:36clojurebotfalse
13:39TravisDSimilarly, commutativity is a lie:
13:39TravisD,(let [big Double/MAX_VALUE] (= (* 0.5 2 big) (* big 2 0.5)))
13:39clojurebotfalse
13:39TravisDsadness :(
13:40whodidthisdo the usual ring session middlewares allow using different cookie lifetimes
13:52whodidthisoh sweet, found :session-cookie-attrs from source
14:27ro_sttechnomancy: 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:27ro_stDEBUG=true lein deps doesn't give me any useful info, and i'd like to avoid redownloading my entire .m2
14:48bufferlosshow does compojure/ring serve or decide from where to serve static files?
14:48bufferlossit 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:52cYmenbufferloss: lein compojure-app?
14:52bufferlossthe compojure docs for route/resources are not clear to me
14:53bufferlosscYmen: uhh, not sure, I just added compojure to my project.clj and set up some basic routing
14:53bufferlossI 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:53bufferlosshttp://weavejester.github.io/compojure/compojure.route.html
14:55cYmenhm...
14:55bufferlosshmm, so it seems route/files serves from the actual project root, wheras route/resources serves from a folder called resources
14:55bufferlossof which, there is no mention in the docs that this is the case
14:55cYmenso the repl.clj that I get generated has (wrap-file "resources")
14:55bufferlosswhat is the difference exactly then?
14:57cYmenlooking at the source I think it might be that files serves everything as a file
14:57cYmenwhile resources might serve images as image content type or something
14:59xeqibufferloss: files come from the file system, resources come from the classpath
14:59xeqiin general lein puts "resources/*" on the classpath
14:59bufferlossxeqi: k, I'm not sure what the implications of that are to how I should develop or which I should choose
14:59xeqibufferloss: I choose resources. Then you can ship jars
14:59cYmenI though a class path was just a list of folders where java looks for classes.
15:00xeqithat contain js/css and refer to them
15:00bufferlossxeqi: ah, ok that makes sense
15:00cYmenWhat IS a classpath? :)
15:00bufferlosscYmen: yeah I think that's pretty accurate for a definition of classpath, though there may be other implications for builds etc
15:00xeqicYmen: pretty much, but then they found out they wanted to ship non-classes in jars, so resources also load from them
15:01xeqifor css/js in web apps, or icons in desktop apps
15:01xeqias examples
15:02cYmenAh, so they are somehow relative to a "project" and included in magic zips like jars?
15:03cYmenAnd that's why you can access resources therein from a deployed jar?
15:07xeqiclose enough
15:08cYmenokay :)
15:08cYmenthanks
15:39TravisDIs there a function like (def enumerate (partial map-indexed vector)) in the clojure libraries?
15:41amalloyTravisD: 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:42TravisDAh, yeah, I guess often you would do (map f (enumerate coll)) or something
15:43TravisDI wanted to filter a list, but remember the indices of the values I kept
15:44gfredericksdoes anybody have any ideas for making :repl-options :nit composable?
15:44gfredericksinit*
15:45gfredericksor some other way to put default util stuff in the :user profile?
15:45technomancygfredericks: :injections is more composable
15:45hyPiRionTravisD: I usually implement a function I call aside
15:46hyPiRion,(defn aside [& fs] (fn [& xs] (mapv #(%1 %2) fs xs)))
15:46clojurebot#'sandbox/aside
15:46hyPiRion,(map-indexed (aside identity :val) [{:val 42} {:val 23}])
15:46clojurebot([0 42] [1 23])
15:47hyPiRionnot sure if the naming makes sense, though
15:48TravisDhyPiRion: 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:48TravisD(defn fn-pair...)
15:56TravisDOne 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:59amalloyTravisD: keep-indexed?
15:59TravisDamalloy: Could work, but I was bothered by filtering nils rather than having a predicate
16:00TravisDI guess it might work nicely with when-let
16:00amalloyTravisD: 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:01TravisDamalloy: Yeah, in the code I was writing I was being sloppy about making it clear what was being filtered
16:09gfrederickstechnomancy: oh hey this might work
16:09gfredericksthamks
16:09gfredericks(inc technomancy)
16:09lazybot⇒ 100
16:10hyPiRionstill < 0x100
16:11gfrederickslazybot: who has teh most karma
16:12gfredericksI don't imagine :injections gets eval'd in any particular namespace?
16:12hyPiRionoh, that's årobably a good PR for lazybot, some list of people with the most karma
16:13hyPiRion*probably
16:15gfredericksoh using a vector for :init would be pretty composable actually,
16:15amalloygfredericks: i think it's got to be technomancy
16:15gfredericksand not crazy obnoxious like the ((comp last list) ...) stuff I'm doing currently
16:16TravisDCan you decrement karma also?
16:17gfredericks(dec rubby)
16:17lazybot⇒ -1
16:17TravisD:O
16:17TravisDis there a count of the number of karmic operations done on a user?
16:18TravisD(karma rubby)
16:18amalloy$karma rubby
16:18lazybotrubby has karma -1.
16:18hyPiRion(identity rubby)
16:18lazybotrubby has karma -1.
16:18TravisDheh
16:18TravisDyou are all just numbers!
16:18gfredericks$karma TravisD
16:18lazybotTravisD has karma 2.
16:19TravisD$karma gfredericks
16:19lazybotgfredericks has karma 42.
16:19TravisD(inc not-a-real-user)
16:19lazybot⇒ 1
16:19TravisDAh..
16:20gfrederickswoooah 42
16:20gfredericksthat's better than 100!
16:20TravisDheh, yeah!
16:20TravisD(inc gfredericks)
16:20lazybot⇒ 43
16:20TravisDD:
16:20gfredericksnow I just gotta find a way to get decremented
16:20gfrederickshey guys why aren't you using haskell yet
16:20TravisD(dec gfredericks)
16:20lazybot⇒ 42
16:21gfredericksthat was quick
16:21TravisDPreemptive, even
16:33amalloygfredericks: just checked in lazybot's db, technomancy is the karma winner, followed by me; TimMc, Raynes, and you round out the top 5
16:33amalloyalso someone on another irc network has a karma of 9002, probably as some kind of inside joke?
16:34Raynes$karma 44
16:34lazybot44 has karma 0.
16:34Raynes$karma Raynes
16:34lazybotRaynes has karma 44.
16:38isaacbw$karma technomancy
16:38lazybottechnomancy has karma 100.
16:43gfredericksI would not have expected to be #5
17:08patrickodI'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:08patrickodGoogling seems to suggest that adding (:gen-class) into the namespace definition for the handler.clj would fix this but that hasn't helped.
17:11seangrovebbloom: ping
17:11seangrovebbloom: You around to check the clarity and sanity of a proposal?
17:16seangrovepatrickod: No warnings when creating the uberjar?
17:16patrickodone second I'll paste the output of that
17:17patrickodseangrove updated the gist with the output of lein ring uberjar
17:19seangrovepatrickod: 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:19patrickodhaha no worries. :) part of the learning curve
17:19seangrovepatrickod: Have you looked at https://devcenter.heroku.com/articles/getting-started-with-clojure ?
17:19patrickodI just happened across that googling. reading now
17:20seangroveOh, sorry, maybe not that one..
17:20seangroveThere we go https://devcenter.heroku.com/articles/clojure-support
17:20seangrove:profiles {:uberjar {:main myproject.web, :aot :all}}
17:21seangroveExcess flood from bbloom...
17:23seangrovepatrickod: Yeah, it's great once you get it, but it can be frustrating in the meantime
17:26patrickodseangrove it worked :)
17:26patrickodthanks!
17:26seangroveGlad to hear it
17:37AeroNotixwhere can I find a list of all clojure namespaces? All things I usually wouldn't stumble across?
17:38brehautAeroNotix: http://clojure.github.io/clojure/
17:39AeroNotixhmm, ok. Was just looking here
18:07TimMc$karma TimMc
18:07lazybotTimMc has karma 55.
18:07TimMchuh
18:10shep-homeI'm playing with trying to improve the performance of some code, and I want to tweak a lazy sequence
18:10shep-homeI think that the overhead of the lazy is too large compared to my algorithm
18:10shep-homeis there a way of making a kinda-lazy-seq?
18:10AeroNotixshep-home: what does this kinda-lazy-seq do?
18:11shep-homeThat is, do my recursive call 100 times eagerly, then return a lazy fn for the rest
18:11AeroNotixshep-home: take?
18:11AeroNotixshep-home: show some code
18:11hyPiRionAeroNotix: is lazy
18:12AeroNotixdoh
18:12shep-homeAeroNotix: one sec, lemmo post
18:13shep-homehttps://gist.github.com/shepmaster/9590585
18:13shep-homeThat is from my editor window, so it doesn't actually work ;-)
18:15shep-home(I've updated with the last working version)
18:16shep-homeI originally had lazy-cat, but that creates 3 anon functions, so I switched to this version, which only makes one
18:17shep-homei havent fully benched the difference, but I think theres a tiny (<10%) speedup
18:17shep-homecould be all in my head
18:17AeroNotixI'm gonna bail on this-- I'm not familiar with how to optimize lazy seqs
18:17AeroNotixIt's quite nuanced
18:18shep-homeA pain with profiling this in visual VM is that the call stack just goes on and on and on
18:18shep-homedeeper and deeper
18:18shep-homeAeroNotix: Me either ;-)
18:18shep-homeI also tried a core.async version
18:18shep-homeand that had reasonable speedup to 4 threads
18:19shep-homebut then flatlined (I think due to lock contention)
18:19AeroNotixwell
18:19AeroNotixone immediate thing for me is the two recursive calls are done one after the other
18:20AeroNotixI'd find a way to do those concurrently
18:21shep-homeHere's the pretty graph of the core.async version: http://i.imgur.com/HYZNqeX.png
18:21shep-homeAeroNotix: do you mean for the lazy seq version? Or for the core.async version?
18:22AeroNotixjust in-general
18:22bbloomseangrove: i'm back now
18:22bbloomwhat's up?
18:22shep-homeI'm not sure that lazy-seq and concurrency play together... do they?
18:22shep-homeerr, generation of lazy-seqs
18:22AeroNotixpass
18:23hyPiRionnot if they are recursive
18:26shep-homehyPiRion: That's what I was afraid of. And I'm not sure how to disentangle this particular recursion
18:48felher_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:49brehautor is fine for defaulting values
18:49amalloy(or a b) is pretty cool
18:49felher_kay, thanks folks.
18:49felher_:)
18:49brehaut(-> some complicated thing (or b)) also works great
18:49amalloythere's also fnil if you get the value from a function call
18:50brehaut(for things that return and consume nils happily)
18:51felher_nice, good to know. Ty :)
19:13AeroNotixso
19:13AeroNotixin core.map
19:13AeroNotixfor instance, it has a lambda. I'm looking at program now which has 37k instances of that lambda.
19:14AeroNotixWouldn't it be better if that was just a separate function?
19:14AeroNotixI know it's a trivial thing to do
19:14AeroNotixbut
19:14AeroNotixthoughts?
19:18shep-homeAeroNotix: I wonder what the benefit would be. Any way to tell?
19:18AeroNotixmemory
19:19shep-homeYou are referring to `step`, right?
19:19shep-homecause there's also the anonymous one below that
19:20AeroNotixSame difference
19:21AeroNotixshep-home: those'll both compile to separate classes
19:21AeroNotixand each time you call, you make an instance of that class. IIRC?
19:21AeroNotixI mean --- I'm not advocating people never use lambdas. That's crazy.
19:21AeroNotixbut, it'd be interesting to see what'd happen if the entire standard library implementation did not use them.
19:23shep-homeLooks like step could be pulled out, but the anon one captures locals...
19:24AeroNotixsure
19:25amalloyAeroNotix: 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:25amalloymake sure it's as lazy as the existing implementation
19:25AeroNotixamalloy: I'm just talking generally
19:26amalloyin general, if the entirety of clojure.core didn't use lambdas, it would be totally awful. fire would rain from the sky
19:27amalloyit 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:30shep-homeAeroNotix: can you tell with lambda is taking memory?
19:30shep-homewhich*
19:31shep-homeamalloy: cause `step` in `map` doesn't close over anything. Is it possible that it could contribute to memory usage for each unfinished map?
19:32amalloy*shrug* a lambda that doesn't close over anything takes up as much space as (Object.)
19:32amalloyie, a pointer
19:32amalloyAeroNotix: 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:35shep-homeamalloy: so, a little bit, as opposed to the static / constant a top-level defn would have? Or is there more hidden?
19:38shep-homeAnd this amount of space is probably neglible compared to the memory used by the lazy-seq's data.
19:39shep-homeBut it is a single place that could be changed to reduce memory consumption across all users
19:42shep-homeSimilar with concat$cat, it seems
19:42amalloyif 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:42amalloyand you can't avoid the map$step$fn, because it's closing over cs
19:43amalloy(map$step$fn is the lambda introduced by the lazy-seq macro, in case that's not obvious)
19:50shep-homeWell, for my current problem, replacing concat with a version with concat$cat at the top level doesn't make any noticeable time difference
19:51shep-homeand I don't know how to quantify memory/GC activity over the entire run, so I cant say anythign there
20:29seangrovednolen_: 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:29dnolen_seangrove: it was just manual
20:29seangroveOk, thought there might have been something else
20:50stcredzeroI may be going crazy here, but it seems like the keys in a map in a defrecord object are all turning into false.
20:58gfredericksthewat
21:02hyPiRion,(alter-var-root #'false? (constantly true))
21:02clojurebottrue
21:02hyPiRionyay
21:03xeqi,(false? false)
21:03clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>
21:03hyPiRionoh, that was probably wrong
21:03hyPiRion,(.bindRoot #'false? (constantly true))
21:03clojurebotnil
21:04hyPiRion,(map false? (keys (apply hash-map (range 10))))
21:04clojurebot(true true true true true)
21:04xeqi,(false? false)
21:04clojurebottrue
21:05xeqioh what fun things that can do to the bots
21:05Rayneshttps://github.com/Raynes/clhue In case you've ever wanted to program your light bulbs.
21:09gfrederickshyPiRion: ha you wanted (constantly (constantly true))
21:09hyPiRiongfredericks: yeah, I realised in hindsight
21:09gfredericks,(->> true constantly constantly (alter-var-root #'false?))
21:09clojurebot#<core$constantly$fn__4057 clojure.core$constantly$fn__4057@6b7d38>
21:09gfredericks,(false? false)
21:09clojurebottrue
21:09gfredericks,(false? ["FALSE!"])
21:09clojurebottrue
21:10akurilinHey 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:12stcredzeroYes, it does appear that (keys my-map) is returning '(false false false false false)
21:15stcredzeroIs there any way someone can see asking (filter fn (keys a-map)) and getting '(false false false false)?
21:16gfredericks,{(Boolean. false) 12 (Boolean. false) 13}
21:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: (Boolean. false)>
21:17gfredericks,(hash-map (Boolean. false) 12 (Boolean. false) 13)
21:17clojurebot{false 13}
21:17stcredzeroYes, but then asking keys, I'd only get '(false)
21:18gfredericksyeah, just experimenting
21:19gfrederickssounds pretty spooky
21:19stcredzeroThis is just the most bizzaro error ever. Should I be upgrading to Clojure 1.6?
21:21stcredzeroI 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:22stcredzeroOr am I misunderstanding lazy sequences and what (doall) does?
21:23beamsodoall doesn't return any values
21:23stcredzeronone at all?
21:23krasHello, everyone
21:23beamsoi think it just makes everything in the lazy sequence evaluate
21:24stcredzero,(doall (map identity '(1 2 3 4)))
21:24clojurebot(1 2 3 4)
21:24krasLooking for suggestions on 'lex/yacc' type libraries in clojure
21:24stcredzeroLooks like it returns a value to me
21:25beamso,(doall (map inc '(1 2 3 4)))
21:25clojurebot(2 3 4 5)
21:26beamsooops. my bad. i think i was getting dorun and doall confused.
21:26stcredzeroIs there something that has the effect of (fn [coll] (vec (doall coll))) ?
21:26akhudekkras: instaparse
21:27stcredzeroOr is (fn [coll] (vec (doall coll))) redundant to (vec)?
21:27amalloystcredzero: that lambda is a lengthy way of writing vec
21:27stcredzeroamalloy: danke
21:28amalloyi 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:29krasakhudek: thank you, will have a look. Any idea how the performance is? My language is simple but I need to parse huge files
21:29akhudekkras: no idea, we've only used it for fairly short inputs
21:31akhudekkras: but the author does care about performance https://github.com/Engelberg/instaparse/blob/master/docs/Performance.md
21:32stcredzeroamalloy: here's the snippet of code that makes me think that's happening: http://pastebin.com/WE3mkACS (old-grid should be a map)
21:32amalloykras: 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:33stcredzeroSo, is there any risk in going to Clojure 1.6, or should I just jump in?
21:33krasamalloy: antlr I guess generated Java code if I am right? it's not a pure clojure library?
21:34amalloykras: he recently wrote some clojure bindings for it: https://github.com/aphyr/clj-antlr
21:34stcredzeroANTLR is definitely Java
21:34amalloystcredzero: one possibility is that you have keys in your map that aren't false, but print the same as it
21:35amalloyfor example, i strongly recommend against using str to print data structures, since ##(str ["false" false (symbol "false")])
21:35lazybot⇒ "[\"false\" false false]"
21:37stcredzeroamalloy: 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:37amalloypr-str
21:38amalloystcredzero: i'd suggest printing the actual map, too, if you're getting behavior from it that makes no sense
21:39stcredzeroamalloy: a sensible suggestion
21:40krasthanks amalloy: and akhudek: give give both antlr and instaparse a shot ...
21:41kraswill*
21:43amalloystcredzero: 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:44SegFaultAXI would be pretty shocked if instaparse could come close to antlr.
21:45mr-foobarIn clojurescript + core.async ... can I use any number of (go ...)'s and channels ? Are there any performance implications ?
21:45amalloySegFaultAX: incidentally, i profiled instaparse, and it was spending most of its time inside of a swap! modifying an arraymap
21:45SegFaultAXamalloy: How big was the arraymap?
21:45amalloyso persistent data structures aren't free *all* the time, as i usually claim
21:46amalloyoh, i dunno. probably small. i just had timing information and stacktraces
21:46SegFaultAXFree lunch and silver bullets, etc.
21:46amalloymr-foobar: http://swannodette.github.io/2013/08/02/100000-processes/
21:50TravisDYowzah, that gets my processor all hot and bothered
21:50TravisDlooks cool though
21:51TravisDAlthough, it's misleading how the URL makes it look like there are 100,000 processes,
21:51TravisDOh, I should have read the update :)
21:52mr-foobaramalloy: There is only one channel, returned by render-loop. Are channels also cheap ?
21:54amalloyi believe channels are cheap too
21:54SegFaultAXmr-foobar: Fairly cheap, yes.
21:55isaacbwanyone 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:56SegFaultAXisaacbw: Sure it could, but you'd have to implement it yourself.
21:56mr-foobaramalloy 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:56isaacbwSegFaultAX: what do you mean
21:57SegFaultAXisaacbw: 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:04dsrxoh god turbolinks
22:13beamsoa defprotocol definition, with a :gen-class directive in the namespace, generates an interface/abstract class?
22:14beamsowith any deftypes implementing that defprotocol as classes implementing/extending the protocol?
22:15stcredzeroamalloy: The thing that I ask (keys) of prints out as a Clojure map!
22:27joshbamboo1isaacbw: have a look at pjax http://pjax.heroku.com/ Turbolinks is based on this.
22:36gfredericksstcredzero: what is its type?
22:36isaacbwjoshbamboo1: is the time supposed to be changing when I click on the links?
22:36gfredericks,(keys (repeat 5 (first {false 42})))
22:37clojurebot(false false false false false)
22:37joshbamboo1if 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:38isaacbwah, I see!
22:38isaacbwawesome, thanks for the link
22:38joshbamboo1pjax 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:39joshbamboo1The 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:40isaacbwso is turbolinks just rails trying to be even more monolithic instead of leveraging what already exists?
22:42joshbamboo1The 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:44joshbamboo1Only skimmed, this might help: http://geekmonkey.org/articles/28-introducing-turbolinks-for-rails-4-0
22:47joshbamboo1Sounds 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&amp;utm_medium=email for some other caveats, esp long lived JS
22:49joshbamboo1I 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:49joshbamboo1^really need == real world need
22:54dsrxhttps://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:04stcredzerogfredericks: the type of the old-map is clojure.lang.PersistentHashMap
23:07stcredzerogfredericks: but now the mismatched (keys) collection is [[0 -3]]
23:30Fraz2does anyone know if it's possible to use the lein kibit with custom rules defined in my project
23:31Fraz2this is possible using vanilla kibit, but the lein plugin does not support a rules argument
23:31Fraz2trying 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:37seangrovednolen_ bbloom Hopefully getting more coherent https://dl.dropboxusercontent.com/u/412963/zenrise/zenrise.html As usual, feedback appreciated
23:40stcredzeroSo no one wants to chime in on the desirability of going to Clojure 1.6?
23:41seangrovestcredzero: Shouldn't be too damaging, but there's no hurry
23:42bbloomseangrove: hmm... seems like there has to be something an order of magnitude simpler
23:44seangrovebbloom: 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:44bbloomis the goal of a "transformer" just to itself be data, so that it's toolable?
23:45bbloomi guess my question is why not just parameterize the nav-bar with a function which converts the provided data in to the items
23:45bbloomprobably worth looking at http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol(v=vs.110).aspx too
23:46bbloomand for bi-directional purposes: http://wpftutorial.net/ValueConverters.html
23:47l1xhi, is this the right way of decomposing list or there is better way of doing that? https://gist.github.com/l1x/9593619
23:47bbloomseangrove: 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:48bbloomi'm not sure why i need a transform-registry and a bunch of other machinery like that
23:49SegFaultAX,(doc some)
23:49clojurebot"([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:49SegFaultAXl1x: ^
23:49bbloomseangrove: 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:49seangrovebbloom: 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:49l1xSegFaultAX: thanks!!
23:50bbloomseangrove: ah i see... lots of concepts at once
23:50bbloomseangrove: is it possible to defer the serialization requirements?
23:51bbloomseangrove: or at least delay introducing them until usage of the fundamentals are clear
23:51bbloomseangrove: 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:51seangrovebbloom: I needed it while building the tooling, I'd have to think of a way to pull that out
23:51bbloomwe've already got a definition-registry, called namespaces :-)
23:52seangrovebbloom: 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:52seangrove"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:53seangroveBeing 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:54bbloomthis is the situtation in which it kinda sucks we don't have an eval or compile function in cljs
23:54seangrovebbloom: Hah, I was considering funding cljs-in-cljs for that very reason while building this out ;)
23:55bbloomthis 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:56stcredzeroIs 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:57bbloomstcredzero: i'm not sure how laziness or proxies relates at all to a game loop....
23:58bbloomseangrove: anyway, this spec makes *some* sense to me
23:58SegFaultAXWell I can see how laziness might relate, but proxies?
23:58seangrovebbloom: 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:58seangrovebbloom: I'll continue hashing it out these are all good questions
23:59seangroveAnd if the tooling is actually usable, then it's all interesting, and if not, then it's not really worthwhile anyway.
23:59bbloomseangrove: yeah, you're making progress, so just keep on hacking
23:59bbloomyou can figure out the theory of it all later :-P