#clojure log - Oct 10 2012

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

0:20 AtKaaZ: lancepantz are you still here? having some trouble running the example in Usage from readme, Unable to resolve symbol: with-graph in this context

0:21 arohner: ok, so I want to write a macro that returns a macro...

0:22 AtKaaZ: arohner, sounds impossible

0:22 arohner: AtKaaZ: pretty sure it's not

0:23 AtKaaZ: okay but I want to know if it's possible how

0:23 ori-l: is there a way to get leiningen to stop littering repl-port files everywhere?

0:23 AtKaaZ: arohner, eval comes to mind

0:25 ,(defmacro x [] `(eval (defmacro y [] (+ 1 1))) ) ;this works

0:26 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

0:26 AtKaaZ: or something=)

0:27 how do I unmap a macro?

0:27 lancepantz: AtKaaZ: the example is probably a bit out of date honestly

0:27 but it's pretty basic if you look at the source

0:27 AtKaaZ: lancepantz it's possible, I had to include one more use clause, but consider that I am quite new to clojure

0:28 lancepantz, not really sure what I need to include in 'use' to get with-graph, without it giving me already defined errors

0:29 ,(ns-unmap defn)

0:29 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/defn, compiling:(NO_SOURCE_PATH:0)>

0:29 amalloy: uhoh, did lancepantz recommend jiraph? it's sorta in constant flux, and ninjudd's official position is "unless you're so dedicated you want to help maintain it, jiraph will probably make you sad"

0:29 lancepantz: amalloy: i did

0:29 AtKaaZ: constant flux?

0:29 lancepantz: AtKaaZ: listen to amalloy on this one :)

0:29 amalloy: AtKaaZ: we keep changing shit instead of documenting it

0:30 lancepantz: AtKaaZ: you coould do a blame on the readme and checkout that sha!

0:30 AtKaaZ: amalloy, like changing stuff inside jiraph or inside our own projects which use it?

0:31 amalloy: well, i definitely don't make changes inside your projects

0:31 AtKaaZ: 2 years old part:)

0:31 amalloy, ah my bad, I read, we recommend changing... :))

0:31 I can't believe I actually read it like that

0:34 amalloy: anyway, jiraph has a lot of cool concepts, but it's all an undocumented morass and probably will be for six months

0:34 i mean, functions and protocols have docstrings, but there's no coherent description of how to use it

0:35 AtKaaZ: amalloy, do you think I should try jiraph or try doing my graph on datomic? I mean I only need nodes and directed edges, no metadata for either

0:35 amalloy: datomic is the hot new thing. give it a shot and then teach me how to use it

0:35 AtKaaZ: lol

0:36 yeah I'm quite excited going that way instead

0:39 ynniv: ,(ns-unmap *ns* 'defn)

0:39 clojurebot: nil

0:39 ynniv: ,*ns*

0:39 clojurebot: #<Namespace sandbox>

0:39 AtKaaZ: ynniv, thank you!

0:39 ynniv: ,(defn foo [x] 1)

0:39 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

0:40 arohner: AtKaaZ: https://gist.github.com/3863185

0:42 AtKaaZ: this was my test: (ns-unmap *ns* 'y) (defmacro x [] `(eval (defmacro y [] `(+ 1 1))) ) (x)(y)

0:42 arohner: right, but eval is icky

0:43 amalloy: arohner: why are you using (resolve (quote ~fn-name)) instead of (var ~fn-name)?

0:43 AtKaaZ: yeah but, I don't know much :) I started reading about clojure to learn it a while ago then took some long break and I forgot pretty much everything that I learned (which wasn't much), I'll try understand the gist

0:43 amalloy: or, if you prefer, #'~fn-name

0:44 arohner: amalloy: that's a good point

0:44 AtKaaZ: /msg nickserv info atkaaz

0:44 err how did that happen?lol

0:44 right, ctrl+enter :)

0:45 amalloy: /msg nickserv identify *******

0:45 AtKaaZ: you put those there?=)

0:45 amalloy, totally reminded me of this: http://www.bash.org/?244321

0:46 amalloy: that was the idea

0:46 AtKaaZ: :)

0:46 you think I would've done it if I didn't have that prev. knowledge? lol

0:47 wingy: do you call clj a compiled lang or interpreted lang

0:48 AtKaaZ: compiles to java bytecode

0:48 wingy: so compiled

0:48 AtKaaZ: well I wouldn't, I can't really evaluate that

0:48 wingy: interpreted then?

0:48 frio: that's actually a tricky question

0:48 amalloy: also, arohner, a ^:dynamic def is a lot safer than with-redefs, and it seems like it would work

0:48 frio: it's technically compiled, i guess.

0:49 arohner: amalloy: I'm using this for stubbing out tests, and some of the things I want stubbed out happen in futures

0:49 AtKaaZ: it's like asking if a string is a value, rich says it is if it's immutable, but I could not have answered that before

0:49 arohner: stubbing out, *during* tests

0:49 amalloy: but yeah, I wouldn't with-redefs production code :-)

0:50 wingy: AtKaaZ: what are immutable values called then?

0:50 ynniv: it's definitely compiled. there may be some circumstances when code is interpreted, but it isn't the common case

0:50 arohner: ynniv: no. clojure is always compiled

0:50 AtKaaZ: wingy pleonasmic :)

0:50 wingy: to java bytecode!

0:50 such a difficult word to learn

0:50 arohner: at the repl, when you type (+ 1 1), the code is compiled, then the byte code is executed

0:51 ynniv: arohner: I defer to your certainty!

0:51 AtKaaZ: arohner, that makes sense

0:51 interactive realtime compilation

0:52 wingy, by the way that thing with the String being a value if it's immutable, got it from here: https://www.youtube.com/watch?v=-6BsiVyC1kM

0:53 I can only hope I remembered it right:)

0:53 ynniv: clojure.org/evaluation says: "Clojure has no interpreter". That sounds pretty definitive.

0:53 wingy: but then the java bytecode is intepreted by the jvm?

0:53 so clojure is just a compiler you can say?

0:54 compiling to java byte code

0:54 ynniv: most JVM's are Just In Time compiled

0:54 wingy: like coffeescript?

0:54 for js though

0:54 ynniv: coffeescript is more of a source -> source translator

0:54 wingy: ynniv: a compiler then :)

0:54 since that is the essence of a compiler

0:55 from what i have read

0:55 AtKaaZ: good video! so recently

0:56 rich always looks so awesome

0:56 AtKaaZ: i wonder if java can microprogram the cpu to execute bytecode directly just like cpu opcodes are really executing microopcodes or whatever they're called:)

0:56 ynniv: source translation is practically somewhat different. CoffeeScript doesn't offer additional core functionality over JavaScript

0:57 the clojure language is substantially different from JVM bytecode

0:57 AtKaaZ: hmm "Some processors can execute Java bytecode natively. Such processors are known as Java processors." well I didn't mean those :)

0:58 wingy: is clojure written in java?

0:58 AtKaaZ: yes

0:58 ynniv: a little

0:58 it's mostly written in clojure

0:58 wingy: cool

0:58 AtKaaZ: Java+Clojure :)

0:58 https://github.com/clojure/clojure/ 59% java it says, what do they know:)

0:58 wingy: write clojure in clojure. david asks .. but how can you write a language with a non existing language?

0:59 steve answers, since we write that language initially using another language

1:00 ynniv: AtKaaZ: that's a ratio of source code characters. Java and clojure source code are not the same density

1:01 AtKaaZ: ynniv, I stand corrected

1:01 wingy: that has to mean 1.5% java logic

1:01 or even less when i think about the verbosity of java

1:01 ynniv: wingy: most of a lisp can be written using a small subset of the language

1:02 wingy: ynniv: i remember i talked to you some months ago .. you were new to clj?

1:02 ynniv: dunno. i've been new to clj for years

1:02 AtKaaZ: I'm new too, I welcome myself back again

1:03 amalloy, I forgot to say, that wasn't rhetorical :))

1:04 oh I just found something good: http://www.infoq.com/presentations/Datomic

1:04 it's from 8 oct 2012

1:05 wingy: AtKaaZ: how do you find all that good stuff :)

1:05 ill have a cup of milk and enjoy them now :)

1:05 michaelr525: hello

1:05 AtKaaZ: well I mean it was infoq, and I just randomly clicked on the right side

1:05 it=I

1:05 wish these were on youtube

1:06 wingy: lol he is so cool :)

1:07 AtKaaZ: I still can't start the video yet heh, that's why I wish they were on youtube

1:08 getting the epic NetConnection.Connect.Failed

1:11 devn: wee, the ML

1:52 AtKaaZ: arohner, btw, I am glad I was wrong and that macro returning a macro was possible

1:53 arohner, did you do any updates on that gist since then?

1:54 arohner: AtKaaZ: just updated it

1:54 AtKaaZ: arohner, thank you, looking forward to understanding it=)

2:05 tomoj: "returning a macro"?

2:06 e.g. ##(#'-> '(-> x y z) nil 'x 'y 'z) ?

2:06 lazybot: ⇒ (clojure.core/-> (clojure.core/-> x y) z)

2:06 AtKaaZ: like: (ns-unmap *ns* 'y) (defmacro x [] `(eval (defmacro y [] `(+ 1 1))) ) (x)(y)

2:07 tomoj: ah. shouldn't need eval?

2:08 AtKaaZ: yeah probably doesn't but I don't know much

2:08 tomoj: that evals the return value of defmacro, which is like ##(eval #'->)

2:08 lazybot: java.lang.SecurityException: You tripped the alarm! eval is bad!

2:08 tomoj: i.e. a noop

2:08 oh, duh..

2:08 AtKaaZ: yeah I just tested, it doesn't=)

2:09 it makes sense, after all it's quoted

2:09 hmm wait a sec=)

2:11 I can't remember what it had to do, like when I call the first macro should the second macro be defined or returned to be defined later

2:12 in the latter case, I wonder how's that possible

2:13 ok got it, I think: (ns-unmap *ns* 'y) (defmacro x [] `(quote (defmacro y [] `(+ 1 1)))) (eval (x))(y)

2:14 tomoj: eval should generally be avoided

2:16 AtKaaZ: , (binding [*read-eval* false] (read-string "#=(eval (def x 3))"))

2:16 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

2:17 AtKaaZ: ,(doc *read-eval*)

2:17 clojurebot: "; When set to logical false, the EvalReader (#=(...)) is disabled in the read/load in the thread-local binding. Example: (binding [*read-eval* false] (read-string \"#=(eval (def x 3))\")) Defaults to true"

2:17 tomoj: huh..

2:17 AtKaaZ: i must be doing it wrong

2:17 tomoj: clojurebot must be hackable?

2:18 ,x

2:18 clojurebot: 3

2:18 AtKaaZ: what? that worked?

2:18 tomoj: I guess #clojure is just nice enough

2:18 AtKaaZ: why did I get the error though?

2:18 tomoj: no, I did it with [*read-eval* true] in a PM to clojurebot

2:19 AtKaaZ: oh right, I don't wanna know :)

2:19 but it's supposed to err?

2:20 I guess it makes sense, but for some reason I remember it wouldn't err before

2:20 ,*clojure-version*

2:20 clojurebot: {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}

2:21 AtKaaZ: maybe on 1.5 it doesn't, must check

2:22 tomoj: it errs if *read-eval* is false

2:22 AtKaaZ: tomoj, ok, I then remember wrongly

2:22 tomoj: I guess the example is confusing

2:23 should say "will throw an error" or something

2:33 AtKaaZ: does the same on 1.5.0, I don't know why I remembered someone using that with false and it wouldn't err

2:34 how can I find out what #= does?

2:35 hyPiRion: ,(read-string "#=(+ 1 2)")

2:35 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

2:36 AtKaaZ: ,(read-string "#=(+ 1 2)")

2:36 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

2:36 hyPiRion: ,(binding [*read-eval* true] (read-string "#=(+ 1 2)"))

2:36 clojurebot: 3

2:36 AtKaaZ: what's #=() ?

2:37 tomoj: heh

2:37 AtKaaZ: ,(read-string "(+ 1 1)")

2:37 clojurebot: (+ 1 1)

2:37 wingy: this is a must see https://www.youtube.com/watch?v=-6BsiVyC1kM

2:37 tomoj: it's the eval reader

2:37 AtKaaZ: oh that's what causing the error

2:38 ,(binding [*read-eval* false] (read-string "(eval (+ 1 2)")))

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

2:38 AtKaaZ: ,(binding [*read-eval* false] (read-string "(+ 1 2)"))

2:38 clojurebot: (+ 1 2)

2:38 AtKaaZ: ,(binding [*read-eval* false] (read-string "(eval (+ 1 2))"))

2:38 clojurebot: (eval (+ 1 2))

2:39 AtKaaZ: ok fair enough, I must've seen this variant :)

2:39 tomoj: hmm

2:40 no

2:40 I don't know what's going on there

2:40 AtKaaZ: maybe it was this , (eval (binding [*read-eval* false] (read-string "(+ 1 2)")))

2:40 (eval (binding [*read-eval* false] (read-string "(+ 1 2)")))

2:40 omg=)

2:40 ,(eval (binding [*read-eval* false] (read-string "(+ 1 2)")))

2:40 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

2:41 AtKaaZ: maybe I'm better off admitting my memory deceived me, rather than making up some acceptable variant of what I think I've seen in the past:)

2:45 wingy this one is good too: https://www.youtube.com/watch?v=EKdV1IgAaFc

2:45 wingy: AtKaaZ: sounds like a sequel to the previous one :)

2:56 what does a sound model mean?

2:56 hear that in datomic sense all the time

2:57 tomoj: so if you use e.g. jayq, will the closure compiler be able to remove parts of jquery you don't use?

2:58 oh, guess not

2:58 AtKaaZ: wingy, like: Four Key Elements For a Sound Business Model. (ignore the capitalization)

2:59 wingy, or this: Is that a sound business model? Central banks can print money. They can buy government bonds. So, the money spent by government seems to come from nowhere.

3:02 wingy: AtKaaZ: its an adjective?

3:02 thought it was a noun

3:05 AtKaaZ: wingy, yep you're exactly right: adjective

3:07 wingy: AtKaaZ: you are from the US :)

3:08 AtKaaZ: I don't wanna say haha

3:25 do you think that doing something in pure clojure is better/faster than doing it so that it's also java compatible ? thinking of datomic here

3:32 pyr: morning

3:33 have people seen occurences of projects built with openjdk7 not working on openjdk6 ?

3:33 AtKaaZ: were they built for 1.6?

3:34 pyr: i just lein uberjard :)

3:35 AtKaaZ: so there are compatibility flags to provide java with then

3:35 AtKaaZ: compiler compliance level if it's 1.7 then it shouldn't work on 1.6

3:36 you'd get something like unsupported major.minor version

3:36 but yeah there should be with lein, in project.clj not sure atm what

3:36 pyr: ok, will investigate

3:38 just to make sure, this applies to distributed jars also i guess, which means that no distributed jar on maven or clojars is supposed to be built with 1.7 yet ?

3:39 AtKaaZ: they can be built with 1.7 but the compiler compliance level can be less like: 1.6 , if it's 1.7 then shouldn't work

3:41 pyr, something like: :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options" "-g:source,lines" "-encoding" "utf8"]

3:42 and possibly also this: :java-cmd "c:\\program files\\java\\jdk1.6.0_31\\bin\\java.exe"

3:43 :java-cmd, if I remember right, is what lein will use to run/compile

3:44 pyr: ack

3:47 AtKaaZ: there's also this if want to enable assert`s :jvm-opts ["-ea"] (btw, I'm speaking strictly lein v2)

3:48 pyr: i'm lein v2 as well

4:10 zoldar: (dorun (repeatedly #(println (eval (read-string (read-line)))))) <= it there a shorter version for minimal repl? :)

4:15 hyPiRion: (loop (println (eval (read))))

4:16 (while true (println (eval (read))))*

4:18 wingy: i wonder how rich sees stores like Redis

4:18 they update in place .. but they are fast .. good for session management?

4:19 clgv: wingy: the appropriate tool for each task? ;)

4:20 wingy: clgv: yeah .. i thought about the whole place vs fact thing in his presentations

4:20 but though for sessions its not that important i guess

4:20 clgv: wingy: you mean the datomic talks? I still have them on the "to watch" list.

4:21 wingy: clgv: they are really great

4:21 clgv: wingy: what I meant before was: choose the appropriate tool per task ;)

4:21 wingy: the value of values .. the database as a value etc

4:21 tomoj: I think it would be fantastic to have a session store that wasn't update-in-place

4:22 wingy: tomoj: how come

4:22 tomoj: you could implement one with redis of course, I think

4:22 just like datomic is implemented on postgres and dynamodb

4:23 wingy: tomoj: yeah

4:23 tomoj: but why would time matter for a session store?

4:23 janpaulbultmann: Do you have a spontaneus idea for a function that splits a list into sublists by a predicate? Like partition-by, only not alternating.

4:24 wingy: you can see when the user was logged in :)

4:24 tomoj: I remember for example debugging session issues when using node.js and redis sessions

4:25 I think if all the session data were in something like datomic it would have been much easier to debug

4:27 wingy: tomoj: https://groups.google.com/forum/?fromgroups=#!topic/datomic/wN36ZykKyrQ

4:27 tomoj: hmm

4:33 clgv: janpaulbultmann: you want only two parts?

4:39 janpaulbultmann: clgv, no, a split after/before every true/false ^^

4:42 clgv: janpaulbultmann: you want it efficient? otherwise you build something together with take-while drop-while

4:42 janpaulbultmann: clgv, (defn my-part-by [f col] (map #(apply concat %) (partition 2 (partition-by f col)))) does the trick but this is rather ugly

4:43 clgv, yeah efficient would be nice ^^ I don't get why partition-by splits when the value changes, it seeems rather obscure.

4:43 clgv: janpaulbultmann: well that makes sense if your function is not a predicate and has more than 2 different values

4:44 janpaulbultmann: clgv, ah yeah right ^^

4:45 clgv: janpaulbultmann: you can write it as recursion that builds the subvectors until the predicate returns true, then the subvector is added to the result and to new subvector is initialized with the current element

4:45 *"the new subvector"

4:46 janpaulbultmann: clgv, I'll probably do that :) I find it weird though that it is not in the std lib, seems commonly needed behaviour to me :/

4:47 clgv: janpaulbultmann: I came to write one myself some time ago. but maybe its a good candidate for clojure.core.incubator

4:47 split-by-pred or something^^

4:47 janpaulbultmann: clgv, hrhr I'll consider submitting it ^^

4:48 clgv: but maybe then it should be as general that it takes two elements of the input sequence

4:48 janpaulbultmann: clgv, hm?

4:48 clgv: I mean the predicate is executed with two elements of the input sequence

4:49 your case would then be (fn [_ e] (your-pred e))

4:49 janpaulbultmann: and a split before would be (fn [e _] (your-pred e))

4:49 clgv: and it would be possible to split depending on both elements one before and one after the split

4:49 janpaulbultmann: awesome ^^

4:51 clgv: janpaulbultmann: I hope you did already sign the CA so you can easily contribute to clojure.core.incubator

4:51 janpaulbultmann: clgv, no where, how, when ^^?

4:52 clgv: http://clojure.org/contributing

4:52 janpaulbultmann: ah thanks ^^

4:53 sw1nn: clgv: why not wrap your predicate in something that keeps state of previous value?

4:53 janpaulbultmann: sw1nn, because state ;)

4:53 clgv: sw1nn: hmm? what do you mean?

4:54 sw1nn: (defn parter [pred]

4:54 (let [v (atom 0)

4:54 p (atom boolean)]

4:54 (fn [x]

4:54 (let [n (pred x)]

4:54 (if(= @p n)

4:54 @v

4:54 (do

4:54 (reset! p n)

4:54 clgv: use a gist for that ;)

4:54 sw1nn: (swap! v inc)))))))

4:54 clgv: ~gist

4:54 clojurebot: gist is http://gist.github.com/

4:54 sw1nn: hmm, better idea.

4:54 clgv: or refheap.com

4:56 sw1nn: the previous idea was to split based on a predicate and having two successive elements passed to the predicate for generality

4:57 sw1nn: https://gist.github.com/4684523a7063dc0fb08a

4:58 janpaulbultmann: wtf, partition by is recursive, and not with recur …

4:58 sw1nn: clgv: that gist's what you're looking for I think.

4:58 or should give you most of what you want

4:59 clgv: janpaulbultmann: yes, it is a lazy sequence

4:59 janpaulbultmann: clgv, but doesn't that still mean a call stack?

5:00 clgv: janpaulbultmann: no. you should read about lazy sequences

5:00 janpaulbultmann: clgv, noted I'll do that instantly ^^

5:00 tomoj: wingy: https://github.com/hozumi/datomic-session

5:01 janpaulbultmann: sw1nn, yeah but using atoms just for this seems a little dirty :D

5:01 clgv: sw1nn: well, I would prefer an implementation without state as we discussed before. it's not that complicated.

5:01 wingy: tomoj: cool

5:01 but the question is if dynamodb is fast enough for sessions

5:02 clgv: wingy: otherwise you can work around with an in-memory cache, I guess

5:02 tomoj: pro supports memcached :/

5:02 wingy: ah

5:02 neat

5:02 problem solved then :)

5:03 sw1nn: janpaulbultmann: atoms are very lightweight...

5:04 janpaulbultmann: sw1nn, yeah but they are state ;P

5:04 sw1nn: janpaulbultmann: yes, but state in a closure - so not global

5:05 clgv: sw1nn: but thats no reason to use them everywere. if you have a new use case that can only be implemented that complicated by using a core function, you should consider implementing a new function that does directly what you want.

5:06 sw1nn: clgv: the 'new' function is gonna have to implement some of that anyway.

5:07 so I'd certainly have a function that took the pred directly.

5:07 rather than the clumsy (parter foo) bit

5:07 clgv: sw1nn: it would not need to use an atom at all. there is a straightforward lazy-sequence approach or a recursive one if he does not need/want lazy behavior

5:18 sw1nn: clgv: agree the atom(s) are messy, but reading back I think I misunderstood your whole problem anyway. you don't want new subsequences when the pred changes?

5:20 clgv: sw1nn: exactly. partition-by would work in that case. the split shall occur when the predicate is true

5:20 sw1nn: clgv: right so I've given you a bad implementation to the wrong problem ;-)

5:21 wingy: rich hickey is a little einstein in the digital world

5:21 he wants the truth!

5:21 sw1nn: clgv: so split-with ?

5:22 clgv: sw1nn: that works only if you want only 2 parts. and is not very efficient

5:26 sw1nn: ,(vals (group-by odd? (range 10))

5:26 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

5:27 sw1nn: ,(vals (group-by odd? (range 10)))

5:27 clojurebot: ([0 2 4 6 8] [1 3 5 7 9])

5:28 sw1nn: although no guarantees on the order of the two partitions I guess

5:28 janpaulbultmann: sw1nn, yeah the idea is to create a split for every case the predicate is true

5:29 sw1nn, like the solution you provided

5:29 clgv: sw1nn: yep, group-by has a different semantic

5:29 janpaulbultmann: did you manage the implementation yet?

5:30 janpaulbultmann: (our-split identity [false false true false true]) => [(false false true) (false true)]

5:30 clgv, not yet I'm currently in a semi-meeting

5:32 Kototama: hi, i'm having troubles creating a clojurescript REPL

5:32 any ideas what the error is: http://paste2.org/p/2319045 ?

5:41 sw1nn: janpaulbultmann: my implementation didn't give you that. I updated it, it's a little closer now. https://gist.github.com/4684523a7063dc0fb08a

5:41 be interested to see a lazy-seq / atom-less implementation tho

6:07 Kototama: actually I get the same error even if I only do "lein cljsbuild repl-listen"

6:23 ok problem solved, probably an error in project.clj

6:25 ptrlv: are slides available for this talk? http://blip.tv/clojure/clojure-concurrency-819147

6:31 clgv: ptrlv: the simulation code can be found online

7:35 frawr: Hello Clojure irc

7:36 sw1nn: hello

7:37 frawr: Do you per chance have experience with duck-streams?

7:40 ticking: fawr, like so http://www.youtube.com/watch?v=2fpQQb0AvO8 ;)?

7:44 frawr: looks like a wonderful experience, but no. http://freegeek.in/blog/2009/10/downloading-a-bunch-of-files-in-parallel-using-clojure-agents/ I was trying this exapmle

7:45 However the writer only writes an empty file

7:48 _ulises: frawr: keep in mind that that's from 2009

7:48 frawr: things have certainly moved on

7:48 ticking: frawr, where is he actually using the duck streams, I see them imported but not used :/

7:48 frawr: Yes, I saw the date.

7:48 They are used for the writer

7:49 d/copy

7:49 ticking: ah right, sorry my fault, don't know why I'm so blind ^^

7:50 frawr: nm =)

7:50 I replaced the stream with a FileOutputStream, and that works, but I was wondering why it didn't work.

7:50 ticking: frawr, it seems that duck-streams was integrated into clojure.java.io

7:51 http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

7:51 third paragraph

7:52 frawr: Ah, IC. It's most likely not maintained anymore and I should try clojure.java.io then

7:53 ticking: frawr, yes you will prbably find the descendatns of the functions there ^^

7:53 frawr: Thanks a lot =)

7:53 ticking: youre welcome ^^

7:58 clgv: I need a persistent linked blocking queue. The only way to go is implement something on top of persistentqueue, right? or are there alternatives?

7:59 samrat: is anyone working with the dropbox API? or are there any up-to-date api wrappers?

7:59 clgv: I need that datastructure since I want to use transactions

8:21 ticking: Am I correct in assuming that using map in the core should be avoided and unrolled as much as possible to increase performance?

8:24 _ulises: ticking: what core?

8:24 ticking: clojure.core ;)

8:25 _ulises: ticking: oh, you're modifying clojure.core; way out of my depth here then :)

8:25 ticking: I picked up a few fragments from a dicussion some time ago arguing that core code often seems a bit cumbersome, which is because of of performance reasons

8:26 _ulises: oh, right, gotcha

8:27 ticking: _ulises, I wanted to do a separate-at fn to make splitting seqs easier

8:29 chronno: ticking: Are you doing separate-at as an exercise?

8:30 ticking: chronno, I need it as well, but yeah there's also a little bit of fun involved ;D

8:31 chronno: ticking: he, ok. Spoiler alert, you might be interested in comparing your answer with split-at and split-with :-)

8:32 ticking: chronno, split creates 2 seqs, I want a variable amount

8:33 partition-with would probably be a better name

8:34 chronno: ticking: ok, then maybe you're interested in one of partition, partition-by or partition-all

8:35 ticking: chronno: (partition-with (fn [x y]) (< x y)) [2 1 5 4 6]) => ((2 1) (5 4) (6))

8:36 The cool thing about the separator fn is that you can use predicates to split before or after an occurence

8:37 (partition-with (fn [_ x] (pred? x)) …) includes the element for which the pred is true

8:38 sorry excludes ;)

8:38 chronno: Ok, I see :-)

8:38 ticking: (partition-with (fn [x _] (pred? x)) …) includes the element for which the pred is true

9:06 AWizzArd: Interesting. In my test namespace (called when doing a “lein midje”) I call my -main method and get the message “-main is not public”. I solved this by calling (#'-main arg1 arg2) vs. (-main arg1 arg2), but I still wonder why -main is not public…

9:14 clgv: ticking: we had the same function discussion this morning

9:15 AWizzArd: no possible answer without a gist ;)

9:16 any idea on a persistent queue with blocking access?

9:21 ticking: clgv, sadly no ^^

9:22 clgv: ticking: do you mean the last question?

9:22 ticking: yes ^^

9:23 clgv: thats bugging me. I have to use LinkedBlockingQueue but I cant modify it in a transaction since it might be retried.

9:23 but modifying it outside a transaction might ruin consistency

9:24 hmm the only way to have something like a ref which signals

9:25 chouser: clgv: LBQs control access to themselves, so the only consistency problem would be between the LBQ and the refs, right?

9:25 clgv: yes.

9:26 or that I cant do (dosync ref-op1 lbq-op ref-op2) so that ref-op1 and ref-op2 are out of sync as well

9:26 chouser: ref transactions are synchronous -- would it work to either do your LBQ work and pass it into the xaction, or take the return value of the xaction and use it with the LBQ?

9:29 clgv: chouser: I am doing some scheduling, thus I need to get a worker-id from LBQ then get its "worker data" from a ref, decide on a number of tasks and update "worker data" again

9:29 chouser: it may also be instructive to think about how agents and refs interact, since sending to an agent is a side effect.

9:31 clgv: chouser: right. so the question is whether I can incorporate an agent there correctly.

9:31 chouser: that sounds like the LBQ work can be done before you start your xaction

9:31 so maybe I'm still missing something.

9:33 clgv: chouser: hm right I can factor out the get-data -> decision -> set data process. but I can not enforce the unique worker in LBQ constraint, yet

9:34 but that might be doable with a lock on the LBQ I guess

9:34 chouser: hm. Did you describe this constraint earlier?

9:36 clgv: the worker LBQ is like an event list. but I only want to have one event for each worker in it at a time since the state of the workers is in a ref and will consist of both events already when the first one is processed.

9:36 but maybe simply doing nothing on "duplicates" would work too

9:38 borkdude: Is it possible to be a programmer without drinking coffee?

9:38 clgv: borkdude: yeah, tea works as well

9:39 chouser: could you have a ref of a set of the worker ids that are in the LBQ, and then make sure everyone does a transaction to add to the ref before putting into the LBQ?

9:41 clgv: chouser: hm yes, that's possible

9:42 chouser: you could bundle that into a "non-dup LBQ" object

9:43 to enforce your constraint, and make sure the when someone pulls an item it gets removed from the set

9:45 clgv: chouser: thx :)

9:45 chouser: np, hope it works out.

9:46 I'm often amazed at how many powerful concurrency tools we have with java+clojure, and how much careful thought is nevertheless required to avoid screwing it up.

9:47 ...and that's all nothing compared to the minefield that is distributed concurrency. :-P

9:47 * Iceland_jack shudders

9:47 clgv: chouser: I do message passing for distribution ;)

9:48 chouser: what if the message doesn't arrive?

9:48 borkdude: is there something like socket.io but based on clojure/clojurescript?

9:48 clgv: I am screwed performance wise but the tasks will get send to another worker after a timeout

9:49 but RMI should secure the message arrival

9:54 * pandeiro <3 emacs workgroups

10:32 borkdude: wow

10:32 http://blog.datomic.com/2012/10/codeq.html

10:33 rhickey: I released codeq today http://blog.datomic.com/2012/10/codeq.html

10:34 clgv: rhickey: borkdude beat you.

10:34 borkdude: rhickey great!!!

10:34 sent-hil: I installed clojure with maven, how do I find the repl and bin file?

10:34 clgv: wow nice idea. thats what I wanted for some time...

10:35 borkdude: clgv it reminds me of that old microsoft video, which has similar ideas (versioning system that is code unit aware)

10:36 clgv: borkdude: since the "code bubbles" demo I thought who needs source files anyway, except for least common denominator for code exchange ;)

10:37 borkdude: clgv it seems the world is moving away from file based thinking (light table)

10:37 scriptor: well, I wouldn't say the world, but it's definitely an idea that's picking up

10:37 rhickey: In this case you don't change your workflow or editr, just keep using git, occasionally import/analyze

10:37 clgv: borkdude: well, light table does not try to get rid of the files ;)

10:39 rhickey: so right now it's a pure external analyzing tool?

10:40 or maybe just the backend for one.

10:41 XPherior: Hey folks. I just introduced Clojure at a start up by means of web services. We have 4 web services right now. I split those services into 4 different repositories on Github. I also got Archiva running as a binary jar manager. They're a little apprehensive that it might be a pain in the butt to work on two different services at the same time, and therefore want to crush all the services into one repository.

10:41 rhickey: yes, just builds a db, then many tools can leverage

10:41 XPherior: Having a hard time articulating any more why that's a bad idea. Can anyone help a bit?

10:43 dda: Xpherior have you looked into git submodules?

10:43 chouser: rhickey: very cool.

10:44 XPherior: dda: I haven't. But I guess it's just that, I don't think working on two different repos is a pain in the first place.

10:45 rhickey: chouser: thanks. we need to work on some more example queries so people can see how much fun it is

10:45 dda: Xpherior: I agree. what's the 'pain' that they are concerned about.

10:46 sw1nn: rhickey: queries like 'last 3 versions of this fn' etc?

10:46 XPherior: rhickey: I netted an unbelievable amount of jobs offers after watching most of your talks. Thanks. :)

10:46 * jkkramer wonders how long it would take to run codeq against everything in clojuresphere

10:47 XPherior: dda: One sec. Looking through my chat log so I can get exact words for you.

10:47 rhickey: sw1nn: yes, and which fns have the most churn etc

10:47 chouser: I've been fumbling around the edges of this idea (as have many others, I'm sure). The fact that git doesn't internally muck around with line-based diffs is so right.

10:47 rhickey: jkkramer: we hope to do just that

10:47 jkkramer: sweet

10:47 pyr: "maybe some fancy browser-hosted UI built with ClojureScript talking to Datomic's REST API"

10:47 :)

10:50 clgv: how about a clojure classloader with codeq backend? ;)

11:08 frozenlock: Anyone here tried clj-stripe? Any opinions/alternative?

11:30 Gosh: any suggestion on which database library to use with clojure? I dont care if it is not the best in performance. I want it to be simple to use and to nicely intergrate with clojure syntax.

11:30 I will probably have at most 10k records in it

11:34 nsxt: Gosh: which database are you using?

11:37 algernon: Gosh: the stuff from clojurewerkz are great, they have libs for multiple dbs (http://clojurewerkz.org/)

11:38 then there's also Datomic. Don't think you can be more idiomatic than that.

11:39 clgv: algernon: clojurewerkz has "Monger" what else?

11:39 lynaghk: ping: ohpauleez

11:39 ohpauleez: lynaghk: pong

11:39 pyr: clgv: cassaforte, though it's proably not what Gosh was looking for :)

11:39 lynaghk: ohpauleez: do you know offhand why kibit uses functions for its rule substitutions?

11:40 algernon: clgv: neocons (neo4j), welle (riak), spyglass (memcached, if you count that as a db)

11:40 lynaghk: ohpauleez: https://github.com/jonase/kibit/blob/master/src/kibit/rules/util.clj#L6

11:40 OE: is there any way to generate a list of numbers in clojure?

11:40 similarly to haskell or ruby

11:40 1..10

11:40 clgv: algernon: ah ok, these are dbs as well. I just searched for "db" on that site ;)

11:40 OE: could I do

11:40 (reduce + [1..50])

11:40 joly: ,(range 1 11)

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

11:40 OE: ah thanks

11:41 joly: goes up to but does not include 2nd argument

11:41 algernon: clgv: ah, yeah. the descriptons could use some love, and briefly mention wtf neo4j and the rest are

11:42 clgv: algernon: indeed :)

11:42 ohpauleez: lynaghk: Previously we had them in Vectors, but it was hard to compose them. Then Jonas changed the way we process them in core.logic. It was easier to clean everything up with functions that we could just apply

11:42 as best as I can remember

11:44 lynaghk: ohpauleez: hmm. hard to compose because you had name collisions between the uninstantiated lvars in different rules or something?

11:44 ohpauleez: No, because writing raw rules was brutal, so it got abstracted

11:45 that's why we had the macro

11:45 Why, is it a pain point for some reason?

11:46 lynaghk: ohpauleez: no, I'm just doing something similar for the ggplot rewrites and was wondering why the rule fns were needed. I am just using them raw and things seem to be working fine.

11:47 ohpauleez: If you dig around in kibit code, it might be that it gets used in a threading expression

11:47 or grouped in a way that only functions can participate

11:47 It's so that predicates and logic look the same, I believe

11:48 but I haven't gone into the core since jonas did a rewrite

11:48 lynaghk: ohpauleez: okay, that makes sense. Seems like a good idea to me, so I might pick up the practice. Thanks for teh tip.

11:48 ohpauleez: Cool

11:59 antares_: clgv: clojurewerkz also has an elasticsearch client, see http://clojureelasticsearch.info

12:04 frozenlock: Er.. is there a way to remove the stack trace from noir? In production mode I don't want to users to see it.

12:13 sent-hil: any good clojure install posts? i need nailgun + hookup to VimClojure

12:16 dnolen: frozenlock: just remove it, libs like Noir configure the route wrapping for you based on prod / dev configuration.

12:16 frozenlock: oh sorry you're already using noir, I thought it did that for you.

12:17 thorbjornDX: sent-hil: do you have a nailgun client yet?

12:17 sent-hil: er, server

12:19 sent-hil: thorbjornDX: don't even clojure yet, originally installed with homebrew, but heard that wasn't so good

12:19 cloned the clojure repo from github, ran maven, not sure what to do next

12:20 SegFaultAX|work: sent-hil: What are you trying to do?

12:20 sent-hil: install clojure + nailgun

12:20 SegFaultAX|work: ^

12:20 SegFaultAX|work: sent-hil: vimclojure?

12:21 sent-hil: SegFaultAX|work: already got that installed

12:21 frozenlock: dnolen: Perhaps I'm just not using it correctly... do you know if I need do something else than 'lein run'? 'lein run production'?

12:21 SegFaultAX|work: sent-hil: Do you have lein installed somewhere (and accessible on the path)?

12:22 thorbjornDX: sent-hil: I would recommend checking out leiningen, and dropping [vimclojure/server "2.3.6"] into :dependencies

12:22 sent-hil: SegFaultAX|work: yep

12:23 SegFaultAX|work: sent-hil: Have you downloaded the most recent server jar?

12:23 sent-hil: SegFaultAX|work: of clojure?

12:23 SegFaultAX|work: sent-hil: Nailgun.

12:24 thorbjornDX: sent-hil: https://github.com/sattvik/lein-tarsier may be helpful

12:26 sent-hil: SegFaultAX|work: i'm not able to find nailgun, help please?

12:26 SegFaultAX|work: sent-hil: You must be new here. Go with thorbjornDX's suggestion.

12:26 fckw: Hi there. In my Compojure defroutes I would like to do the following: (GET "/hello/:user" [user] (str "You have asked for " user))

12:27 But this does not work (I'm using Compojure 1.1.0).

12:27 Can anyone explain me why? All the tutorials say this should work.

12:27 My URL is then http://localhost:8080/hello/foo

12:28 Note that I can do both a GET without destructuring and a POST with destructuring using {params :params}.

12:32 SegFaultAX|work: fckw: Is that not the URL you were expecting?

12:33 devth: given a fn, is there a way to find which source file it's in and which line? been poking around with source, find-ns, meta, but no luck so far.

12:34 technomancy: devth: no, you need a var for that

12:34 fckw: yes

12:34 dnolen: frozenlock: don't know I don't use noir, but I saw that in the source. Might want to ask on the noir ML.

12:34 SegFaultAX|work: fckw: Then what's the problem?

12:35 devth: technomancy: that's fine, i can use a var

12:36 technomancy: devth: see clojure.repl/source, I think

12:36 hiredman: or just call meta on the var

12:36 ,(meta #'+)

12:36 fckw: I don't know what the problem is. I simply only ever receive "Page not found".

12:36 clojurebot: {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 920, :arglists ([] [x] [x y] [x y & more]), ...}

12:36 fckw: Which is my default fall back if no url matches.

12:37 I don't get an error message or anything.

12:37 Bronsa: https://github.com/Bronsa/neurotic i just added defrecord support

12:37 sent-hil: SegFaultAX|work: thorbjornDX: got it work, thx!

12:37 fckw: Thought, maybe this has changed in a newer Compojure version?

12:37 sent-hil: *working

12:38 devth: hiredman: ah, maybe it wasn't working for me because i loaded my ns into a repl. shows :file "NO_SOURCE_FILE"

12:38 thorbjornDX: sent-hil: awesome! <leader>el <leader>ef <leader>eb will prove pretty useful

12:38 devth: for my own vars, not clojure.core

12:38 technomancy: thanks, checking out source

12:38 fckw: It's not that the URL should be something like http://localhost:8080/hello?=foo

12:38 ?

12:39 sent-hil: thorbjornDX: sweet!

12:40 devn: hm, can't seem to get codeq to work

12:40 fckw: ??? Now it works.

12:40 devn: IllegalArgumentException No implementation of method: :extrel of protocol: #'datomic.datalog/ExtRel found for class: datomic.api$db clojure.core/-cache-protocol-fn (core_deftype.clj:533)

12:41 fckw: Oh, dear, sometimes I'm feeling stupid.

12:41 Maybe I forgot to reload my file when I restarted the server?

12:42 pandeiro: where should this print in nrepl.el? (future (while true (Thread/sleep 1000) (println "hello")))

12:44 fckw: That's weird. I am working with CCW in Eclipse using a nREPL. When I change only the defroutes function and restart the server, my changes are nowehere. But when I reload the whole file and restart the server, there are my changes.

12:46 pandeiro: fckw: noir saves the routes in an atom

12:47 fckw: I am not using noir (yet) - only Compojure and Ring.

12:47 But maybe Compojure does the same. This might explain the strange behavior.

12:50 casion: ,(conj (array-map :a 1 :b 2) [:c 3])

12:50 clojurebot: {:c 3, :a 1, :b 2}

12:50 pyrhho: Hi. I have a ring question. I have a ring app starting an embedded jetty server, but I'd like to mount another servlet (com.yammer.metrics/metrics-servlet AdminServlet) into it. anyone know how to do that? or is there a better way of integrating that with my app?

12:50 casion: why does conj prepend to an array-map?

12:51 fckw: Thanks guys, need to quit again.

12:51 technomancy: casion: order in array-maps is an implementation detail

12:57 TimMc: casion: There is no "prepend" with maps.

12:57 casion: TimMc: that's what I thought actually, however it seems to be a consistent result with any variation of the code above

12:58 TimMc: using a hashmap shows the unordered behavious right away

12:58 so I wasn't totally sure what I'm looking at

13:02 pandeiro: very weird: (future (mapv #(println %) (range 10))) ;=> prints to *nrepl* while (future (doseq [n (range 10)] (println n))) ;=> prints nowhere

13:21 jsabeaudry: pandeiro, doesnt that have to do with laziness?

13:21 pandeiro: jsabeaudry: doseq isn't lazy though

13:21 so i would say no

13:23 ivan: pandeiro: I would guess it's because the mapv runs faster

13:23 duck11231: the latter one prints in lein repl

13:24 pandeiro: i think it's a specific nrepl.el issue

13:24 ivan: I see https://www.refheap.com/paste/5655 in clj-swingrepl

13:24 pandeiro: https://github.com/kingtim/nrepl.el/issues/83

13:25 duck11231: I just tried these in the repl, and the first one returns the future before printing, the second prints then returns the future. (may just be the timing of those runs)

13:27 pandeiro: duck11231: using nrepl.el?

13:27 duck11231: let me try that

13:28 pandeiro: hmm, maybe it is fixed in nrepl.el 0.1.4, i was using 0.1.3 ...

13:29 duck11231: yeah, using nrepl, in both cases they print

13:30 pandeiro: duck11231: thanks, working for me now with the upgrade too.. wish there was a way to auto-upgrade elpa packages

13:30 jsabeaudry: I'd be extremely surprised there isnt

13:31 pandeiro: jsabeaudry: i use a snippet from technomancy's emacs config that iterates over my pkgs on startup and installs them if they're not there... maybe that can be extended to check versions

13:32 technomancy: yeah it's not included because it's like four lines, and half of that is just listing out your packages

13:40 pandeiro: technomancy: how do you deal with upgrades, out of curiosity?

13:40 technomancy: pandeiro: M-x package-install

13:40 I've never felt the need to make sure everything is up to date

13:41 this way if something breaks I have a better chance of figuring out what it is

13:41 sw1nn: M-x package-list-packages then U marks packages for upgrade and you can review install/delete

13:45 pandeiro: Is that what you're after?

13:45 jsabeaudry: sw1nn, programmatically

13:48 duck11231: I'd like to be notified when I start emacs (or once a day) that X packages can be upgraded

13:48 I'll do it manually

13:53 pandeiro: yeah that would be the best, just a notification

13:53 could even be in the form of a y/N prompt

13:57 cemerick: ever noticed java.net.URLConnection/guessContentTypeFromName can't recognize a javascript file!?

13:58 antares_: pandeiro: if you need to guess content types, use http://github.com/michaelklishin/pantomime

13:58 pandeiro: it is not magical and won't detect JS if you just give it a stream, but for most common formats and sane filenames it works flawlessly

13:59 pandeiro: antares_: thanks, it's that clutch has it builtin b/c clj-http or couchdb need it, i think

14:00 antares_: it's weird b/c clutch delegates to the class i mentioned above, and has an exhaustive mime.types meta info file that includes javascript, but it returns nil

14:15 TimMc: antares_: It works 100% of the time 60% of the time? :-)

14:20 ibdknox: rhickey: why did you shell out instead of using jgit?

14:21 rhickey_: don't know enough about the veracity of jgit

14:23 ibdknox: do you have any experience with it?

14:24 ibdknox: rhickey: I've used it with some success. Haven't done anything particularly crazy with it - though it is what eclipse uses (for what that's worth)

14:25 rhickey: it's rather poorly documented, but seems to be fast and has been accurate for everything I've done with it. I'd imagine something as fundamental as getting commit information is pretty safe.

14:26 rhickey: I figured I'd try to replicate the shell stuff you did in codeq with it and see what happens. My hope is it's a lot faster.

14:26 rhickey_: ibdknox: happy to take a patch (er whatever) with that if it proves to be so

14:27 is there javadoc?

14:28 ibdknox: rhickey: http://jgit.info/javadoc/

14:28 rhickey_: yikes

14:29 ibdknox: haha

14:29 yeah

14:29 ohpauleez: haha best reaction ever

14:29 antares_: there is a Clojure layer on top from beanstalk (the company)

14:30 rhickey_: I bet jgit more code than trudging through the git output, but should be faster

14:30 antares_: https://github.com/clj-jgit/clj-jgit

14:30 wingy: if i make a query in my Datomic Peer, does Datomic have to fetch the whole database from the storage server (DynamoDB) to be able to query against it?

14:30 since the data stored in the storage server is just a blob

14:30 ibdknox: rhickey: It might not be as much as you think, this opens a file from a commit: (.getBytes (.open repo (.getObjectId (TreeWalk/forPath repo "b/test.txt" tree) 0)))

14:31 rhickey: either way, we'll see :)

14:31 rhickey_: ibdknox: ok!

14:32 wingy: nope, what is stored in storage is an index tree, only those portions needed are fetched

14:40 wingy: rhickey_: it is using multiple key value pairs in storage to store this index tree?

14:41 cool that you can store an index tree in a key value store

15:08 antares_: can anyone think of a good example of a JDK interface to implement for the clojure-doc.org Java interop guide?

15:12 pjstadig: java.io.Closeable

15:13 used with a with-open block or something

15:14 antares_: pjstadig: this is for a section on reify, to be specific

15:15 I am thinking java.util.Comparator is decent candidate. java.io.Closeable is small and easy to follow but I can't think of a good example to use it with

15:16 pjstadig: we use reify to wrap a seq, fn pair in a closeable interface that can be used with with-open

15:17 also to pair an inputstream with a function that gets called on close

15:17 dgrnbrg: technomancy: Why can't I invoke clojure-find-ns from outside of clojure-mode.el?

15:17 pjstadig: but that uses proxy, not reify, since inputstreams must inherit an abstract class

15:20 antares_: pjstadig: I am going with java.io.FilenameFilter for one example, since it is small enough to understand for noobs and is not covered by clojure functions out of the box

15:21 pjstadig: that sounds like a good example

15:21 an interface with a single method

15:24 pisketti_: Question: is there a clojure lib for handling zip files?

15:24 dgrnbrg: pisketti_: you can just use java.io.zip

15:24 it's a java lib

15:28 pisketti_: dgrnbrg: mmmkay. thanks, I'll take a look. So far haven't found any examples

15:28 dgrnbrg: pisketti_: http://docs.oracle.com/javase/6/docs/api/java/util/zip/package-summary.html

15:29 you can create zipfile objects, iterate through the entries, read them

15:30 pisketti_: oh, you meant that one. Yeah I've used java.util.zip.ZipFile for some stuff but was hoping to find a clojure wrapper or something

15:31 frozenlock: pisketti_: https://github.com/Raynes/fs/blob/master/src/fs/compression.clj

15:31 pisketti_: but thanks anyway, I'm sure those will get the job done

15:33 frozenlock: ty. I already use fs.core. Didn't even cross my mind that fs.compression might be useful as well :)

15:47 frawr: Heey, is there a function for vecs that i can use to transform ((a b c . . .)) into (a b c . . .)

15:52 honkfestival: ,(flatten [[1 2 3]])

15:52 clojurebot: (1 2 3)

15:52 honkfestival: frawr: ^

15:53 TimMc: honkfestival: Love the name, but not the advice.

15:53 frawr: I see now that I can just reorder the statement and use apply

15:53 TimMc: frawr: 'first would do that for you.

15:54 Oh, you mean you want to call 'a on the rest of the args?

15:54 ~flatten

15:54 clojurebot: flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.

15:54 honkfestival: TimMc: neat, thanks

15:55 TimMc: honkfestival: Are you in NY, MA, WA, TX, or RI?

15:55 honkfestival: ON, Canada

15:55 frawr: Yeah, I get a bunch of items (a k-v pair as a vector) out of a for comprehension, and i want to make a map out of these

15:55 honkfestival: but I stole the name from the one in MA

15:56 TimMc: haha, OK

15:56 hiredman: frawr: (into {} ...)

15:56 S11001001: frawr: ^^hiredman

15:56 frawr: Perfect!

15:56 thank you all

15:56 looks a lot less convoluted too. thanks

15:57 TimMc: (into {} (for ...)) is a pretty common idiom.

15:57 Sgeo: ,(doc mapcat)

15:57 clojurebot: "([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection."

15:58 Sgeo: Basically >>= on sequences

15:58 frawr: Still quite new to clojure, have been trying for quite some time, but i find it quite hard to get into still

15:58 Sgeo: Erm, hmm

15:58 <<=

15:58 Erk

15:58 =<<

15:59 frawr: Very enjoyable experience though. Raises a lot of interesting questions with every new statement. Keeps you on your toes.

15:59 antares_: frawr: some are working on clojure-doc.org to make it easier on folks like you.

16:00 frawr: I bought the joy of clojure, and i like it a lot, but it's not a referece book.

16:01 antares_: frawr: by the way, we are looking for someone to contribute the guide on books ;) (just a listing of books on Clojure in reverse chronological order)

16:01 frozenlock: In compojure/hiccup, will a 'submit button' send the data of every 'form-to' in the page, or only the current 'form-to' in which it's located?

16:01 frawr: this keeps happening to me: Oh yeah, they explained how to do x in there, and then i can't find it back

16:03 For clojure-doc.org?

16:04 amalloy: frozenlock: that's not a hiccup or compojure question at all, it's an html question

16:04 frozenlock: indeed

16:06 frawr: The site looks pretty nice

16:16 (defn distsq [from to] "calculate the distance between 2 vectors" (letfn [(square [n] (* n n))] (reduce + (map #(-> %1 (- %2) abs square) from to))))

16:16 Somehow I get the feeling I could do that cleaner. Without a letfn

16:17 antares_: frawr: looks good to me. You use letfn the way it is intended to be used.

16:19 frawr: can't i add an annonymous function there instead?

16:20 (style aside)

16:20 antares_: frawr: you can, I don't know if that would be cleaner, honestly

16:21 muhoo: wow, i'd love it if someone wrote a clojure wrapper for jgit

16:21 AtKaaZ: how do you add it? do you just replace abs square with abs #(* % %) ?

16:21 frawr: Yeah, I think i agree, but how would it look? simply replacing the square with #(* percent percent) gave all sorts of scary errors

16:22 jkkramer: you can't nest #()

16:22 AtKaaZ: oh right

16:22 frawr: Oh yeah, i don't need to abs if i square to begin with

16:22 Aah thnx, makes sense

16:22 raek: you can nest (fn ...) though

16:22 AtKaaZ: cool

16:23 raek: but you need to add an extra pair of parenthesis if you use it with ->

16:23 frawr: thnx!, though I'll have to agree on the cleanlyness of said solution

16:23 raek: (-> 1 (fn [x] (inc x))) expands to (fn 1 [x] (inc x))

16:23 ohpauleez: antares_: We're leaving because we're relocating?

16:24 raek: but (-> 1 ((fn [x] (inc x)))) expands to ((fn [x] (inc x)) 1)

16:24 antares_: ohpauleez: we need to leave #clojuredocs so that dakrone can register it properly

16:24 ohpauleez: ahh

16:24 frawr: thank you for the help, I'm out.

16:24 dakrone: antares_: ohpauleez: thinking of just registering #clojure-doc instead since not everyone is around to get out

16:25 and it matches the website

16:25 antares_: dakrone: ok

16:25 ohpauleez: sounds good

16:26 AtKaaZ: raek, can you call something to show you what it expands to?

16:26 dakrone: ohpauleez: technomancy: uvtc: join #clojure-doc

16:27 raek: AtKaaZ: yes, macroexpand or macroexpand-1

16:27 ,(macroexpand '((-> 1 (fn [x] (inc x))))

16:27 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

16:27 raek: ,(macroexpand '((-> 1 (fn [x] (inc x)))))

16:27 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>

16:27 raek: ,(macroexpand-1 '((-> 1 (fn [x] (inc x)))))

16:27 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>

16:28 raek: ,(macroexpand-1 '(-> 1 (fn [x] (inc x))))

16:28 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>

16:28 Iceland_jack: ,(macroexpand-1 (-> 1 (fn [x] (inc x))))

16:28 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>

16:28 raek: now, what am I doing wrong... :)

16:28 AtKaaZ: raek, excellent, thanks works in my repl

16:28 ,(macroexpand-1 '(-> 1 (fn [x] (inc x))))

16:28 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Long>

16:28 AtKaaZ: it shows this for me: (fn 1 [x] (inc x))

16:28 raek: &(macroexpand-1 '(-> 1 (fn [x] (inc x))))

16:28 lazybot: ⇒ (fn 1 [x] (inc x))

16:29 AtKaaZ: clojurebot needs a reboot=)

16:29 raek: probably some bug in the clojurebot sandbox code

16:29 oh, frawr left...

16:29 I was going to suggest 'comp'

16:29 Sgeo: &(macroexpand-1 '(-> 1 ((fn [x] (inc x)))))

16:29 lazybot: ⇒ ((fn [x] (inc x)) 1)

16:29 amalloy: he resets his sandbox every fifteen minutes or so

16:30 hiredman: raek: please go ahead and try that in your repl

16:31 ,*clojure-version*

16:31 clojurebot: {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}

16:31 Sgeo: interim?

16:31 &*clojure-version*

16:31 lazybot: ⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}

16:32 raek: (sqrt (reduce + (map (comp square -) from to)))

16:38 jweiss: what's the idiomatic way to provide a set of functions with some state already set? for example, i have a set of functions that do remote actions over ssh. the first arg to each function is the ssh connection. i can create a set of functions with this already fixed using partial, but then what? stick them in a map?

16:39 create a protocol on the connection type?

16:40 gfredericks: jweiss: trying to avoid the dirty version of dynamic var + binding?

16:40 jweiss: gfredericks: yeah, gets ugly when trying to switch back and forth between hosts, and multithreaded gets ugly too.

16:41 FWIW, that's how i implemented it first, but now i have to deal with switching a lot mroe.

16:42 amalloy: jweiss: you can't get around having to keep track of the information somewhere. if you're not going to make it global/bindable (thank goodness), it has to be local. so, the client has to pass at least one connection-oriented option to the ssh functions

16:43 (or, they have to keep a map of connection functions, which is much the same)

16:43 gfredericks: amalloy: do you have precise opinions about when dynamic vars are appropriate?

16:44 technomancy: things like log levels

16:45 amalloy: not really. i just like to complain

16:45 technomancy: or print-depth

16:45 jweiss: amalloy: i guess the map of connection functions seems like cheap OO, and the syntax doesn't look like any idiomatic code i've seen. but nothing really wrong with it that i can think of

16:45 amalloy: jweiss: personally i prefer just having global functions that accept a map of connection info

16:46 technomancy: agreed re log levels, but i don't think i agree on print-depth. there's no reason the print functions couldn't take, modify, and pass on a depth arg

16:46 technomancy: in leiningen we use it for indicating you're operating in some alternate mode that is off the beaten path

16:46 amalloy: IMO it should honor both

16:47 amalloy: i don't understand that

16:47 technomancy: amalloy: "alternate mode" or "honor both"?

16:47 amalloy: honor both

16:47 technomancy: accept an argument, fall back to the var if it's not provided

16:47 gfredericks: dynamic vars are appropriate exactly when nobody winces too much

16:56 TimMc: Dear Abby, my friends tell me I use dynamic vars too much. How can I tell if they're right?

16:56 hyPiRion: Humm, you can't give a defrecord a docstring, am I correct?

16:59 Apage43: Now I am reconsidering my recent dynamic var use

16:59 gfredericks: hyPiRion: I doubt it, as I'm not sure where the docstring would be stored; defrecord just creates a class primarily I think

16:59 technomancy: things that aren't vars =(

17:00 Apage43: I'll probably add the option to take the dynamic thing as a parameter, but it's pretty useful when I often have a block that contains several forms that would all have the thing repeated

17:01 gfredericks: TimMc: it's easy! you just ask yourself "what option is simple?" and "what option is easy?" and then you pick the simple one of course.

17:01 hyPiRion: gfredericks: A shame :/

17:01 gfredericks: I started using this easy trick and now I don't make any more mistakes.

17:44 AtKaaZ: in a REPL, if you define a macro then use it in a newly defined function then redefine the macro, how can you make that function reflect the new definition?

17:44 I mean, without also redefining that function

17:44 arohner: you don't

17:44 you'll have to recompile the fn

17:44 macros only run at compile time

17:44 AtKaaZ: kind of makes sense

17:45 antares_: new Java interop section on clojure-doc.org: http://clojure-doc.org/articles/language/interop.html#implementing_java_interfaces_with_reify, feedback welcome

17:48 brehaut: clojure-doc.org and clojuredocs.org makes me a little sad

17:48 AtKaaZ: why?

17:48 clojurebot: why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone

17:48 technomancy: brehaut: the plan is to unify them

17:48 brehaut: oh cool

17:48 technomancy: brehaut: but the clojuredocs.org maintainer is proving difficult to find

17:48 brehaut: ah

17:49 sorry, i didnt mean to be a grumpy old man

17:49 AtKaaZ: unifying them sounds great!

17:49 technomancy: brehaut: well it's less than ideal, sure

17:49 TimMc: Sounds like a job for core.logic.

17:49 AtKaaZ: rofl

17:50 brehaut: hah

17:51 on more positive points, the content on clojure-doc looks good

17:51 technomancy: content is king

17:52 antares_: looking good

17:54 TimMc: ~maven

17:54 clojurebot: Help, I'm trapped in an XmlFactoryFactory!

17:57 cmdrdats: hey guys, does anybody know where I can find a working pallet example installing the oracle jdk7 onto an ubuntu vm?

17:57 * dakrone is sad that a simple documentation site needs javascript just to display a ToC

17:57 S11001001: TimMc: http://docs.oracle.com/javafx/2/api/javafx/util/BuilderFactory.html

17:58 technomancy: dakrone: looks fine in w3m from here =)

17:59 kirindave_: How to _not_ document your code: http://palletops.com/pallet/api/0.6/pallet.core.html#var-lift

18:00 node-type, not actually a real thing

18:00 Only appears there. Ever.

18:02 hugod: kirindave_: well, thanks for reporting the issue

18:03 dda: ,flatten

18:03 clojurebot: #<core$flatten clojure.core$flatten@4f25d6ca>

18:03 kirindave_: hugod: Literally just discovered.

18:03 technomancy: kirindave_: how's the new gig?

18:03 dda: flatten

18:03 kirindave_: hugod: Will probably note some stuff.

18:03 antares_: ,(doc flatten)

18:03 clojurebot: "([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."

18:03 kirindave_: technomancy: Getting provisioning set up.

18:03 technomancy: Fun tho.

18:03 technomancy: I can see =

18:03 )

18:04 kirindave_: Yeah provisioning is a pretty grim world.

18:04 But not having anything is way worse.

18:04 technomancy: I know very little about pallet, but I really hope it makes a dent in chef

18:04 hugod: cmdrats: the pallet java crate can do that for you - https://github.com/pallet/java-crate - though that readme could use an example

18:06 kirindave: hugod: I don't suppose you know what lift is asking for in the first argument? It's obviously not a server-spec.

18:06 hugod: a group-spec

18:07 kirindave: hugod: Ahh, cool. Thanks. Kinda tired of using converge over and over. W/ AWS it varies between shockingly fast and tediously slow.

18:08 hugod: vmfest/vitualbox is great for developing your crates

18:08 TimMc: S11001001: I think I wrote one of those once.

18:10 kirindave: hugod: Has virtualbox stopped chain-breaking on OSX yet? I tried this and had kernel panics. Like 2 in one day.

18:10 hugod: Every time there is a new OS release, it takes some time for the virtualization dust to settle.

18:10 I'll have to try.

18:11 cmdrdats: hugod: ye, i'm trying the java-crate, but not having much luck

18:12 hugod: yeah, virtualbox's network driver can cause issues - seems ok at the moment with vbox 4.1.23 and OS X 10.7.5

18:13 antares_: kirindave: on 10.8, virtualbox 4.2 works OK

18:13 cmdrdats: hugod: one of the issues i'm finding is that the oracle jdk has a licence agreement rubbish that needs and 'enter' key and hangs there..

18:13 antares_: cmdrdats: on Debian and ubuntu, you can work around that with preseeding

18:14 kirindave: cmdrdats: Actually a lot of the crates seem subtly broken in some places. You're probably best off forking and fixing on your own.

18:14 hugod: cmdrdats: defining a group-spec like (group-spec "java" :extends (pallet.crate.java/java {:vendor :oracle})) should work on ubuntu

18:14 antares_: cmdrdats: like here https://github.com/travis-ci/travis-cookbooks/commit/3f0d12caf95af4f3a42ba2f2bfd660a4e725fdea or via preseed file

18:15 (this assumes you use the oracle jdk7 ppa)

18:15 kirindave: cmdrdats: It turns out universal installation and management rules are hard. ;)

18:16 cmdrdats: antares_: interesting, that's a good link to keep around

18:16 hugod: kirindave: and the target is constantly moving

18:16 kirindave: hugod: And some of the crates suffer from neglect. Like mysql.

18:16 antares_: cmdrdats: for the seed file, see https://github.com/travis-ci/travis-cookbooks/commit/3fdf7048abd0318904b8f41eff7a464ce668d568

18:17 kirindave: Cuz mysql is not exactly a popular target anymore.

18:17 cmdrdats: kirindave: ye, but seriously. java? it's only, like, the cornerstone of pretty much every clojure app out there..

18:17 (not ranting at pallet, more at the fact that java is such a mess to install)

18:18 hugod: kirindave: yeah - slowly getting round to updating them, but it is a huge amount of work and nobody offers much help with them

18:18 kirindave: cmdrdats: I'm sort of at the point where I write off most pre-packaged configuration stuff. All goodwill towards the pallet crew for trying, but it's sort of a given with _every_ distributed conf system you're gonna just write your own code to force software onto boxes

18:18 cmdrdats: Even big-name ones like puppet and chef have their _entire_ stdlib written off by most serious shops I know.

18:19 cmdrdats: So just having a reasonable syntax and model that doesn't require a rendezvous server is a pretty big accomplishment in this space.

18:19 hugod: I'll commut back for my changes to nginx.

18:19 cmdrdats: antares_: thanks - I wonder if I can work that preseed file into the java crate

18:20 hugod: kirindave: thanks!

18:20 antares_: kirindave: that's largely what happened with travis-ci/travis-cookbooks. Almost every cookbook is modified or rewritten for our needs.

18:20 hugod: cmdrdats: so the crate is failing without it? Which install method are you using?

18:20 technomancy: cmdrdats: openjdk is easy

18:20 antares_: kirindave: at ~80 of them

18:20 cmdrdats: hugod: I'm going to try again now and let you know

18:21 technomancy: ye, i'm considering using it, but deep in my gut, something tells me something inexplicable is going to break one day if i do

18:21 kirindave: antares_: Yeah we _didn't_ do that at CrowdFlower and it ended up being a huge debacle that those guys are still extricating themselves from.

18:21 technomancy: cmdrdats: very unlikely

18:21 * kirindave </3s chef though.

18:21 kirindave: Fundamentally bad model.

18:22 Pallet & Jclouds is much more suited to elastic provisioning.

18:22 technomancy: does oracle jdk still adhere to the ancient US crypto laws like they did a couple years ago?

18:22 hugod: cmdrdats: if you have more issues, you can find more pallet people in #pallet

18:22 cmdrdats: technomancy: ok, then I probably will just end up using openjdk because it's more sane.

18:23 shaungilchrist: say I have a keyword (def x :thingy/majigger) - if I do (name x) I get "majigger" how do I get the first part "thingy" ?

18:23 cmdrdats: hugod: cool, that's a good point - i'll be sure to pop my head in there

18:23 nDuff: kirindave: Be nice if all the world worked like that. Of the last several startups I've been at, _none_ of them had every machine profile in our clusters completely stateless. (Web frontends, yes; app servers, yes... but there's always been _someone_ with a datastore who can't be nuked and paved).

18:23 technomancy: cmdrdats: at heroku the only people who want oracle JDK are the kind of people who buy big up-front enterprise sales packages for a service that's easily available via the CLI

18:24 * nDuff hasn't followed Pallet in quite some time, though -- it may be much better for the updating-existing-nodes case now than it used to be.

18:24 technomancy: it's 100% a brand name recognition thing

18:25 cmdrdats: technomancy: ah. ok, i'll definitely switch to openjdk then

18:25 * nDuff is at a very large Java shop, and gathers that the collective experience here is very different.

18:26 kirindave: nDuff: I think until we get totally off of hosting our monolithic db's in the cloud we're stuck with that property.

18:26 nDuff: There is just no magical way to wave a wand and have postgres failover with all the popular and modern app stacks.

18:27 nDuff: I try to use DynamoDB wherever I can. It's often cheaper than the box you'd require for a beefy postgres cluster, and if it can do what you want it's plenty fast.

18:27 nDuff: kirindave: I've done wave-a-wand PostgreSQL failover, but that was targeting a single (in-house) stack.

18:27 kirindave: nDuff: Yeah, you can break it until you make it happen. It's a lot of engineer hours tho.

18:27 shaungilchrist: (namespace :thingy/majigger) is what I needed

18:27 * nDuff nods.

18:28 AtKaaZ: shaungilchrist, cool thx

18:28 * nDuff -> train

18:28 AtKaaZ: ,(namespace :thingy/majigger)

18:28 * kirindave <$> tasks

18:28 clojurebot: "thingy"

18:28 AtKaaZ: ,(name :thingy/majigger)

18:28 clojurebot: "majigger"

18:29 AtKaaZ: ,(namespace :majigger)

18:29 clojurebot: nil

18:29 AtKaaZ: ,(namespace ::majigger)

18:29 clojurebot: "sandbox"

18:30 AtKaaZ: ,*ns*

18:30 clojurebot: #<Namespace sandbox>

18:30 wingy: does anyone know what is wrong with this datomic query: (q '[:find ?account :in $ ?uid :where [?account :db/id ?id]] (db conn) uid)

18:30 i get Exception: java.lang.Exception: processing rule: (q__3580 ?account)

18:30 shaungilchrist: I think you have your rule backward?

18:30 AtKaaZ: what is ?id ?

18:30 shaungilchrist: [?uid :db/id ?account] perhaps?

18:31 AtKaaZ: or add ?id to :find ?

18:32 shaungilchrist: wingy: is uid an entity id?

18:32 wingy: yeah i think i have it wrong

18:32 yeah

18:32 thats the issue :)

18:36 so if i wanna find an entity with that id (its a user) how should it look like?

18:36 i tried this: (q '[:find ?name :in $ ?id :where [?id]] (db conn) id)

18:36 but it gave me an error: java.lang.Exception: processing rule: (q__3580 ?id)

18:37 AtKaaZ: maybe you need ?name inside the :where ?

18:37 shaungilchrist: [:find ?name in $ ?id :where [?id :attr/name ?name]]

18:38 assuming :attr/name is what ever your actual name attribute is

18:38 AtKaaZ: or replace ?name with ?id ?

18:39 what shaungilchrist said makes sense:)

18:40 shaungilchrist: that is not a phrase often said

18:40 AtKaaZ: I assumed he wanted the entity id, but that's like asking does this entity with this id exist, but he wanted the name (ie. :attr/name) associated to that entity id

18:41 shaungilchrist: yeah it comes from sql mindset that first you must match a record to an id

18:41 but in datomic the id IS the record

18:42 wingy: i dont get the error: java.lang.Exception: processing rule: (q__3580 ?val)

18:42 (q '[:find ?val :in $ ?id :where [?id :account/name ?val]] (db conn) id)

18:42 it looks correct .. but why that error

18:43 shaungilchrist: where are you getting id from?

18:43 wingy: as a fn parameter

18:43 let me have it as a string to see if it changes

18:44 nope

18:44 shaungilchrist: is it cast to long?

18:44 AtKaaZ: what do you do to get set 'id' ?

18:45 ,(class 12367136812)

18:45 clojurebot: java.lang.Long

18:45 wingy: this worked (q '[:find ?val :where [?id :account/name "_gid_6YFM5nDHBkGY5ylI2vwa9OluSPR9i6A0i7fCRNiRf90="]] (db conn))

18:45 so i guess its something with the variable thing

18:46 perhaps i need to encode it first?

18:46 shaungilchrist: wait what?

18:46 wingy: oh yeah

18:46 what am i doing .. wait

18:46 shaungilchrist: are you sure the "id" you have is datomic entity id and not some other id you are creating?

18:47 AtKaaZ: wish we had a datomic both here:D

18:49 shaungilchrist: seems feesible to have one which does not allow transactions populated with a decent pet store schema or what not

18:49 wingy: shaungilchrist: i am using gigya which is giving me an id .. i need to see if that is an id that exists in the db .. if not, i create a new user and then tells gigya what that newly created account id is .. next time that user logs in it gives me that id and i would know that he/she already exists in my db

18:50 shaungilchrist: so you need to have an :gigya/id attribute defined

18:50 and check that

18:50 [:find ?exists :in $ ?gid :where [_ :gigya/id ?gid]]

18:51 AtKaaZ: everytime I watch this (Datomic Datalog) I learn something new: https://www.youtube.com/watch?v=bAilFQdaiHk

18:51 wingy: shaungilchrist: ?exists is a built in variable?

18:51 shaungilchrist: sorry I accidently pressed enter

18:51 just a moment

18:52 [:find ?exists :in $ ?gid :where [_ :gigya/id ?id] [(= ?id ?gid) exists]]

18:52 bah forgot ? on last exists but you get the idea

18:52 AtKaaZ: neat

18:55 wingy: the thing it is better for me to use whatever ID is in my db for an entity and just tell gigya that the new user's id is X and gigya will know that it is X next time it gives me the ID

18:55 AtKaaZ: is that potentially slower than just returning the ?gid ? since the first part will find all entities with any :gigya/id ids and then check if they are the one, instead of just finding the one with that specific id, but I guess both have to cache the same amount of data?!

18:55 wingy: 1. i create a new account 2. give gigya the ID of the newly created account

18:56 which means i cant have it as a :gigya/id attr

18:56 shaungilchrist: yeah I would try and use the entity id directly

18:56 AtKaaZ: so you're using entity id?

18:56 wingy: yeah

18:56 ill ask in datomic ML why its not working then

18:57 shaungilchrist: btw I would revise my answer to

18:57 AtKaaZ: they'll probably ask you to tell the type of the 'id' ie. (class id) before you run that query

18:57 but it's probably Long already

18:57 shaungilchrist: [:find ?id :in $ ?gid :where [_ :gigya/id ?id] [(= ?id ?gid)]] and just check if it is empty vector

18:59 AtKaaZ: why not this? (q '[:find ?eid :in $ ?gid :where [?eid :gigya/id ?gid] (db conn) gidvar)

19:00 shaungilchrist: the where is just binding any entity id with any gigya/id to ?gid

19:01 AtKaaZ: oh? just a sec I'll recheck/learn

19:02 I mean, if you're right then it would explain why this wouldn't work: <wingy> (q '[:find ?val :in $ ?id :where [?id :account/name ?val]] (db conn) id)

19:03 shaungilchrist: yeah that is just binding the account/name of any entity to ?val

19:03 AtKaaZ: but also to ?id ?

19:04 shaungilchrist: oh the :in yeah it is looking for that specific id but that is why it is breaking

19:04 it is a string and not the long an eid should be

19:04 AtKaaZ: yeah it's possible, that's why I wish wingy would do a (class id) :D

19:05 shaungilchrist: [:find ?id :in $ ?gid :where [?id :account/name ?val] [(= ?val ?gid)]]

19:05 would probably do the trick as that way it would be string -> string comparison

19:05 and if found it would return the entity id

19:19 wingy: shaungilchrist: dont you have to pass the db value as well?

19:20 i c .. you just wrote the the matching clause

19:21 AtKaaZ: wingy, looking at this https://www.youtube.com/watch?v=bAilFQdaiHk&t=4m30s

19:22 wingy: i should too

19:22 lets watch!

19:23 AtKaaZ: I mean, that part at 4:30 about finding a customer by email, and the ?email is passed as a param

19:35 wingy: AtKaaZ shaungilchrist that means i just have to convert the id to a long if its a string and i wouldn't get error

19:37 (q '[:find ?name :in $ ?gid :where [?gid :item/name ?name]] (db conn) (java.lang.Long. "17"))

19:37 no error

19:40 AtKaaZ shaungilchrist: FYI this worked great: (q '[:find ?id :in $ ?id :where [?id :item/name _]] (db conn) (java.lang.Long. "17592186045425"))

19:41 AtKaaZ: that makes me wonder, if you put the "_" does it mean the value of attribute :item/name for that ?id is restricted to being something? as in, it cannot be nil? (can it ever be nil anyway?) and if you don't put "_" would it allow it to be either something or nil? (assuming nil is doable)

19:42 by nil I merely mean, missing

19:42 wingy: wait .. regarding my answer it didn't work since Gigya ID is a string that cannot be converted to a nr :)

19:43 i guess ill just stick with the gigya ID as a attr approach

19:43 less hacky

19:49 tacoman: is there a list of the individual packages that make up Emacs-Live? I like some of the ideas but don't really want to go whole-hog with everything in it

19:52 ah, nevermind. the interesting stuff looks like it's largely in the configs in the packs

19:53 AuroraX: does anyone know LonTalk?

19:59 gert: is there a function f such that (f :foo/bar) returns "foo/bar"? i.e. like `name` but without removing the namespace part?

20:02 AtKaaZ: ,(defn keywordname [keyword] (symbol (namespace keyword) '/ (name keyword)))

20:02 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

20:03 AtKaaZ: i failed: ,(defn keywordname [keyword] (symbol (str (namespace keyword) '/ (name keyword))))

20:04 ,(#(symbol (str (namespace %) '/ (name %))) :foo/bar)

20:04 clojurebot: foo/bar

20:04 AtKaaZ: &(#(symbol (str (namespace %) '/ (name %))) ::bar)

20:04 lazybot: ⇒ clojure.core/bar

20:04 gert: AtKaaZ: thanks!

20:06 AtKaaZ: hmm, doesn't work for namespaceless keywords :) &(#(symbol (str (namespace %) '/ (name %))) :bar)

20:06 ,(#(symbol (str (namespace %) '/ (name %))) :bar)

20:06 clojurebot: /bar

20:06 patchwork: I have a file, what is the best way to get a content-type?

20:07 I was about to write something, but I feel this MUST have been done before

20:07 just not sure where

20:07 AtKaaZ: ,(#(symbol (str (when-let [ns (namespace %)] (str ns '/)) (name %))) :bar)

20:07 clojurebot: bar

20:09 AtKaaZ: patchwork, possibly this? https://github.com/michaelklishin/pantomime

20:10 patchwork: Wow, perfect!

20:10 knew it had to exist, thanks AtKaaZ!

20:11 AtKaaZ: I'm glad my life was not a waste ;)

20:12 patchwork: AtKaaZ: At the very least, you have done this much

20:13 AtKaaZ: yeah ;)

20:13 totally worth it, bbl

20:23 gert, btw, just making sure you saw the fix for when using that function with namespaceless keyword ie. :bar didn't work, it would show /bar fix was this: &&(#(symbol (str (when-let [ns (namespace %)] (str ns '/)) (name %))) :bar)

20:24 was this the syntax for bot? ##(#(symbol (str (when-let [ns (namespace %)] (str ns '/)) (name %))) :bar)

20:24 lazybot: ⇒ bar

20:24 gert: yup AtKaaZ I've got it working, ta :)

20:32 kovasb: ure

20:49 seancorfield: ,(#(->> % ((juxt namespace name)) (remove nil?) (clojure.string/join "/") symbol) :bar)

20:49 clojurebot: bar

20:50 seancorfield: ,(#(->> % ((juxt namespace name)) (remove nil?)

20:50 (clojure.string/join "/") symbol) :foo/bar)

20:50 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

20:50 seancorfield: bah!

20:50 frozenlo`: Is there a function to round up numbers?

20:50 Wrong question: surely there is, I just don't know the name.

20:50 amalloy: like yeehaw, round em up, cowboys?

20:51 frozenlo`: -_-

20:51 seancorfield: ,(Math/round 4.5)

20:51 clojurebot: 5

20:51 brehaut: ,(iterate inc 0)

20:51 clojurebot: (0 1 2 3 4 ...)

20:51 brehaut: ^ amalloy

20:51 frozenlo`: seancorfield: ah! The ubiquitous java call. Thanks!

20:51 amalloy: brehaut: i was thinking more like clojure.core/set, to get a bunch of free-ranging numbers from an infinite seq into a corral

20:52 brehaut: i hope those are only grass fed numbers

20:52 AtKaaZ: seancorfield that is pretty cool

20:54 frozenlo`: Grr... it chokes on a rational number. I suppose I should convert it to float before rounding it?

20:55 gfredericks: Frozenlock: are you dealing with rationals specifically?

20:55 Frozenlock: yes

20:56 gfredericks: then surely we don't have to resort to those nasty floats

20:56 ,(#(+ % (- 1 (rem % 1))) 7/5)

20:56 clojurebot: 2N

20:57 Frozenlock: More elegant indeed :)

20:57 * gfredericks is a rational idealist

20:57 gfredericks: verify it does what you want with negatives and such if you're dealing with those too

20:58 wingy: i have a clj server running using compojure/lein ring server .. how can i connect to it from repl so i can investigate the memory environment?

21:02 AtKaaZ: seancorfield, I just understood that code :) it's quite elegant

21:04 wingy: is it possible to destructure stringed keys

21:04 gfredericks: yep

21:04 :strs instead of :keys

21:04 wingy: ah

21:04 nice!

21:04 gfredericks: (inc rhickey)

21:04 lazybot: ⇒ 1

21:05 gfredericks: first!

21:05 * gfredericks imagines what clojure.core/first! would do

21:06 wingy: (inc rhickey)

21:06 lazybot: ⇒ 2

21:06 * Frozenlock just learned about :strs

21:06 Hodapp: out out damned statefulness!

21:06 * Hodapp glares at API he dislikes

21:06 Frozenlock: So much to learn, so little time!

21:06 wingy: i remember it from the (Programming) Clojure (Programming) book

21:06 gfredericks: Frozenlock: study that for a week and come back and I'll tell you all about :syms

21:07 Frozenlock: Naow! I want to know naow!

21:08 wingy: clj is said to be an interactive env where one can interact with the program .. how can i do that after i have run my program with "lein ring server"

21:08 gfredericks: wingy: you could start the server from the repl instead?

21:08 chouser: https://github.com/clojure/clojure/commit/000a3068a9e24d6f1a2464390fdecb4241133f45 ...I'm just sayin'

21:08 seancorfield: AtKaaZ: you can "blame" amalloy for my fondness for juxt :)

21:08 wingy: gfredericks: yeah

21:09 gfredericks: set destructuring??

21:09 lazybot: gfredericks: Uh, no. Why would you even ask?

21:09 gfredericks: ,(let [{:keys [a b]} #{:a :c}] [a b])

21:09 clojurebot: [:a nil]

21:09 gfredericks: O_O

21:10 AtKaaZ: ,(let [{:keys [a b]} #{:a :b}] [a b])

21:10 clojurebot: [:a :b]

21:10 AtKaaZ: typo?:)

21:10 seancorfield: wingy: or start a swank server inside your app and then slime-connect to that (assuming emacs)... that's what we do at world singles

21:10 gfredericks: AtKaaZ: no, I was just surprised it worked at all

21:10 clojure is full of secrets

21:10 AtKaaZ: oh

21:11 chouser: I haven't done anything useful lately so I have to take props from 4 year old patches.

21:11 wingy: seancorfield: not an emacs user though

21:11 gfredericks: chouser: oh I didn't see your name there

21:11 Frozenlock: Is :syms a way to pass functions?

21:11 gfredericks: (inc chouser)

21:11 lazybot: ⇒ 11

21:11 gfredericks: (dec rhickey)

21:11 lazybot: You want me to leave karma the same? Fine, I will.

21:11 AtKaaZ: lol

21:11 gfredericks: (dec lazybot)

21:11 lazybot: ⇒ 6

21:12 amalloy: &(let [{:keys [a b c]} (reify clojure.lang.ILookup (valAt [this k] "foo"))] [a b c])

21:12 lazybot: ⇒ ["foo" "foo" "foo"]

21:12 gfredericks: (dec rhickey)

21:12 lazybot: You want me to leave karma the same? Fine, I will.

21:12 chouser: Frozenlock: no, it's just for when you're using symbols as map keys

21:12 gfredericks: $karma rhickey

21:12 lazybot: rhickey has karma 2.

21:12 chouser: ,(let [{:syms [a b]} '{a 1 b 2}] [a b])

21:12 clojurebot: [1 2]

21:12 amalloy: i knew :keys worked on vectors, but it never occurred to me that it's just ILookup

21:13 wingy: clojurebot is more helpful than Siri

21:13 Frozenlock: Oh... OH!

21:13 Wow that never even occured to me to do something like this. Is this approach used often?

21:14 gfredericks: Frozenlock: what part?

21:14 Frozenlock: use symbol in a map instead of keyword or string

21:14 chouser: no, it's not very common to use symbols as keys, but occasionally it's exactly what you want.

21:15 Frozenlock: One could use a function as a key, for example?

21:15 brehaut: chouser: macros and stuff?

21:15 Frozenlock: Well the symbol for the function

21:15 gfredericks: Frozenlock: not functions no

21:16 it is probably mostly macro work

21:16 * gfredericks tries to remember if currj did that

21:16 Frozenlock: I'll stick with my newly learned :strs for now :)

21:17 chouser: brehaut: sure, lists and symbols are used most often when dealing with code such as in macros

21:17 Frozenlock: you can also use functions as keys, but that's probably even less common.

21:17 though, I do think I had a bit of code that did that...

21:18 patchwork: Is there a version of ring that does not include this heinous hiccup dependency issue?

21:18 gfredericks: ring depends on hiccup?

21:18 chouser: Frozenlock: http://fogus.me/fun/unfix/infix-src.html

21:19 there, functions as keys.

21:20 patchwork: Yes, and fails hard if there is another version of ring somewhere

21:20 gfredericks: which ring lib is that?

21:21 I see ring-devel does

21:21 patchwork: Here is the error: java.io.FileNotFoundException: Could not locate hiccup/core__init.class or hiccup/core.clj on classpath:

21:21 gfredericks: oh yeah hiccup changed it's namespaces didn't it

21:21 Frozenlock: Actually this might be what I was missing when trying to store functions in a map... https://github.com/Frozenlock/zyzanie/blob/master/src/zyzanie/core.cljs#L51 With the symbol however I could easily that.

21:21 patchwork: hiccup renamed a bunch of stuff and now everything blows up

21:22 terrible, I don't even use hiccup

21:22 Frozenlock: Ohh this is exciting :)

21:22 patchwork: Now my app is broken : (

21:22 gfredericks: patchwork: so you're using ring-devel specifically?

21:22 patchwork: No, but it gets included

21:22 gfredericks: by another dep?

21:22 so you have hiccup as a 2nd degree dependency conflicting with hiccup as a 3rd degree dependency?

21:22 patchwork: Yes

21:23 exactly

21:23 nowhere do I include it directly

21:23 gfredericks: apparently encouraging lots of libraries has its downsides

21:23 wingy: i have this fn i run from the lein repl: (defn run [] (run-jetty handler {:port 3000}))

21:23 gfredericks: best you can do is pick the one that depends on the older hiccup and update it

21:24 send a pull request and push your own version to clojars in the mean time

21:24 wingy: the server starts but then i cannot interact with the repl anylonger

21:24 gfredericks: wingy: add :join? false I believe

21:24 to the options map

21:25 wingy: ok i did this: (run-jetty #'handler {:port 3000 :join? false})

21:25 and it worked

21:26 gfredericks: wingy: SWEET

21:26 patchwork: gfredericks: Thanks

21:26 wingy: much better than lein ring server since now i can interact :)

21:26 gfredericks: patchwork: you can also use lein checkouts if the clojars part sounds difficult (which it isn't)

21:27 I think...actually I don't remember if the checkouts feature uses the project.clj from the checkout

21:27 it probably does

21:27 wingy: just to check with you that this is the correct workflow: 1. "lein repl" 2. (require 'myapp.server)(ns myapp.server)(start) .. it can't get simpler than this?

21:28 gfredericks: if you set that ns as your :main in the project.clj then it'll go there automatically cutting out 2/3 of your steps

21:29 AtKaaZ: awesome

21:29 gfredericks: I think you could also have a function that starts the server and starts a repl itself but it might not be fully featured

21:35 * Hodapp discovers Clisk

21:35 Hodapp: wonder of its author ever steps in here...

21:37 wingy: gfredericks: i added main: myapp.server in project.clj and now it jumps right to it .. so all i have to do is (start)

21:37 i did (start) in the server.clj file directly but the repl timed out

21:37 is there a way to set a longer timeout value?

21:37 i should consult lein github doc

21:38 https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L134

21:40 Frozenlock: That is a big project file.

21:41 gfredericks: and if you really love clojure you'll memorize it

21:41 Frozenlock: lol!

21:44 wingy: why is lein "compiling myapp.server" after i added it to :main in my project file

21:45 its taking forever to compile it

21:45 gfredericks: eh...that might be a side effect :)

21:45 leiningen y u complect

21:45 wingy: what is compilation do? compiling it to java byte code?

21:45 Hodapp: you told me that there were no side effects :(

21:45 wingy: since now it just hangs up in "compiling myapp.server"

21:45 gfredericks: wingy: yeah; I imagine the primary purpose of :main is setting a main class for an executable jar

21:46 ideally lein would have a :lein-repl-ns option

21:46 wingy: since i added (server) in my server file .. if i remove it it compiled it perfectly

21:46 gfredericks: oh ah ha

21:46 wingy: ill file an issue

21:46 gfredericks: there's a compile flag you can check for

21:46 so that you don't start the server if it's compiling

21:46 ,(doc *compile-files*)

21:46 clojurebot: "; Set to true when compiling files, false otherwise."

21:47 gfredericks: so just say (when-not *compile-files* (server))

21:47 AtKaaZ: wait that's too good to be true

21:48 wingy: Unable to resolve symbol: server in this context, compiling:(myapp/server.clj:142)

21:48 gfredericks: WAT.

21:48 wingy: my fault

21:48 wait

21:48 start ! not server :)

21:49 wohoooooo

21:49 so now my workflow looks like this: lein repl :)

21:49 thx for the help

21:49 gfredericks: alias lr="lein repl"

21:50 wingy: yeah

21:50 :D

21:50 brehaut: you close your repl‽

21:50 AtKaaZ: ,(compile 'clojure.core)

21:50 clojurebot: clojure.core

21:50 aperiodic: there's a way to tell leiningen not to compile your main, if you want

21:50 wingy: when i think about it "lein ring server" is a bad practice

21:51 since clj is built around interactive env

21:51 gfredericks: (inc wingy)

21:51 lazybot: ⇒ 0

21:51 wingy: who gave me minus???

21:51 lazybot: wingy: Yes, 100% for sure.

21:53 gfredericks: wingy: it doesn't matter. that's all over now. he can't hurt you anymore.

21:54 AtKaaZ: gfredericks, how can I test that and see *compile-files* is true? I don't really know how to make it compile in a new thread

21:54 wingy: i still have nightmares

21:54 he was a monster

21:55 gfredericks: AtKaaZ: you could add a ns to :aot in project.clj and run `lein compile`

21:55 AtKaaZ: gfredericks, but I mean from repl, to be easier

21:55 gfredericks: AtKaaZ: no clue

21:56 ,(doc compile)

21:56 clojurebot: "([lib]); Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath."

21:56 AtKaaZ: something like ##(.start (Thread. #(compile 'clojure.core))) *compile-files*

21:56 lazybot: ⇒ nil

21:57 Frozenlock: seancorfield: I'm aware this is more a mongodb question, but I'll take my chances anyway.. Any tricks to avoid this error? "command failed [findandmodify]: { "serverUsed" : "/127.0.0.1:27017" (...)" I think it's because I try to modify a recently created collection, but I'm not sure.

22:08 AtKaaZ: gfredericks, I looked at the source, compile does (binding [*compile-files* true]

22:08 and I was trying to get the value from a different thread:)

22:10 binding is threadlocal right?

22:10 amalloy: i'm pretty sure *compile-files* is a compiler internal that you're not really supposed to use

22:11 AtKaaZ: I was trying to see if I can catch it to ever be true

22:11 hiredman: amalloy: no, it's cool, you can use it

22:12 amalloy: hiredman: so there are actual good situations to use it in?

22:13 AtKaaZ: "but you can get bitten by sloppily thinking that an established binding will migrate to another thread" from chas

22:13 I mean, from here: http://cemerick.com/2009/11/03/be-mindful-of-clojures-binding/

22:13 hiredman: if you have something you only want to happen when you are compiling

22:14 seancorfield: Frozenlock: I'd need to see more of your code and know more about your setup... is there more detail in the error?

22:15 Frozenlock: are you using congomongo? if so, asking on the congomongo-dev list might be a good idea, where you can provide full details

22:18 Frozenlock: seanaway: Yes I'm using congomongo. Thanks for the tip, I'll try the mailing list if my current workaround fails.

22:21 AtKaaZ: hiredman, but can you ever get the *compile-files* to be true to do any such work ? if the compile happens in a different thread it'll always be false to you, or if it happens in the same thread you're either doing the check before or after the compile is done, again seeing it as false

22:24 looks like it's used internally to know when to generate files (when it's true)

22:30 aperiodic: AtKaaZ: when the namespaces being compiled are evaluated, *compile-files* will be true. try adding (when *compile-files* (println "compilation is happening")) as a toplevel form in some namespace, then compile that namespace

22:33 AtKaaZ: aperiodic, wow I did not see that, I stand corrected

22:33 thank you for that

22:33 wingy: is it okay to shadow symbols like _name_ in eg. (let [name (...)] …)

22:34 aperiodic: you're welcome

22:34 wingy: cause name already exists

22:34 aperiodic: that's totally kosher

22:34 clojure has lexical scope

22:35 wingy: aperiodic: yeah so its okay as long as i dont use the name fn inside of the let scope

22:35 aperiodic: yeah, inside of that let name will always refer to the local

22:36 but you can still refer the core fn by using the fully-qualified symbol

22:37 ,(let [name 'Bob] (clojure.core/name name))

22:37 clojurebot: "Bob"

22:42 AtKaaZ: ,#(1)

22:42 clojurebot: #<sandbox$eval53$fn__54 sandbox$eval53$fn__54@6b497573>

22:42 AtKaaZ: ,#(identity 1)

22:42 clojurebot: #<sandbox$eval81$fn__82 sandbox$eval81$fn__82@465155b6>

22:45 AtKaaZ: I think I'm losing my mind, I need an anonymous function that returns 1 when called, how to?

22:45 aperiodic: ,((constantly 1))

22:45 clojurebot: 1

22:47 Raynes: AtKaaZ: (constantly 1) or (fn [& _] 1)

22:47 AtKaaZ: can I use #() ?

22:47 aperiodic: why?

22:47 clojurebot: why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone

22:47 AtKaaZ: curious how to

22:48 I mean other than like this: ((#(constantly 1)))

22:48 aperiodic: that's the only way you can do it

22:49 AtKaaZ: I see that ##(fn [] 1) is easy but #(1) is like calling function 1

22:49 lazybot: ⇒ #<sandbox7657$eval11377$fn__11378 sandbox7657$eval11377$fn__11378@98df31>

22:49 AtKaaZ: ,((fn [] 1))

22:49 clojurebot: 1

22:49 AtKaaZ: aperiodic, it's not possible with #() ?

22:49 brehaut: ,(#(-> 1))

22:49 clojurebot: 1

22:50 AtKaaZ: neat, ok I guess what I learned is, #(..) will require first thing to be function call, unlike (fn [] ...)

22:51 thanks aperiodic, Raynes, brehaut

22:51 Raynes: brehaut: That is hideous.

22:51 brehaut: Raynes: i have something worse

22:51 ,(#(or %& 1))

22:51 clojurebot: 1

22:51 aperiodic: (inc brehaut)

22:51 lazybot: ⇒ 7

22:51 Raynes: &(#(do 1) 1 2 3)

22:51 lazybot: clojure.lang.ArityException: Wrong number of args (3) passed to: sandbox7657$eval11389$fn

22:52 Raynes: The problem with that is that it only works if you're passing no args.

22:52 brehaut: aperiodic: its chouser or fogus's fault (from JoC)

22:52 aperiodic: i'm utterly addicted to ->

22:52 AtKaaZ: I actually like that one with -> :)

22:52 brehaut: Raynes: didnt i say it was worse?

22:52 Raynes: brehaut: I meant your -> and my do example/.

22:53 brehaut: Raynes: oh right. the %& breaks much worse with arguments

22:54 aperiodic: yeah, don't you just want #(or 1 %&)?

22:54 amalloy: &'#(1) ;; in case you're unclear on why that fails

22:54 lazybot: ⇒ (fn* [] (1))

22:54 AtKaaZ: ok *compile-files* can be used to guess if it's first time run, thanks to aperiodic's eye opener

22:55 I mean, first time ever :) like after checking out the project

22:56 brehaut: aperiodic: aha of course

23:03 AtKaaZ: disregard my previous statement, doesn't work with lein (or I'm doing it wrong: lein clean, lein repl ...)

23:05 amalloy: aperiodic, brehaut: #(or 1 %&) isn't very general, since it only works for truthy values. if you were really going to rewrite (constantly x) with #(), the answer is #(do %& x)

23:06 AtKaaZ: it only works (in ccw or lein) if I invoke compile

23:07 Sgeo: What's wrong with just using constantly?

23:07 aperiodic: so straightforward!

23:08 AtKaaZ: ,(#(do %& 1))

23:08 clojurebot: 1

23:08 Sgeo: ,(#(identity %&) 1 2 3)

23:08 clojurebot: (1 2 3)

23:08 AtKaaZ: ,(#(do %& 1) 1h l 12hlk 131 3hl1)

23:08 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 1h>

23:09 Sgeo: ,(type (#(identity %&) 1 2 3))

23:09 clojurebot: clojure.lang.ArraySeq

23:09 AtKaaZ: ,(#(do (comment %&) 1) 1h l 12hlk 131 3hl1)

23:09 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 1h>

23:09 Sgeo: AtKaaZ, is there a reason to not use constantly?

23:09 AtKaaZ: Sgeo, i wanted to do it with #()

23:09 Sgeo: And the problem with the examples you're trying is the 1h, not the function

23:10 AtKaaZ: yeah my bad passing random stuff, not even valid numbers

23:12 ,(#((comment %&) 1) 1 2 3)

23:12 clojurebot: #<NullPointerException java.lang.NullPointerException>

23:13 AtKaaZ: ,(macroexpand '(#((comment %&) 1) 1 2 3))

23:13 clojurebot: ((fn* [& rest__193#] ((comment rest__193#) 1)) 1 2 3)

23:14 Sgeo: ,(nil 1)

23:14 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)>

23:15 Sgeo: ,(macroexpand '(#(#_%& 1) 1 2 3))

23:15 clojurebot: ((fn* [& rest__245#] (1)) 1 2 3)

23:15 AtKaaZ: oh right, comment returns nil

23:15 Sgeo: ,(macroexpand '(#( 1) 1 2 3))

23:15 clojurebot: ((fn* [] (1)) 1 2 3)

23:15 Sgeo: Hmm, so the reader will see the %& no matter what, I take it?

23:16 AtKaaZ: ,(#(#_%& do 1) 1 2 3)

23:16 clojurebot: 1

23:17 AtKaaZ: very clever of you Sgeo :)

23:17 Sgeo: ,(macroexpand '(#("%&" 1) 1 2 3))

23:17 clojurebot: ((fn* [] ("%&" 1)) 1 2 3)

23:17 amalloy: Sgeo: yeah, that's a quirk of the reader: %n "counts" even inside an #_ form

23:18 AtKaaZ: so that's the right way to ignore any extra params with #_%& ?

23:20 amalloy, I think you mean that in the future it could change?

23:20 ,(#(do (comment %&) 1) 1 2 3 "x" true)

23:21 clojurebot: 1

23:24 scottj: codeq: continuing the clojure tradition of obfuscating spoken conversations.

23:25 ynniv: anyone know the difference between an empty "let" block and a "do" block?

23:26 I was surprised to see defrecord using an empty "let" block

23:26 AtKaaZ: how can you test is the stuff inside comment is evaluated or not like: (comment (+ 1 2))

23:27 Sgeo: It should in theory be completely ignored

23:27 ynniv: (comment (println 'a)) ?

23:27 Sgeo: ,(comment (println "HoNk HoNk :o)"))

23:27 clojurebot: nil

23:27 ynniv: ,(println "HoNk")

23:27 clojurebot: HoNk

23:28 ynniv: wasn't sure clojurebot printed stdout

23:28 AtKaaZ: ynniv, that's pretty epic, why didn't I think of it:)

23:28 ynniv: AtKaaZ: the proper answer to your question is "side effects" ;-)

23:28 AtKaaZ: yep

23:29 Sgeo: ,(doc set!)

23:29 clojurebot: excusez-moi

23:29 AtKaaZ: comment is a macro, makes sense now

23:30 uvtc: &(doc set!)

23:30 lazybot: java.lang.SecurityException: You tripped the alarm! set! is bad!

23:30 Sgeo: &(comment set!)

23:30 lazybot: ⇒ nil

23:31 AtKaaZ: if it were a function they would've been evaluated ##( #(#_%&) (println 1) )

23:31 lazybot: ⇒ 1 ()

23:31 uvtc: First rule of `set!` is that you do not talk about `set!`.

23:32 Sgeo: I should watch that movie sometime

23:33 AtKaaZ: didn't know this returns empty list: ##(class (#(#_%&)) )

23:33 lazybot: ⇒ clojure.lang.PersistentList$EmptyList

23:33 AtKaaZ: that is, if no return is specified

23:34 ,(class (#()) )

23:34 clojurebot: clojure.lang.PersistentList$EmptyList

23:35 AtKaaZ: ,(count (#()) )

23:35 clojurebot: 0

23:35 Sgeo: ,(class nil)

23:35 clojurebot: nil

23:35 Sgeo: Oh, what you're doing makes... wait, hmm

23:35 AtKaaZ: ,(#())

23:35 clojurebot: ()

23:35 Sgeo: You're right, that's weird

23:35 ynniv: ,(reduce *' (range 2 100))

23:35 clojurebot: 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000N

23:36 Sgeo: ,(apply *' (range 2 100))

23:36 clojurebot: 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000N

23:36 AtKaaZ: what's the ' ?

23:36 ynniv: ,(list (reduce *' (range 2 100)) nil)

23:36 clojurebot: (933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000N nil)

23:36 ynniv: ,(do (reduce *' (range 2 1000)) nil)

23:36 clojurebot: nil

23:36 Sgeo: AtKaaZ, bignums

23:36 ynniv: ,(do (reduce *' (range 2 100000)) nil)

23:36 AtKaaZ: thanks

23:36 clojurebot: Execution Timed Out

23:36 AtKaaZ: ,(class (*'))

23:37 clojurebot: java.lang.Long

23:37 wingy: wouldn't this be cool: https://www.refheap.com/paste/5705

23:37 ynniv: *' autopromotes

23:37 AtKaaZ: Sgeo, it expands as needed?

23:37 ,(class (*' 19289821 7129872189889899))

23:37 clojurebot: clojure.lang.BigInt

23:37 ynniv: ,(class (*' (range 2 100)))

23:37 clojurebot: #<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.LazySeq to java.lang.Number>

23:37 ynniv: ,(class (apply *' (range 2 100)))

23:37 clojurebot: clojure.lang.BigInt

23:38 AtKaaZ: ,(class (* 19289821 7129872189889899))

23:38 clojurebot: #<ArithmeticException java.lang.ArithmeticException: integer overflow>

23:38 AtKaaZ: nice

23:38 ynniv: ,(do (reduce *' (range 2 100000)) nil)

23:38 ,(do (reduce *' (range 2 100000)) nil)

23:38 clojurebot: Execution Timed Out

23:38 Execution Timed Out

23:46 ynniv: ,"/me sighs"

23:46 clojurebot: "/me sighs"

23:48 dlitvak: ,(println "/me sighs")

23:48 clojurebot: /me sighs

23:48 dlitvak: clojurebot: you evil creature

23:48 clojurebot: I don't understand.

23:48 dlitvak: clojurebot: you disrespect the rules of irc

23:48 clojurebot: irc is only for opionfests

23:49 dlitvak: \(println "/me sighs")

23:49 lazybot: help

23:49 lazybot: You're going to need to tell me what you want help with.

23:50 dlitvak: lazybot: help commands

23:50 lazybot: Topic: "commands" doesn't exist!

23:50 dlitvak: lazybot: help all

23:50 lazybot: Topic: "all" doesn't exist!

23:50 dlitvak: lazybot: help eval

23:50 lazybot: Topic: "eval" doesn't exist!

23:50 dlitvak: lazybot: help clojure

23:50 lazybot: Topic: "clojure" doesn't exist!

23:50 dlitvak: i hate bots...

23:52 ynniv: ,(do (Thread/sleep 5000) (symbol "Hi!"))

23:52 clojurebot: Hi!

23:52 Sgeo: I wasn't watching, did it sleep?

23:52 ynniv: ,(do (Thread/sleep (* 10 1000)) (symbol "Hello from 10 seconds ago!"))

23:53 2

23:53 3

23:53 4

23:53 5

23:53 6

23:53 7

23:53 clojurebot: Execution Timed Out

23:53 ynniv: 8

23:53 bah

23:53 Sgeo: ,(symbol "&(println "boom"))

23:53 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string>

23:53 Sgeo: ,(symbol &(println "boom"))

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

23:53 ynniv: haha

23:54 Sgeo: ,(symbol "&(println \"boom\")")

23:54 clojurebot: &(println "boom")

23:54 lazybot: ⇒ boom nil

23:54 ynniv: Sgeo: you're no good

23:54 :-)

23:55 Sgeo: Considering the -> I don't see a way to do it

23:55 Then again, I suck at botloops

23:55 ynniv: ,(symbol "&(symbol \"boom\")")

23:55 clojurebot: &(symbol "boom")

23:55 lazybot: ⇒ boom

23:55 ynniv: perhaps someone thought of this

23:55 &1

23:55 lazybot: ⇒ 1

23:56 ivan: maybe you can get a multi-line message

23:56 AtKaaZ: something like make the other bot dec rhickey's karma :)

23:56 only cause normal users can't do it :)

23:57 ynniv: 1 ,2

23:57 &(println "\n1")

23:58 lazybot: ⇒ 1 nil

23:58 Sgeo: &(symbol "hi\nbye")

23:58 lazybot: ⇒ hibye

23:58 AtKaaZ: that works in repl

23:59 ,(symbol "hi\r\nbye")

23:59 clojurebot: hi

23:59 bye

23:59 AtKaaZ: i did not believe it

23:59 Sgeo: &(symbol "hi\r\nbye")

23:59 lazybot: ⇒ hibye

23:59 Sgeo: AtKaaZ, note the different bots

23:59 AtKaaZ: oh right

23:59 finally, I was right to not believe :)

Logging service provided by n01se.net