#clojure log - May 09 2014

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

2:10 amalloy: AWizzArd: i think you define a goal that succeeds only when one of those things is true, and then use that goal in your function

2:10 wait, core.match, not core.logic

2:12 so define a function: (defn small-or-even [x] (or (#{1 2 3} x) (even? x))), (match [x] ([(n :guard small-or-even)] ...)). i don't recall core.match syntax exactly, but i think you see the idea, AWizzArd

3:59 bracki: How do I doto with static methods?

4:00 CompilerException java.lang.RuntimeException: Expecting var, but Mysql is mapped to class com.twitter.finagle.exp.Mysql

4:02 Glenjamin: ,(doto "1" (Integer/valueOf))

4:02 clojurebot: "1"

4:03 Glenjamin: not the best example, but i couldn't think of any mutating static methods

4:05 bracki: I'm trying to call a builder...

4:06 https://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/Mysql.scala#L95

4:07 Glenjamin: oh, that's just (doto (Mysql/withCredentials "user" "pass") (.withDatabase "db") (.newRichClient "blah"))

4:07 i think

4:07 the first call is static, the rest operate on the return value

4:08 bracki: Ah, OK. Got that mixed up... Thanks

4:08 Glenjamin: assuming that they all return this, otherwise you might need ->

4:09 clgv: Glenjamin: they do not need to return anything for usage with "doto"

4:10 ,(seq (doto (java.util.LinkedList.) (.add 1) (.add 3) (.add 7)))

4:10 clojurebot: (1 3 7)

4:11 clgv: you need them to return the modified object if you want to use `->`

4:39 lee_: Hello I want to know how the html content in to string (actually i am using ckeditor to write the question fo next line it will show <p> on the database how i am remove these html elements) so that i am getting the question according the my format

4:41 Hello I want to know how the html content converting in to string (actually i am using ckeditor to write the question fo next line it will show <p> on the database how i am remove these html elements) so that i am getting the question according the my format means in next line . at that time it will come in a single line

4:45 maxthoursie: lee_: sorry I'm not able to understand your question

4:46 wink: me neither

4:47 Glenjamin: clgv: good point, i meant in the context of a fluent method chain - if they don't return `this` for chaining, doto won't work either

4:47 so actually, bracki -> is the correct form to use to call a fluent method chain

4:48 doto may or may not work, but -> should always work

4:48 clgv: Glenjamin: doto works always for side effects no matter what the methods/functions return

4:48 Glenjamin: clgv: yes, but it's unclear if https://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/Mysql.scala#L93 is side-effecting or not

4:49 lee_: <maxthoursie> i am using ckeditor in my web-app i enter the string in it . but this string display in a single line but i want to show that in a multiple line

4:49 clgv: Glenjamin: well that looks like chaining in scala so I'd use "->" in clojure

4:50 maxthoursie: lee_: you want to break a line into multiple lines? What do you want to break on?

4:50 Glenjamin: yeah, the original question was about doto, which threw me off :)

4:51 lee_: yes

4:52 <maxthoursie> description of content

4:52 <maxthoursie> i am using split it not work properly

4:53 maxthoursie: lee_: could you show what you use now?

4:55 lee_: <maxthoursie> ckeditor plugin in js file and from where i enter the data is myapp.routes.example and where i want to display is myapp.routes.ex2

4:57 ddellacosta: lee_: give us a gist/refheap/etc. dump of the relevant code and we can help you. As it is there is too little information.

5:03 lee_: <maxthoursie> my html page is cont.html where i put my ckeditor .The myapp.routes.ex1111 render this cont.html page i filled the info in ckeditor and submit it another file is in myapp.routesex22222where i want to display that info , and i want to display the info in a proper format mmean it comes in a line but it come with a <p> info </p> which is not right

5:05 szymanowski: is there any hack to allow :refer :all in cljs?

5:25 maxthoursie: lee_: sorry I really don't follow you, could you post some code in a gist?

5:28 shadow_prince: Hi there! Can't reaize how to implement inputstream on clojure. I tried with proxy, but read method dont return result, but accept veriable, that needed to be written in. Its not mutable, so I can't assign it. How can I workaround it?

5:31 phillord: If I open a new Clojure file in Emacs, cider-jack-in and cause an error I get a cute stack trace, centered and in lots of colours. If I do the same thing in a leiningen project, I get a single coloured stack trace left-justified. Anyone know why the difference and how to get the cute stack trace in a leiningen project?

5:35 bracki: What's the best way to track down ClassCastExceptions when interop'ing w/ Java?

5:38 lee_: Actually i want parsing the string, i want my string is treat as in html format

5:40 maxthoursie: phillord: I believe that transformation is done inside emacs, so I don't think there's a way

5:41 phillord: ah -- so why is it openly happening when I am not using a lein project?

5:42 maxthoursie: phillord: You don't get that with lein projects inside emacs?

5:42 * phillord shakes his head

5:42 phillord: I get two totally different output formats

5:42 maxthoursie: phillord: ah, reread your first message.

5:42 All I can say is that it works here

5:42 phillord: ah

5:43 that's interesting, so maybe I have screwed something up somewhere with either leiningen or with my cider config

5:43 maxthoursie: I get colored stacktraces for leiningen projects inside emacs

5:43 any hint in the *messages* buffer?

5:44 phillord: no

5:44 nothing at all -- I only discovered that it wasn't working in lein a couple of days ago, when I found that it was working outside

5:50 where is your clojure mode coming from?

5:50 sorry, mean cider

5:56 martinklepsch: I'm trying to setup background processing with carmine but get a null pointer exception when running the most basic example from the readme: https://www.refheap.com/85286

5:57 maxthoursie: phillord: I have cider 0.5.0 iirc

5:57 phillord: installed with package-install

6:00 phillord: hmmm

6:00 same for me

6:00 well, AFAICT, it's not emacs doing it -- emacs is just interpreting the ANSI colour symbols

6:00 so, I am guesing lein isn't doing that

6:02 martinklepsch: anyone an idea why carmine could be failing in that simple case?

6:07 I was missing the connection macro in front: (wcar* ... )

6:17 I'm trying to start the carmine worker like so now: (wcar* (car-mq/start my-worker))

6:18 but (car-mq/queue-status nil "index-queue") doesn't put any messages in :done

6:21 anyone used the worker part of carmine?

6:33 io__: i want to automate bulk downloading of files(i.e. PDF) from a webpage via imacros firefox addon, i dont know how to make it happen? can anyone help?

6:33 ssideris: which one is faster: core.match or matchure?

6:33 io__: wrong channel?

6:36 ambrosebs: ssideris: does matchure work with recur?

6:37 clgv: ssideris: you could take a characteristik example thats not too small and measure both via criterium

6:37 ssideris: ambrosebs: not sure, I was thinking of using it as an advanced code+destructuring

6:38 clgv: I probably will, but I thought to ask here in case it was common knowledge

6:39 ambrosebs: ssideris: core.match works fine with recur, matchure didn't play nicely.

6:39 might have changed

6:40 ssideris: ambrosebs: I'm not sure I follow, are you saying that if you use a matchure call within a loop/recur it doesn't behave as expected?

6:42 ambrosebs: IIRC using recur on the right hand side of a pattern doesn't work in some cases. search "matchure recur"

6:42 I've never used matchure

6:43 ssideris: ambrosebs: thanks, that's useful to know. it may not end up being a problem with me

6:44 ambrosebs: ssideris: maybe. performance == loop/recur in clojure :)

6:45 ssideris: we shall see, I think my use case is very simple :-)

6:46 ambrosebs: ssideris: disclosure: I worked on core.match

6:46 a long time ago :)

6:47 ssideris: ambrosebs: I know, I follow the mailing list ;-)

6:47 how's core.typed going?

6:52 ambrosebs: ssideris: kicking into gear

6:52 :)

6:52 ssideris: great!

7:19 bracki: Can anybody point to some documentation on how to interface with Scala, esp. Some/Option?

7:22 agarman: you have to use Scala like Java

7:23 with the problem that Scala libraries written & documented for Scala require you to use apply / unapply and know how Scala does default parameters

7:24 what Scala library are you using?

7:24 bracki: https://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/mysql/Value.scala

7:25 Trying to write a wrapper around finagle-mysql as an enhancement for https://github.com/jcrean/clj-finagle

7:25 agarman: for Clojure, treat None as Nil and just unwrap Some

7:25 if you're writing a wrapper

7:26 http://stackoverflow.com/questions/5839697/why-is-the-use-of-maybe-option-not-so-pervasive-in-clojure

7:27 bracki: agarman: Saw that already but TLDR ;)

7:29 agarman: summary is that Clojure doesn't have a Maybe Monad, Nil Punning works just fine in most cases

7:30 so dealing with Scala Option type write a function that unwraps Option

7:32 bracki: Thanks

8:36 AWizzArd: slightly OT: in Emacs/Cider I would like to add my own indentations for some functions. Any pointers?

8:37 justin_smith: M-: (apropos-variable ".*lisp.*indent.*")

8:37 this works for other things too, just change the regex :)

8:38 instead of M-: you can use M-x ielm or hit C-j or C-M-X in the appropraite place in the *scratch* buffer

8:40 AWizzArd: justin_smith: interestingly when I grep for “reify” or “proxy” in my cider (elpa) installation I find nothing. It seems it isn’t defined there how to indent those.

8:41 justin_smith: ah okay, because this is done in clojure-mode. All clear, thanks.

8:41 justin_smith: AWizzArd: they are elisp vars, you don't reify them, you just use setq to change them

8:41 they are part of lisp mode, which is the parent of clojure mode

8:42 the clean way to do it would be to add-hook on clojure-mode-hook to set those variables (iirc they are buffer local so can be set per file)

8:42 also, expect your codebase to end up all messed up if anyone edits code with other settings :P

8:43 for values of "all messed up" = "inconsistent indentation" of course

8:43 AWizzArd: justin_smith: I didn’t plan to call reify in emacs lisp :) Just was searching where reify was defined for Clojure.

8:43 justin_smith: I don't see where reify would even come in?

8:45 AWizzArd: https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L957

8:49 justin_smith: ahh so you want to change the rules for indenting reify?

8:49 AWizzArd: justin_smith: wanted to see examples for complex cases, such as reify or deftype. So I can play with indentation for Om.

8:50 justin_smith: it looks like the complex rules are for proxy, or deftype or defrecord (relatively complex)

8:51 AWizzArd: yes

8:51 justin_smith: (describe-function #'put)

8:51 maxthoursie: I heard someone implementing a clojure mode for their editor complaining about the complex, irregular indenting of clojure code

8:52 I do find my self expressing much more with whitespace in lisp compared to other langs

8:52 justin_smith: AWizzArd: if you run that code I just posted in emacs, you will see how put works - it is assoc where you can assoc onto any symbol, and lookup is slow

8:53 maxthoursie: I think most of the clojure indent customs are just derived from emacs' defaults for lisp

8:54 AWizzArd: of course the other difference from assoc is it mutates the store :)

8:56 maxthoursie: justin_smith: that's probably true. It's all emacs's fault :)

8:56 justin_smith: maxthoursie: I think that here emacs is a proxy for centuries of lisp tradition

8:56 for values of century ~= 50 years

8:57 maxthoursie: justin_smith: right

9:01 clgv: ident everything with 2 spaces is probably the easiest identation rule ;)

9:14 phillord: has anyone got any ideas why stacktraces only colorize in Emacs when I am *not* in a lein project -- it works fine with a raw clojure file, but not at all with a file that is part of a project

9:14 mdrogalis: phillord: I noticed the same thing, but I never found the pattern.

9:14 phillord: I asked earlier, and I know that it is not affecting others

9:15 AFAICT, the colour comes from the middleware somewhere!

9:15 mdrogalis: Heh.

9:16 phillord: But I've tried, with an emacs -q, I've just recreated my .lein, and on a newly created lein project with nothing in it. Tried debugging -- all the call backs make it hard, but still can't see it.

9:17 it's a shame, because it's quite cute -- I only realised it did it at all yesterday

9:17 mdrogalis: It's more like a pleasant surprise when I see the colors. :P Only happens once in a while, but when it does - I'm pleased.

9:17 phillord: they definately help

9:18 I mean, it's almost a pleasure to have your code crash with colours on, don't you think?

9:19 mdrogalis: Haha, yes.

9:19 How angry can you really be?

9:20 phillord: perhaps, I should give in -- I mean, if I actually get the colours all the time, my code quality will probably drop, just so I can see more.

9:21 mdrogalis: Haha.

9:39 liviu10: what's the advantage of using a semaphore over a monitor

9:42 mikerod: semaphore sounds cooler :P

9:43 joking, but a I think http://stackoverflow.com/questions/7335950/semaphore-vs-monitors-whats-the-difference explains it reasonably

9:52 michaelr525: hi

9:53 in emacs-live is there a "find references" for functions?

9:53 or other symbols

9:54 AWizzArd: amalloy_: yes, that could make sense, to move this all into the guard.

9:56 jcromartie: compojure style question: I keep mixing up different ways of connecting routes and params to handlers

9:58 https://gist.github.com/jcromartie/d4b6d752e1d001de1724

9:59 Is there any good example out there of a good balance?

9:59 sometimes I feel like I get way too much logic going on in the (GET …) body etc.

10:04 sveri: hi, lets say I have a list of maps like this: ({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }) and want that list to be sorted after the value of a key in the map, is there a function available in clojure or do I have to write it myself?

10:05 mdrogalis: ,(doc sort-by)

10:05 clojurebot: "([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."

10:05 bbloom: sveri: can you give your expected output for that input?

10:06 sveri: bbloom: ({;key 1 :key2 "f" } {:key :key2 "fsdf" } {:key 3 :key2 "3" }) if I sort it after the value of :key

10:06 mdrogalis: ok, so I have to make use of sort-by, thank you :-)

10:07 bbloom: ,(sort-by :key '({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }))

10:07 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:07 bbloom: ,(sort-by :key '({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" })))

10:07 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:07 bbloom: ,(sort-by :key '({key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }))

10:07 clojurebot: #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>

10:07 bbloom: sheesh

10:07 ,({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" })

10:07 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:07 bbloom: ,(sort-by '({key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" }))

10:07 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/sort-by>

10:07 bbloom: ,(sort-by :key '({:key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" }))

10:07 clojurebot: ({:key 1, :key2 "f"} {:key 3, :key2 "3"} {:key 4, :key2 "fsdf"})

10:07 bbloom: ok finally fixed up that syntax lol

10:08 sveri: bbloom: thanks a lot, I didnt know it was that easy

10:08 again I was thinking to much around the corner

10:48 TimMc: clojurebot: You can't spell REPL without EPL.

10:48 clojurebot: Cool story bro.

10:49 akazlou: what is the idiomatic clojure way of iterating with accumulating the result: 1. using loop/recur with accumulator as one of the loop binding or 2. for and filter the result after?

10:49 bbloom: akazlou: reduce

10:50 ,(reduce + 0 [1 3 5])

10:50 clojurebot: 9

10:50 TimMc: loop is better if you are accumulating or tracking multiple bits of "state".

10:51 (You can still do it with reduce, but it can be harder to read.)

10:53 akazlou: no reduce is not what I want in my context, for example, iterating over vec of vecs, and do something on each of the element, and either return something or nil for example, if the data satisfies the requirements, I could use loop and put piece of data into the accumulator and return it when no more recur, or "for" with [nil <piece of data> ..] and then do filter for all, but not nil

10:55 bbloom: akazlou: ah, ok, there's two primary patterns for that

10:55 1) is use mapcat

10:55 2) use loop or reduce w/ a sequence state variable, return that at the end

10:56 example: ##(mapcat (fn [x] (when (odd? x) [x x])) [1 2 3 4 5])

10:56 lazybot: ⇒ (1 1 3 3 5 5)

10:56 bbloom: the idea is you just wrap your result in [] or if there is no result, you return nil

10:57 alternatively: ##(reduce conj [] (range 5))

10:57 lazybot: ⇒ [0 1 2 3 4]

10:58 bbloom: and you can do that with a state variable too: ##(reduce (fn [[i v] x] [(inc i) (conj v x)]) [0 []] (range 5))

10:58 lazybot: ⇒ [5 [0 1 2 3 4]]

10:58 bbloom: i ignore the state, but show how to thread it through

10:58 or just write an explicit loo

10:58 p

10:58 akazlou: that answer it?

11:03 arrdem: ,(/ 1000 8)

11:03 clojurebot: 125

11:03 akazlou: I guess yes, nice examples, thank you. My usage pattern so far to use loop, will try mapcat for the new tasks and see how it fits, maybe it is better than loop-s I've been writing before

11:04 arrdem: ,(* 125 (/ 100 3))

11:04 clojurebot: 12500/3

11:04 arrdem: ,(double (* 125 (/ 100 3)))

11:04 clojurebot: 4166.666666666667

11:04 akazlou: reduce with the state is also nice example, thanks

11:14 clgv: ,(* 125 (/ 100.0 3))

11:14 clojurebot: 4166.666666666667

11:17 justin_smith: I'm working on my java skills as a portfolio building / skill building thing, and I gotta say you can do some nifty things with java 8 type inference and lambdas (it's no clojure or haskell to be sure, but compared to vanilla java it is awesome)

11:18 I predict a clojure fork or rewrite once java 8 becomes a reasonable expectation (or at least hope for one)

11:19 jvm 1.8 of course, is what I mean there

11:20 bbloom: justin_smith: what would be the benefit of such a fork or rewrite?

11:22 justin_smith: bbloom: now methods have a first class syntax

11:23 well - I wonder if it is just a syntax or a change in jvm actually

11:23 bbloom: justin_smith: i'm pretty sure it's just syntax....

11:23 justin_smith: oh, don't mind me then :)

11:23 bbloom: there's no reason for anybody to ever write another clojure in java again

11:23 justin_smith: OK

11:23 arrdem: justin_smith: the issue with a project like that is that for the most part Clojure code is very tricky to type 'cause we use structured maps everywhere. I've toyed with the idea of using core.typed to do type introduction on the basis of map structures but it's nontrivial.

11:23 justin_smith: bbloom: maybe the features were deceptive

11:24 llasram: It might prompt adding a nicer method->IFn syntax

11:25 justin_smith: yeah, in java 8 you can pass Class::method as an arg to a method

11:25 seangrove: I wish someone would do a proper clojure-in-clojure, based of some solid research

11:25 justin_smith: and the method then calls that method on the args it would like etc.

11:25 seangrove: Make certain parts specifiable...

11:25 I don't know, kind of an 'extensible clojure'

11:25 arrdem: what on earth does that mean....

11:25 * seangrove sighs, gets back to his world of kludges

11:25 bbloom: haha

11:26 it's a P2 project, but it's not stalled :-P

11:26 seangrove: arrdem: Just the mutterings of a madman

11:26 arrdem: seangrove: we're all mad here...

11:27 llasram: At some point Clojure needs to learn about the Java 8 function interfaces. And decide what to with IFn wrt them

11:27 justin_smith: llasram: much better put than my blabbering :)

11:27 (inc llasram)

11:27 lazybot: ⇒ 23

11:28 justin_smith: http://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html

11:28 for example the Function interface has a compose method, etc.

11:29 maybe that's an ugly part of clojure that we don't want to revisit, but maybe there is potential in utilizing or integrating that stuff

11:29 llasram: Just making AFn implement more interfaces like it already does with e.g. Runnable would allow using Clojure functions in Java 8 functional APIs, but not vice versa

11:30 justin_smith: llasram: yeah, I am still puzzling this set of classes / apis / features out, but that sounds about right

11:33 arrdem: tbaldridge: if only so I can start coalating my notes, is the plan (if one exists) for my GSoC compiler to be a tools.emitter.* project or is this a point of discression?

11:33 llasram: justin_smith: Silly Java... Why couldn't it just stay all boring and OO/imperative?

11:34 arrdem: llasram: because people like us want to build nice fuctional systems atop the JVM...

11:39 justin_smith: if nothing else this seems like a chance to make cleaner and more succinct code in the .java files in clojure.core, if we ever wanted that (acknowledging of course that wanting a fully self hosting clojure is a thing, and long term they are incompatible)

11:46 melipone: hello! which debugging tool are you using in the REPL? I would like to get breakpoints.

11:50 coventry: melipone: There aren't very good tools for that. To get the data at a particular point of execution into the REPL, I often (def dbg (atom nil)) before the function in question then (reset! dbg interesting-expression), maybe followed by a throw, and re-run the program.

11:50 melipone: Then you can access to the data in @dbg.

11:52 There's also schmetterling, which will actually do a breakpoint with a repl in that execution context.

11:52 justin_smith: coventry: with the caveat that the breakpoint must be an exception (the two are kind of complected in schmetterling, but that may be inevitable)

11:53 the problem with schmetterling: if you provoke an exception in the context repl, everything is hosed (maybe we can fix that soon...)

11:54 roelof: why doe sthis (http://pastebin.com/eU0zWZND

11:55 melipone: coventry: what's @dbg?

11:55 roelof: not work well on this part : (toggle #{:a :b :c} :a)

11:55 coventry: melipone: Just dereferencing the atom you put the data in.

11:56 ,(do (def dbg (atom nil)) (dotimes [i n ] (swap! dbg conj i)) @dbg)

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

11:56 edlothiol: roelof: I think you're missing an if

11:56 coventry: ,(do (def dbg (atom nil)) (dotimes [i 10 ] (swap! dbg conj i)) @dbg)

11:56 clojurebot: (9 8 7 6 5 ...)

11:57 kenrestivo: meliphone: i use tools.trace

11:57 roelof: oke, I thought on contains? that would not be needed because the outcome is true or false

11:57 coventry: tools.trace is useful for simple data, but often inadequate if you want to get a reproducible test case in the repl.

11:58 melipone: coventry: oh, but I want to stop the program and maybe rerun it. how do you do that with a throw?

11:59 roelof: edlothiol: but you are right. With a if it works fine . But as I said I always thought on contains? you do not need a if

11:59 melipone: kenrestivo: does tools.trace has breakpoints?

12:00 kenrestivo: not AFAIK.

12:00 coventry: melipone: Stick all the args to the function you're studying into the debug repl, and (apply function @dbg) in the repl. It's definitely not as nice as a breakpoint.

12:02 edlothiol: roelof: well... I don't know how you got that idea, you can't just leave out ifs

12:04 roelof: edlothiol: I did it here :(or (apply <= a-seq) (apply >= a-seq))) and it worked well. I see false and true when I expected it

12:04 bbloom: roelof: you didn't leave out an if... or has an if in it

12:04 (doc or)

12:04 clojurebot: "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. (or) returns nil."

12:04 bbloom: you can go look at (source or) too

12:05 roelof: bbloom: clojure still suprise me

12:05 coventry: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L813

12:08 gmc__: I’m trying to run through the basic example in Lobos, but I keep getting the following error: “Unable to resolve symbol: *db* in this context, compiling:(lobos/connectivity/jdbc_2.clj:14:1)”

12:08 Anyone seen that before?

12:08 roelof: Another question I have to look if a seq has duplicates. Can I count each element somehow ?

12:09 coventry: (doc frequencies)

12:09 clojurebot: "([coll]); Returns a map from distinct items in coll to the number of times they appear."

12:09 mdeboard: oh nice

12:09 wow

12:09 that's handy.

12:12 roelof: coventry: that not what Im looking for. I have to make a form which does this : (contains-duplicates? [1 1 2 3 -40]) ;=> true

12:12 and I just learned to use count

12:12 hmm, maybe use apply or map

12:13 coventry: Something like (defn contains-duplicates? [seq] (< 1 (apply max (vals (frequencies seq))))), maybe.

12:13 That's inefficient compared to stopping when you hit the first duplicate though, I suppose.

12:16 Also, that'll throw if seq is empty.

12:23 roelof: I thought this (http://pastebin.com/chd9JyrN) would work but I see this error message : ompilerException java.lang.IllegalArgumentException: let requires a vector for its binding in structured-data:90, compiling:(/home/roelof/clojure/structured-data/src/structured_data.clj:90:3)

12:23 maybe clojure is not my language

12:23 akazlou: I'm trying to understand, is it against the Clojure philosophy that some of the funcs work correctly when only applying to a vector, for example, like update-in or assoc, and similar, so is it common to transform the input to vector first (using vec) and then apply the before-mentioned functions

12:24 against I mean, that lots of functions don't care whether the input is seq, list or vec

12:24 or even map

12:24 bbloom: roelof: have you picked up a book on it?

12:25 (doc let)

12:25 clojurebot: "([bindings & body]); binding => binding-form init-expr Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein."

12:25 bbloom: roelof: maybe read this & the rest of the page: http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)

12:26 roelof: bbloom: yep, the course is providing info and Im reading clojure for the brave

12:29 bbloom: roelof: is this an in-person course? or online?

12:30 roelof: bbloom: its a online course . Here is the page Im working on : http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html

12:30 bbloom: roelof: all of those examples clearly show how let bindings work, so i'm not sure where you got the idea that the vector brackets were optional

12:31 roelof: bbloom: sorry. I miss you now. what do you mean ?

12:31 bbloom: nevermind

12:36 arrdem: deployment jars are just the source code packed, right? clojure deps don't ship as just .class files in a .jar.

12:36 technomancy: arrdem: you can put .class files in a jar, but then you're a bad person who has betrayed all the trust your friends have put in you

12:38 arrdem: technomancy: good. that's what I thought.

12:38 felixflores: Hey guys I made a visual map of :db.part/db for datomic

12:38 https://raw.githubusercontent.com/felixflores/datomic_explanation/master/doc/figures/render/entity_zero.png

12:38 what do you guys think?

12:38 https://github.com/felixflores/datomic_explanation/blob/master/doc/figures/render/entity_zero.pdf

12:38 teslanick: bigger?

12:38 felixflores: here's the pdf

12:38 roelof: I have now this : http://pastebin.com/vAfwv7r4 and see this error : ArityException Wrong number of args (5) passed to: structured-data$contains-duplicates-QMARK-$element clojure.lang.AFn.throwArity (AFn.java:437)

12:38 teslanick: better!

12:39 roelof: I think somewhere along the line I lost track of things

12:41 felixflores: What do you guys think?

12:48 akazlou: nvm, I found mapv

12:49 PigDude: justin_smith: thanks for the advice about Calendar, but if i'm using a java/clj-specific API i'll go whole hog w/ Joda/clj-time on that side of things. of course i say that now, the world of java libraries etc is still very new to me :) so plenty of time to reconsider

12:59 boblarrick: Does anyone know of a Om tutorial that demonstrates submitting a simple form?

13:01 coventry: boblarrick: Submitting a form to a server is kind of orthogonal to the concerns om addresses. Do you mean updating the client view based on the form data, independent of server response? Otherwise, you just set a callback which sends the data to the server.

13:01 tnks: not to start a flame war of personal preference, but is there a popular number of spaces for indentation (guessing either 2 or 4)

13:01 I have to set my editor to something, and thought I'd ask first.

13:01 manutter: I see a lot of code with 2-space indents

13:01 justin_smith: tnks: there is no real controversy - two spaces

13:02 coventry: Die in a fire you heretic.

13:02 justin_smith: I've never even seen an argument about it

13:02 teslanick: Also, in Clojure, indentation is typically all over the place ya?

13:02 technomancy: tnks: special forms indent by two, regular function calls indent subsequent lines to the column of their first argument.

13:02 tnks: technomancy: okay.

13:02 manutter: true that

13:02 technomancy: it's such a relief to be free of formatting wars

13:03 so we can focus on more important things like editor wars

13:03 justin_smith: technomancy: even that is unbalanced enough that the "editor war" is more like a state of occupation

13:03 technomancy: hehe

13:03 bbloom: shhh don't mention cond

13:04 technomancy: justin_smith: it's a peacekeeping operation dammit

13:04 PigDude: justin_smith: i see a fair amount of clj code that writes out hashes like js objects (new line for each key, indented two spaces)

13:04 clgv: coventry: :P

13:04 PigDude: justin_smith: my editor doesn't like that end neither do i :P

13:04 clgv: technomancy: did the emacs operating system finally get a decent editor? ;)

13:04 PigDude: like in the project.clj example on https://github.com/emezeske/lein-cljsbuild

13:05 justin_smith: PigDude: I'm just saying that things like that are seen as abberations - it isn't like we have a significant disagreement about which way that should be (that I've seen at least)

13:06 boblarrick: coventry: Yeah I'm just having some trouble extracting what I need from the Om wiki

13:06 PigDude: justin_smith: yea, i like that i can just =% in vi and know it is right, or if it's wrong it reveals misordered ) quickly :)

13:07 boblarrick: I have a server that accepts GET requests + query params and responds the way I want

13:07 and an Om front end that works with a hard-coded URL

13:07 trying to get to place where the user can submit a form in place of the hardcoded URL

13:08 was hoping there was a example app that demonstrated a simple form

13:15 coventry: boblarrick: Don't know any simple public examples, sorry

13:20 mordocai: Hey, could use some help. I'm going through "The Joy of Clojure" 2nd edition(it is an early access) and an example isn't working. Take a look https://www.refheap.com/85295? I'm getting and errors that the argument list isn't a vector, which seems valid, but I don't see how to make the example work completely.

13:20 I'm getting errors*

13:23 justin_smith: mordocai: weird, I get no such error in my repl

13:23 cbp: mordocai: there doesnt seem to be any error with that

13:23 PigDude: i think he needs to include the code using this

13:23 justin_smith: ,(defn neighbors ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx)) ([deltas size yx] (filter (fn [new-yx] (every? #(< -1 % size) new-yx)) (map #(vec (map + yx %)) deltas))))

13:23 clojurebot: #'sandbox/neighbors

13:24 cbp: (neighbors 10 [2 2])

13:24 ,(neighbors 10 [2 2])

13:24 clojurebot: ([1 2] [3 2] [2 1] [2 3])

13:24 justin_smith: looks good?

13:24 mordocai: PigDude: I'm getting a compiler error, nothing is using it

13:25 I'm using cider-eval-buffer, i'll try using lein repl directly

13:26 PigDude: oh, huh, yea, runs fine here

13:27 cbp: you must not be pasting the same thing on your repl

13:29 mordocai: Okay, so lein repl doesn't work either. I'm using clojure 1.6.0 with lein 2.3.4 on java 1.80_05. I'm not pasting into repl, it is in a file in my project. I'm wondering if there error is somewhere else and i'm not realizing it.

13:31 llasram: mordocai: Maybe paste up the whole file?

13:32 mordocai: llasram: Yeah, it's collections.clj here: https://github.com/mordocai/learning-clojure/blob/master/src/learning/collections.clj.

13:32 If you clone that repo it is a full project

13:32 cbp: mordocai: the first defn is wrong

13:33 mordocai: oh... duh...

13:33 I had an empty vector there before. Thanks

13:33 The error was saying 1:26 which confused me, if it had said line 2 I might have figured it out myself lol

13:35 PigDude: the only way i know how to zip a list in clojuer is (map vec colls). but this is not lazy so it means i can't use it w/ my lazy structures. how do you turn elements from two lazy collections into [c1 c2] [c1-1 c2-2] ... ?

13:35 mordocai: By the way, so far the community in this channel has been great. Kudos to you guys.

13:36 cbp: PigDude: it is lazy due to map

13:36 llasram: PigDude: Do you mean (map vector coll1 coll2) ?

13:37 PigDude: cbp: then in practice i'm geting it wrong

13:37 ,(take 10 (map vec [(iterate inc 1) (iterate inc 2)]))

13:37 (never ends)

13:37 clojurebot: #<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>

13:37 llasram: ,(take 10 (map vector (iterate inc 1) (iterate inc 2)))

13:37 clojurebot: ([1 2] [2 3] [3 4] [4 5] [5 6] ...)

13:37 cbp: PigDude: use itlike llasram

13:37 PigDude: (map vector) not (map vec0?

13:38 ok

13:38 llasram: The version you posted just turns each collection separately into a vector

13:39 cbp: PigDude: also the first one you pasted is lazy, though wrong

13:40 to check if its lazy you can just put it in a var and it must return instantly

13:40 (def x lazy-operation)

13:40 PigDude: hm ok

13:41 cbp: the way youre doing it makes the repl print it which realizes it

13:41 llasram: ,(map vec [(range 0 3) (range 1 4)])

13:41 clojurebot: ([0 1 2] [1 2 3])

13:42 PigDude: ah ok cbp

13:42 coventry: boblarrick: session has a rather involved example, but it might give you some ideas about how to get the data out of the form and to the server. https://github.com/kovasb/session/blob/master/src/cljs/session/editor.cljs#L39

13:42 PigDude: that's why i include `take 10` in those sorts of tests

13:43 cbp: you can also do (type lazy-operation)

13:43 although im not sure checking if things are lazy is of any help

13:43 llasram: PigDude, cbp: the real problem is that the resulting lazy sequence only has 2 items, each consisting of the result of producing a concrete vector from an infinite lazy sequence

13:44 mordocai: I learn so much just by reading this channel...

13:44 PigDude: do you have a process for breaking down large functions?

13:45 cbp: Large as in big number of lines?

13:45 if they're pure functions you can just break them wherever you want :-)

13:45 PigDude: i have a really ugly 40-line function w/ several ifs, lets, etc. but the loop/recur requires maintaining some state, and each branch in the decision tree must do the same things to maintain this state ... that is the chief culprit here

13:46 i just don't see how to break apart a loop that requires more than one piece of state, short of doing some really ugly reduce call w/ some ad-hoc acc structure

13:46 jcromartie: PigDude: can you share it?

13:46 PigDude: sheepishly

13:46 jcromartie: don't be ashamed

13:46 PigDude: https://www.refheap.com/a4ac1d207818bd7cf31c3f7e6

13:47 llasram: PigDude: that's generally what I do (reduce w/ a vector of state), and is usually fine

13:47 PigDude: llasram: hm ok ..

13:48 one insight is that the index is the same in each branch but the first. i was reluctant to do the `assoc' at a higher level though because it's nice to have it be local to each branch

13:48 jcromartie: PigDude: one basic tactic is to pull out the common parts (in this case being the recur from several places) and parameterize it

13:49 PigDude: so you could probably recur from one place after calculating all of the new values

13:49 bbloom: PigDude: you may consider replacing your arg lists with a map

13:49 and breaking the various branches down in to functions that operate on that map

13:50 PigDude: jcromartie: is this akin to doing 'ret = ...' 'return ret'?

13:50 jcromartie: or is there a larger discussion around where to put tail calls?

13:51 jcromartie: that's good advice, thanks

13:51 jcromartie: also, a bunch of ifs usually turn into a cond nicely

13:51 bbloom: PigDude: generally, i think this function is simply doing too much

13:51 jcromartie: and partial application could help shorten some of these things

13:51 bbloom: i'd break it in to a lazy seq of the data to write & then the writing logic

13:51 that will eliminate all your do-blocks

13:51 PigDude: bbloom: yea, it is maintaining the log entries and also the index, but the two happen at the same time ... this is not my strength

13:52 jcromartie: i.e. you are always calling write-interval with the same firs three args

13:52 so you could say (let [write (partial write-interval store id iter-size)] ...)

13:52 bbloom: PigDude: see if you can use lazy-seq over lexical closures to create a sequence of operations to perform

13:53 then you can just doseq over that & call write in a tight loop

13:53 PigDude: jcromartie: interesting, i didn't know that was common, it looks good

13:54 jcromartie: also destructuring

13:54 (loop [[iter-size & remaining] intervals

13:54 PigDude: bbloom: heh, i wouldn't understand how that worked though :)

13:54 jcromartie: then lose the (let [iter-size… and replace (rest unprocessed) with remaining

13:54 bbloom: PigDude: sure you could

13:54 PigDude: jcromartie: oh ok! so that's like [H|T] in erlang

13:55 bbloom: PigDude: you're doing data transformation & side effecting in the same code. unless you need to do that for (meausred!) perf reasons, you should always try to separate those out. you'll get shorter/cleaner code that is easier to debug

13:55 mordocai: So, i have a theory, but can someone explain to me how the % works in ,(take 10 (map vector (iterate inc 1) (iterate inc 2)))

13:55 Wrong paste

13:55 ,(map #(map + [5 3] %) [[-1 0] [1 0] [0 -1] [0 1]])

13:55 clojurebot: ((4 3) (6 3) (5 2) (5 4))

13:55 PigDude: jcromartie: but this function only recurs from two of the branches

13:56 bbloom: PigDude: in this case, you'd do something like (defn log-entries [args...] (let [rec (fn [state] ...)] (lazy-seq (rec initial-state)))

13:56 PigDude: jcromartie: so i can't just put the recur at the bottom ... see the branch ordering, this is what i'm having trouble w/ too. and now i'm overwhelmed :( let me take a breath

13:56 jcromartie: yeah :(

13:56 bbloom: well i guess you need (fn rec [... so it can make the recursive call :-P

13:56 lemonodor: anyone using coveralls.io & clojure (with lein-cloverage)? I’ve followed the steps at http://blog.bfontaine.net/2014/02/15/using-coveralls-with-clojure/ and it mostly works, but coveralls has trouble finding my source files: https://coveralls.io/files/195713441

13:56 bbloom: PigDude: if you use a lazy seq, you don't need to worry about tail position as much b/c the tail calls happen on the caller stack when the lazy seq is traversed

13:57 PigDude: bbloom: what you don't see at the top is that log entries are in increasing size, so it's very expensive to pull out an entry you don't need

13:57 bbloom: or to operate on one unnecessarily

13:57 bbloom: ok, i think i need to use lazy-seq to abstract this, i'll study it more now

13:58 bbloom: PigDude: i'm not sure what you mean by that. guessing from looking at this you only hit some external oracle for the fetch-index call

13:58 everything else seems output-only, no?

13:58 PigDude: bbloom: the way it actually works is by limiting key size, but to be space-efficient and correct it tries to fit as much as possible in a key

13:59 bbloom: the index itself is just stored in another key; it's meant to work on nything that stores keys and values

13:59 bbloom: so it's not write-only because keys get moved .. a problem in the design i'm working on, but w/ growing key size like that, i think you have to move keys

13:59 bbloom: PigDude: the result is nil, correct?

14:00 PigDude: bbloom: yep

14:00 seangrove: bbloom: Progressing on being able to quickly layout nested components http://dl.dropbox.com/u/412963/Screenshots/ek.png

14:00 bbloom: PigDude: it might be worth studying how Fipp uses mapcat-state such that this is the only "side effect" of the entire pretty printer: https://github.com/brandonbloom/fipp/blob/master/src/fipp/printer.clj#L215

14:01 PigDude: not saying that this code is perfect. i'd rather a "yield" like operator, but the trick of mapcat-state is pretty general & it's so much nicer to debug this code than something with interleaved effects

14:01 seangrove: more details?

14:02 PigDude: bbloom: thanks for the good code example!

14:03 seangrove: bbloom: This is composing look-less/layout-less components, and applying the style/layout separately. The screenshot is laid out via the extended/hacked ui-pass system

14:03 PigDude: bbloom: and don't worry, i write some pretty-ish functions too :) https://www.refheap.com/1b262e07aefa75a558d14b230

14:03 bbloom: seangrove: cool

14:03 PigDude: bbloom: (i'm sure that could be shortened too!)

14:05 cbp: mordocai: % is a placeholder for a variable in an anonymous function

14:06 mordocai: http://clojure.org/reader look there for anonymous functions

14:06 mordocai: Am I right in thinking that #(< -1 % size) is the same as (fn [item] (< -1 item size))?

14:06 cbp: yes

14:06 mordocai: Kk, that was what was confusing me. Either the book didn't explain it or I didn't grok it lol

14:07 cbp: joy of clojure isnt a beginners book

14:07 mordocai: Meh, it is close enough. That's the first thing so far that has confused me.

14:08 If I was new to programming too though...

14:10 stuartsierra: mordocai: a common mistake is #([:foo %]) which expands to (fn [x] ([:foo x]))

14:16 mordocai: stuartsierra: Would the correct version be #(vector :foo %)?

14:16 stuartsierra: mordocai: Yes, or just (fn [x] [:foo x])

14:18 bbloom: #(-> [:foo x])

14:18 :-P

14:18 stuartsierra: Oh no

14:18 Here we go again.

14:19 bbloom: haha

14:20 coventry: bbloom: Does t/each not call its argument when the value from mapcat-state is nil? The example at https://github.com/brandonbloom/transduce#usage could maybe use a little clarification.

14:22 bbloom: coventry: sorry, i'm not sure i follow what's not clear.... each calls its function on each element of the sequence resulting from the mapcat

14:22 coventry: each doesn't look at the state at all

14:22 coventry: each is just a function version of doseq

14:24 coventry: So in the case switch, :n returns [arg nil], :c returns [n (repeat n arg)], I guess the :c case is producing the "abcd" characters in the output, why doesn't [arg nil] produce some representation of nil?

14:24 Should probably just read the source.

14:25 bbloom: ,(print nil)

14:25 clojurebot: nil

14:25 bbloom: er rather:

14:25 ,(print-str nil)

14:25 clojurebot: "nil"

14:25 bbloom: er nevermind, i forgot what the example was

14:25 * bbloom looks

14:26 cespare: Is there a way to run a single clojure.test test?

14:26 technomancy: cespare: deftest macroexpands to a defn

14:26 bbloom: oh dur... coventry: it's b/c ##(apply mapcat (repeat 5 nil))

14:26 lazybot: ⇒ ()

14:26 bbloom: coventry: nil could just be []

14:26 you don't need the src to understand it

14:27 coventry: Oh, right. Thanks.

14:28 cespare: technomancy: what about fixtures?

14:29 technomancy: cespare: my understanding is you'd have to call the fixture function with the deftest as the arg

14:30 bbloom: coventry: i had forgotten the example so i thought you were talking about ##(str nil)

14:30 lazybot: ⇒ ""

14:31 coventry: bbloom: right, and I was reading mapcat-state as map-state.

14:38 It'd probably be clearer if you showed the output of map-state, then mapcat-state with print to show the idea of using it to separate the side-effect from the pure calculation.

14:38 bbloom: coventry: had you read mapcat-state correctly, would it have been clear? :-P

14:52 llasram: Has anyone done a persistent sorted set of unboxed longs?

14:54 hiredman: llasram: dunno, you could wrap https://github.com/ztellman/immutable-int-map as a set I suppose

14:55 llasram: hiredman: I was thinking of that... Also looks like the referenced original work includes sets

14:55 hiredman: I assume it stores keys as primitives

14:56 hyPiRion: llasram: do you need them to be mergeable? Otherwise I would guess judy arrays would be more performant

14:57 hiredman: performant or use less memory?

14:58 hyPiRion: Except hrm, not sure which operations you need on the set?

14:58 hiredman: oh, I am thinking of a patricia trees

14:58 or tries, whatever

14:59 llasram: hyPiRion: Yeah, merge-able. I'm trying to decide how far down the yak-shaving hole I want to go making a friendly HyperLogLog++ implementation

14:59 sm0ke: so i have this testing utility class which has changed over versions, of a library i am using. How do i test against different class versions? anything better than reflection here?

15:00 something clean and clever which can be done with lein pofiles may be?

15:02 noonian: sm0ke: that sounds doable, should just be able to put the different deps in different profiles and invoke lein with the correct one, you probably want the different deps + some common ones so i think lein has a syntax with the specific profile and a '+'

15:02 sm0ke: noonian: yes true, thats what i am already doing

15:03 hyPiRion: llasram: I'd guess hiredman's recommendation is the best then

15:03 sm0ke: but the problem is the same class which was called FooBar in profile :foo1.1 is FooBarBaz in profile :foo1.2

15:04 noonian: ick

15:04 sm0ke: so i need something like different test source paths itself

15:04 hurm even that is doable

15:04 hyPiRion: sm0ke: put the tests separately through test-paths in the profiles

15:04 noonian: yeah, which is also doable, but not nice because you basically need duplicate directory trees

15:05 sm0ke: hyPiRion: exactly my thoughts :D

15:05 noonian: i dont see any other way also

15:06 reflection is more ugly here

15:06 hyPiRion: sm0ke: you could maybe set the :default test selector in :test-selectors, although that wouldn't remove compile errors

15:07 noonian: or you could use env variables (or in project.clj profiles using environ) and have a macro that checks the env and inserts the correct class?

15:07 sm0ke: yea, also it would be too much work, excluding tests, or putting annotations

15:07 noonian: not nice at all

15:08 sm0ke: i guess duplicating same code namespaces according to profiles is better

15:09 so the default test path is everything under /test right? i need to fix it to something like /test/common in main profile

15:09 noonian: yeah, i'd probably go with that

15:09 sm0ke: and add /test/foo1.x in each profiles?

15:10 hyPiRion: yeah

15:10 that's the most evident I guess

15:10 sm0ke: thanks noonian hyPiRion

15:19 coventry: bbloom: Yeah, but I tend to misread a lot more when I'm looking at alien expressions of a calculation.

15:25 bbloom: coventry: the library is simple enough to read it its entirety in about 3 minutes, so i don't feel compelled to overdo the documentation :-P

15:42 dkinzer: fg

15:43 bbloom: ^c

16:17 gyim: Is there a Clojure library that makes it easy to trace a running multi-threaded application? For example, I want to know whether a function was called (on another thread), what argument it got, etc

16:18 when I have to do this I usually redefine the function in question, add some logging, etc - it works, but I wonder whether somebody made a lib for this

16:18 ambrosebs: gyim: seen tools.trace?

16:22 gyim: hmm, i checked it before, but i overlooked its (trace-ns) and (trace-vars) functions...

16:32 gfrederi`: reiddraper: have I bugged you about using seeds on individual trials instead of larger runs?

16:33 gfredericks: I think I remember doing that

16:34 * gfredericks is hacking on test.check again

16:38 gyim: anything more versatile than tools.trace? For example, I might want to measure invocations/secs for a function, or write a log only if a condition holds on the function arguments

16:39 justin_smith: gyim: well, you can get a lot of info from a good jvm profiler

16:39 gyim: no, my primary focus is live debugging

16:40 for example, i see null pointer exceptions in the logs => i want to check what input the function got

16:41 i am thinking about writing a small lib for these things, but if such a tool exists, it's even better...

16:52 mikerod: I'm getting the infamous "clojure.lang.Compiler$CompilerException: java.lang.ClassFormatError: Invalid method Code length 248014 in class file <fname>" . For some reason I was under the impression that this was only an issue with AOT-compilation. I suppose not?

16:53 I see it comes from a "<ns-path>s$fn__15616$fn__15617" sort of class name.

16:53 This is with a macro expanding into a large fn-body.

16:54 So I guess this has to get a class generated to represent it, and therefor can overflow the method size limits. Regardless of AOT vs not.

16:54 amalloy: mikerod: right. every function definition is a class definition

16:54 whether those ever appear on disk dosen't matter; the classes still have to follow the jvm spec

16:55 mikerod: amalloy: I've been able to "dodge" the issue of large literals by not AOT'ing a ns before. So I guess some paths are different in regards to this.

16:56 I guess I find it tricky to see where the lines are really drawn.

16:57 I understand the the fn is getting compiled into a JVM-spec class. I'm assuming the fn-body ends up occumpying a single method body to some degree.

16:58 amalloy: yes, each arity is exactly one method body

16:59 mikerod: amalloy: So in the case of large data literals, there is a difference between AOT vs non-AOT though? This sort of relates to a really old post https://groups.google.com/forum/m/#!topic/clojure/5VZDSjgt6BQ.

17:01 amalloy: seems plausible. i don't know a lot about that

17:01 mikerod: I've read up on this a bit before and inspected the Compiler some. It seems like it comes down to whether or not the code you are generating with the macro needs to be held in a class or not.

17:02 e.g. if I make a macro that generates a huge map, it doesn't need to be held as a class constant, if not AOT

17:03 However, if I do it in a fn-body, I'm curious if it now needs to be held in a constant.

17:03 These things are subtle.

17:17 jdkealy: anybody use the friend library and know how to handle sign-up? I can create a user in datomic, but don't know how to log the user in. Right now i'm redirecting to login after sign-up

17:19 sritchie: jdkealy: yeah, I can help

17:20 jdkealy: you have to make a new friend workflow that intercepts posts to the signup route

17:20 (and (= uri "/signup")

17:21 (= request-method :post))

17:21 (when (and (= uri "/signup")

17:21 (= request-method :post))

17:21 jdkealy: here's what I do

17:21 https://gist.github.com/sritchie/e7c6135aa7eab706544c

17:22 that's the workflow I made, rather

17:44 expez: (gdom/getChildren (gdom/getElement "queue")) <- why does this return an array when called with regular javascript, but in clojurescript (type...) returns #<function HTMLCollection() { [native code] }> ?

17:44 I tried mapping over this result and was surprised.

17:46 Is this even the recommended way to grab stuff out of the dom occasionally, or should I be using something like jayq?

17:47 nullptr: expez: that returns NodeList, which is considered "ArrayLike" in google closure speak

17:48 expez: !(Array | NodeList) <- what does this type notation for getChildren from the google api mean?

17:49 nullptr: it means it returns an array or a nodelist, and doesn't return null

17:49 expez: Is this their notation for either? And Chrome just happened to tansform a NodeList into an Array before I saw it in the console?

17:49 mmitchell: re. prismatic's schema -- anyone know if it's possible to have a coercer rename a key?

17:50 nullptr: expez: if you see the code it returns element.children when possible, but falls back to goog.array.filter for IE8

17:52 expez: nullptr: thanks. Is it common to use something like jayq, or do most clojurescript projects try to rely on the closure library as much as possible?

17:52 nullptr: as closure library is a superset of jquery (excluding third party libs) i would certainly advise not including jquery for the core functionality

17:52 it's much lighterweight to use the closure stuff given that its optimized for adv compilation

17:53 expez: everyone already has every version of jquery ever published on their computer it's connected to the internet :)

17:53 nullptr: even if it's in cache, it still has to parse/load it

17:54 if you do lots of dom selection and don't mind paying a slightly higher cost than goog.dom will impose there's always goog.dom.query

17:57 expez: hmm, can't find the api docs for that namespace

17:58 nullptr: it's under third_party in the actual closure-library source if that helps

18:05 martinklepsch: When I want to do upserts with elastisch do I need to use the native client or can I somehow do that using the rest client too?

18:27 bbloom: sometimes i forget just how hard it is to write a macro without having first written the code that the macro will expand to

18:27 i know for a fact i'm going to need a macro, so i start typing it... and fail hard... then i write it by hand 3 times, and the macro impl becomes obvious

18:27 * bbloom pounds on the side of his head

18:29 amalloy: bbloom: does having a concussion help with the macro writing?

18:29 bbloom: amalloy: only one way to find out

18:31 SegFaultAX: bbloom: I find it's usually easier to work backwards from the expanded form anyway.

18:31 Even if I know exactly how I want to write the macro.

18:38 bbloom: SegFaultAX: oh yeah, totally. which is why i'm beating my own head for skipping ahead prematurely :-P

18:47 programmancer: My IRC bot insists it saw the following raw message: " t o b 0 r k ... ..."

18:47 I can not possibly imagine this is a legal message according to the specs.

18:47 bbloom: sounds like somebody is trying *to b0rk* your parsing code

18:48 programmancer: Do networks generally follow the specs? Or do they consider it more of a general guide line?

18:48 They succeeded with flying colors.

18:48 Frozenlo`: err... what's the way to solve the 'NodeList is not iseqable' in cljs?

18:48 programmancer: I can change the parser, of course, but I wonder what else the networks may have in store for me.

18:48 I suspect they may be including line breaks in their MOTD.

18:52 They're supposed to end the line with \r\n, but I suppose they could be sending multiple lines separated by \n and then ending them in \r\n.

19:15 Glenjamin: i'm experimenting with the full form of (reducers/fold) - [combinef reducef coll], if my reducef doesn't support an arity-0 call i get an exception

19:15 but according to the docs, only combinef should be called with 0 args

19:16 could anyone point me at what i'm doing wrong?

19:23 amalloy: Glenjamin: could you paste a specific example?

19:26 Glenjamin: hrm, in trying to distil a reproducible case, it's started working...

19:27 amalloy: as is so often the case

19:27 Glenjamin: ah, no it hasn;t

19:28 although i think i have found the problem

19:28 seems to be a bug in immutable-int-map

19:40 yep, slight oversight when extending CollFold to the collection - https://github.com/ztellman/immutable-int-map/issues/2

19:43 although i'm struggling to think of an example where the combining function would return a different identity to the reducing function

19:49 amalloy: Glenjamin: that happens all the time, just like when you reduce and your initial value is of a different type than the list elements

19:50 Glenjamin: for the inner reduce to work, it has to know what the type of acc is in [acc x], but with fold acc is supplied by combinef

19:51 so when would (not= (combinef) (reducef))

19:57 amalloy: well, i guess at the moment i can't think of any. it's been two years since i really dealt with reducers

19:57 i'm pretty sure at the time i believed it made sense

19:57 have you read the stuff at http://clojure.org/reducers, Glenjamin?

19:58 Glenjamin: yeah, reading it again now

19:58 i think it makes sense that the combinef "owns" the collection to reduce into

19:59 but assuming you write a reduce, then expand into a fold - i think (combinef) and (reducef) will always be the same

20:00 i might post this on the mailing list, there must be a possible example :s

20:08 ah, got it

20:08 the reducing function can be polymorphic

20:09 and re-used with different folds

20:09 but the function producing the value has to decide what it's producing

20:54 toan: hi guys, i'm over confused by this bit of code.

20:54 > (reduce #(+ (* % 2) %2) 0 '(1 0 1 0 1 0) )

20:56 it returns the right bin to dec value, 48

20:57 dbasch: ,(reduce #(+ (* % 2) %2) 0 '(1 0 1 0 1 0) )

20:57 clojurebot: 42

20:59 toan: yeah, sorry 42

20:59 dbasch: btw, you don’t need the 0 before the list

20:59 toan: thx, maybe that maybe clearer for me

21:00 amalloy: unless he wants (bin2dec ()) to be 0 rather than an exception

21:00 toan: ah

21:00 amalloy: or, no, i guess it'd be 0 anyway

21:01 still, i don't think adding the explicit 0 as a starting-point is bad

21:01 dbasch: , (reduce #(+ (* %1 2) %2) '() )

21:01 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval55/fn--56>

21:01 dbasch: matter of taste I guess

21:02 toan: i'm just really confused.

21:02 dbasch: toan: what about?

21:02 toan: in this example the first element to get worked is the first one, correct?

21:03 how does the become 2^5?

21:04 dbasch: because reduce keeps the result and applies the function to that and the next element

21:04 toan: oh...

21:05 that's tricky

21:05 thx!!

21:05 that's why the dummy %1 was necessary

21:05 dbasch: yes, “f should be a function of 2 arguments”

21:06 amalloy: dummy? in what way is %1 there a dummy?

21:06 dbasch: it’s not a dummy, it’s the first argument

21:06 toan: well, i'm new, so i guess the term is incorrect

21:06 place-holder if you will

21:07 dbasch: ,(doc reduce)

21:07 clojurebot: "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...

21:07 amalloy: the word isn't wrong, the meaning is. placeholder is just as wrong: that %1 is an important part of the computation

21:08 toan: so what would be the term to describe the value assign?

21:10 dbasch: toan: it’s the same as (fn [arg1 arg2] (+ (* arg1 2) arg2))

21:10 toan: but, also thanks for the help.

21:10 amalloy: i mean, it's a function argument. in a reduce, it's often called the accumulator (the value you're building up)

21:10 toan: fair enough

21:11 accumulator. thx

21:12 this shit hurts my brain

21:15 dbasch: toan: programming hurts everyone’s brains at some point

21:20 toan: =)

21:23 gfredericks: reiddraper: I just spent 5 hours tracking down a bug that I'm 90% sure results from test.check using stateful randomness

21:24 reiddraper: Yeah?

21:25 gfredericks: because bind needs to consume randomness during the shrink process

21:25 so the shrink tree is sensitive to what order you walk it in

21:25 I don't think this effects normal users

21:25 just people like me who tweak things :)

21:26 I'm wondering if this could be fixed in bind without overhauling all the pseudorandom code

21:27 reiddraper: gfredericks: hmm, ok. I'll have to give that some thought.

21:27 gfredericks: if I see a fix in bind I'll make a ticket

21:35 reiddraper: gfredericks: ok, thanks. Shrinking _should_ be deterministic, but that's a _should_, not _is_ :)

21:36 * gfredericks shakes his fist at stateful randomness

21:36 gfredericks: reiddraper: if you're curious, here's my repro code: https://github.com/fredericksgary/test.check/blob/fork-debug/scratch.clj

21:37 reiddraper: gfredericks: I'm out now, but will take a look when I can, thanks

21:37 gfredericks: np

22:50 l1x: we should build a website, core review as a service

22:50 code*

22:50 talking about code reviews, is there anybody willing to go through ~300 lines of clojure and give me a review?

22:51 rpaulo: l1x: depends; CRaaS is a premium paid service these days...

22:51 :p

22:52 l1x: :)

22:52 i am the only clojure dev in the office and even scala guys just meh on my clojure, no real interest to learn, understand it

22:53 but this channel is actually pretty good in terms of best practicies

22:53 seangrove: l1x: I think it's just GitHub and making projects ;)

22:53 l1x: been there, done that :)

22:54 Jaood: but scala has strong type system...

22:54 :)

22:54 l1x: hahah, true that, so i can lose all of my hair over "why did you pass in a vector while i am expecting a list" sort of problems

23:13 amalloy: l1x: a good general rule: make it as easy as possible for someone to help you. nobody's going to say "yes, please, i want to help, can i have a link to your code", but if your request for code review includes a link, someone may be interested enough to have a look

23:29 l1x: cool :)

23:48 MrMiracle: evening all

Logging service provided by n01se.net