clojure 1.5 cheatsheet?

2013-06-24 Thread László Török
Hi, is there a clojure 1.5 cheatsheet somewhere, the last I could find was 1.4. Thanks, -- László Török -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new

Re: clojure 1.5 cheatsheet?

2013-06-24 Thread terjesb
http://jafingerhut.github.io kl. 11:38:41 UTC+2 mandag 24. juni 2013 skrev Las følgende: Hi, is there a clojure 1.5 cheatsheet somewhere, the last I could find was 1.4. Thanks, -- László Török -- -- You received this message because you are subscribed to the Google Groups Clojure

ANN: core.match 0.2.0-rc1

2013-06-24 Thread David Nolen
core.match 0.2.0-rc1 going out the door. ClojureScript support now up to date with Clojure. I've also changed the ClojureScript version to optimize for performance over code size as the code size issues are less problematic for ClojureScript than they are for the JVM.

Re: Best practice for looping

2013-06-24 Thread P Martin
Thanks a lot for tracing through my code! So, as I understand it, my loop/recur is correct, but I was not using map in a correct way within the vector functions. By the way, what is your (pst e*) line doing? Is that from a debugging library? I don't appear to have that in my clojure

Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread David Nolen
I've written up how core.match works here http://github.com/clojure/core.match/wiki/Understanding-the-algorithm Hopefully this is a bit more approachable than the Maranget paper :) On Mon, Jun 24, 2013 at 7:43 AM, David Nolen dnolen.li...@gmail.com wrote: core.match 0.2.0-rc1 going out the

Re: Best practice for looping

2013-06-24 Thread Gary Trakhman
pst is printstacktrace, it's in the clojure.repl namespace and comes with clojure. Sometimes lein or something makes it available automatically, but if it isn't, you can (use 'clojure.repl) to get to it. http://clojure.github.io/clojure/clojure.repl-api.html#clojure.repl/pst Yes, switching to

Re: Clojure 1.6 API: clojure.lang.IFn and clojure.api.API

2013-06-24 Thread Jörg Winter
Hi Stuart, ok, so my question is actually more about how to create some clojure Runtime, filling it with additional namespaces, i.e. more than just clojure.core. I just discovered the RT class which could be what I want ( though its not official API ?) I need to make clojure runtime avail.

Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread Thomas Heller
Hey David, I wanted to try core.match for a while and fiddled around a bit to see what kind of code is generated by match, in doing so I found a potentially dangerous bug. See: https://gist.github.com/thheller/5850693#file-match-clj-L67 If a match has no :else clause an

Re: [ANN] clj-wamp : a WebSocket sub-protocol for HTTP Kit

2013-06-24 Thread Christopher Martin
Martin, Thanks for the kind feedback. I've written a tutorial (first draft) that covers some of the basics, and created a leiningen template for quick-starting a new HTTP-Kit/clj-wamp project: http://cljwamp.us/tutorial https://github.com/cgmartin/clj-wamp-template Cheers, ~Christopher Martin

putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-24 Thread John Gabriele
Why does `into` fail when the 2-element collections are lists and not vectors? : ~~~ user= (into {} [[:a 1] [:b 2]]) {:a 1, :b 2} user= (into {} ['(:a 1) '(:b 2)]) ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj

Re: Best practice for looping

2013-06-24 Thread P Martin
Great! Thanks so much for your help! On Monday, June 24, 2013 10:50:57 AM UTC-4, Gary Trakhman wrote: pst is printstacktrace, it's in the clojure.repl namespace and comes with clojure. Sometimes lein or something makes it available automatically, but if it isn't, you can (use

Re: [ClojureScript] Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread David Nolen
Thanks for the report, fixed and 0.2.0-rc2 is going out. Probably going to hold off on ex-info change, the behavior of match is the same as `case` with respect to the no match exception. David On Mon, Jun 24, 2013 at 11:10 AM, Thomas Heller th.hel...@gmail.com wrote: Hey David, I wanted to

Bitwise Operations in core.logic?

2013-06-24 Thread David Rocamora
Hi, I've been exploring core.logic while working through The Reasoned Schemer and would like to be able to describe relationships between IP addresses and networks that they may or may not be a part of. It's straightforward to do this in Clojure because I can use bit-and on a network and a

Re: Bitwise Operations in core.logic?

2013-06-24 Thread David Nolen
Yeah there's no good way to do this out of the box. You probably want to define some custom constraints - to perform well you might even need to go so far as to define a new constraint domain. Things are not at the point where I feel comfortably describing how this can be done as the details are

Re: putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-24 Thread Sean Corfield
On Mon, Jun 24, 2013 at 8:49 AM, John Gabriele jmg3...@gmail.com wrote: Why does `into` fail when the 2-element collections are lists and not vectors? : Because the implementation special cases vectors :) It's the one place where a two element vector is treated like a Map$Entry so that you are

Re: clojure 1.5 cheatsheet?

2013-06-24 Thread Andy Fingerhut
That link is also available near the top of http://clojure.org/cheatsheet(Download other versions with tooltips). There are a few things new in 1.5 on the latest version, but I haven't yet included any of the new reducers functions there yet. If anyone has a better suggestion for categorizing

Re: Clojure 1.6 API: clojure.lang.IFn and clojure.api.API

2013-06-24 Thread Kevin Downey
On 6/24/13 7:53 AM, Jörg Winter wrote: Hi Stuart, ok, so my question is actually more about how to create some clojure Runtime, filling it with additional namespaces, i.e. more than just clojure.core. I just discovered the RT class which could be what I want ( though its not official API

Re: Bitwise Operations in core.logic?

2013-06-24 Thread David Rocamora
Cool. Thanks for the quick feedback (also thanks for core.logic). I'll continue experimenting. -Dave On Monday, June 24, 2013 12:14:14 PM UTC-4, David Nolen wrote: Yeah there's no good way to do this out of the box. You probably want to define some custom constraints - to perform well you

Re: matching, assigning and branching in one form

2013-06-24 Thread Gary Johnson
The condp form is very nice and concise if you have multiple match clauses. If you are more generally just looking to perform a single match/assign/branch task, I'd recommend this little nugget of clojure wisdom: Forget ye not the hidden might of if-let. (if-let [[_ from to message] (re-find

Re: clojure 1.5 cheatsheet?

2013-06-24 Thread László Török
Thx, i saw that but the page says 1.3 and 1.4 :-) Sent from my phone On Jun 24, 2013 6:17 PM, Andy Fingerhut andy.finger...@gmail.com wrote: That link is also available near the top of http://clojure.org/cheatsheet(Download other versions with tooltips). There are a few things new in 1.5 on

Re: [ClojureScript] Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread Thomas Heller
That was quick, thanks. One Question for vector matches, I was thinking of a 'case-ex macro which basically copies the semantics of erlangs case-expressions. eg. (case-ex (db/find-object some-id) [:ok object] object [:error :not-found] default-object) expands to (match [(db/find-object

Re: Clojure 1.6 API: clojure.lang.IFn and clojure.api.API

2013-06-24 Thread László Török
Thanks Kevin, it's all clear now. Sent from my phone On Jun 24, 2013 6:38 PM, Kevin Downey redc...@gmail.com wrote: On 6/24/13 7:53 AM, Jörg Winter wrote: Hi Stuart, ok, so my question is actually more about how to create some clojure Runtime, filling it with additional namespaces, i.e.

ANN: cljson, for faster browser deserialization

2013-06-24 Thread Alan Dipert
Hi all, I'm pleased to announce the release of cljson 1.0.0, a Clojure and ClojureScript data serialization library designed for maximal Clojure data deserialization speed in the browser: https://github.com/tailrecursion/cljson. cljson was designed to take advantage of the native JSON parsing

Re: ANN: cljson, for faster browser deserialization

2013-06-24 Thread Thomas Heller
Hey, this looks pretty sweet! I stuck with EDN for now but its way too slow, so I'm gonna give this a shot. One thing: I'm don't think its the best idea to fall back to *default-data-readers*, would you be open to adding a second argument to 'cljson-clj which takes a map specifying readers?

Re: putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-24 Thread John Gabriele
On Monday, June 24, 2013 12:14:56 PM UTC-4, Sean Corfield wrote: On Mon, Jun 24, 2013 at 8:49 AM, John Gabriele jmg...@gmail.comjavascript: wrote: Why does `into` fail when the 2-element collections are lists and not vectors? : Because the implementation special cases vectors :)

Re: putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-24 Thread Michael Gardner
On Jun 24, 2013, at 11:14 , Sean Corfield seancorfi...@gmail.com wrote: On Mon, Jun 24, 2013 at 8:49 AM, John Gabriele jmg3...@gmail.com wrote: Why does `into` fail when the 2-element collections are lists and not vectors? : Because the implementation special cases vectors :) It's the

Re: ANN: cljson, for faster browser deserialization

2013-06-24 Thread Alan Dipert
Glad you enjoy! And yes, totally into the cljson-clj [map data] arity. Alan On Monday, June 24, 2013 1:50:00 PM UTC-4, Thomas Heller wrote: Hey, this looks pretty sweet! I stuck with EDN for now but its way too slow, so I'm gonna give this a shot. One thing: I'm don't think its the best

Lazy seq race condition?

2013-06-24 Thread Cedric Greevey
What, precisely, happens if two threads sharing a reference to a single lazy sequence try to realize the same element at the same time? If the sequence is completely pure and deterministic, so any attempt to realize a particular element will produce a single particular value consistently (unlike,

Re: Lazy seq race condition?

2013-06-24 Thread Nicola Mometto
Realizing a lazy-seq is done through a synchronized method see: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazySeq.java#L37 No race conditions. Cedric Greevey writes: What, precisely, happens if two threads sharing a reference to a single lazy sequence try to realize

[ANN] lein-gnome 0.1.0

2013-06-24 Thread Jamie Brandon
Useful tools for writing gnome extensions in cljs: -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first

Re: [ANN] lein-gnome 0.1.0

2013-06-24 Thread Jamie Brandon
(I fell afoul of the new gmail compose window) Useful tools for writing gnome extensions in cljs: https://github.com/jamii/lein-gnome As a side effect, allows injecting a cljs repl into gnome-shell. On 24 June 2013 23:02, Jamie Brandon ja...@scattered-thoughts.net wrote: Useful tools for

Re: Lazy seq race condition?

2013-06-24 Thread Cedric Greevey
Ah, thanks. The locking granularity is local to the cons cell (or analogue; first/rest pair) being realized, I hope? So one thread actually calculates an element and neither call returns until it's calculated, and then both promptly return the calculated value, but threads realizing other lazy

Unnecessary boxing with 1.5?

2013-06-24 Thread Cedric Greevey
(defn foo [x y z] (let [x (long x) y (long y) z (long z)]) (loop [a false b (long 0)] (if a b (recur true (+ x (+ y z)) NO_SOURCE_PATH:1 recur arg for primitive local: b is not matching primitive, had: Object, needed: long Auto-boxing loop arg: b What the fuh? Binary + with

1.5: Can't type hint a local with a primitive initializer error message gives wrong line number.

2013-06-24 Thread Cedric Greevey
I got a Can't type hint a local with a primitive initializer triggered by the following fragment of a let binding vector: ^BigDecimal d0x (- x (:x rp)) ^BigDecimal d0y (- y (:y rp)) d0x2 (- (* d0x d0x) (* d0y d0y)) d0y2 (* 2M (* d0x d0y)) d0x3 (-

Re: Lazy seq race condition?

2013-06-24 Thread Timothy Baldridge
Reading the LazySeq.java file should make this all clear, but yes, no race conditions. https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazySeq.java#L37 Synchronized methods basically lock the current instance of the object while the method runs, so it is impossible for two

Re: Lazy seq race condition?

2013-06-24 Thread Cedric Greevey
I'm familiar with what synchronized Type foo (args) does -- my last question was more about what aspect of a lazy seq the object with the method corresponds to. Cons cell or similar subunit? I could read half of clojure.lang, learn how all the various types of seq (Cons, LazySeq, ChunkedSeq,

Re: Lazy seq race condition?

2013-06-24 Thread Timothy Baldridge
It corresponds to the execution of the LazySeq fn. That fn will be called once and only once, the rest of the data in the object is immutable and side-effect free and therefore does not need to be synchronized. Timothy On Mon, Jun 24, 2013 at 8:51 PM, Cedric Greevey cgree...@gmail.com wrote:

Re: Lazy seq race condition?

2013-06-24 Thread Cedric Greevey
So, is the granularity that of seq realization -- individual [first rest] cells for (iterate inc 0), single chunks for (range), etc.? I'd appreciate a straight, direct, yes-or-no answer to that question. On Mon, Jun 24, 2013 at 11:03 PM, Timothy Baldridge tbaldri...@gmail.comwrote: It

Re: [ANN] clj-wamp : a WebSocket sub-protocol for HTTP Kit

2013-06-24 Thread Christopher Martin
Good call. I agree the prefix shortening should be more noticeable since it's found throughout the examples. I've given it its own section now: http://cljwamp.us/tutorial#wampprefix Again, much thanks for the feedback! On Monday, June 24, 2013 1:51:25 PM UTC-4, martin_clausen wrote: That is

Re: [ANN] clj-wamp : a WebSocket sub-protocol for HTTP Kit

2013-06-24 Thread Juha Syrjälä
Nice work. How about adding this https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/authentication WAMP-CRA (WAMP Challenge Response Authentication)? On Tuesday, June 25, 2013 6:52:40 AM UTC+3, Christopher Martin wrote: Good call. I agree the prefix shortening should be more

Re: Lazy seq race condition?

2013-06-24 Thread Timothy Baldridge
The first 100 lines of LazySeq.java contain all the answers. Read it, and be enlightened. :-) And as a bonus, you'll better understand the language as a whole. Timothy On Mon, Jun 24, 2013 at 9:08 PM, Cedric Greevey cgree...@gmail.com wrote: So, is the granularity that of seq realization --

Re: [ANN] clj-wamp : a WebSocket sub-protocol for HTTP Kit

2013-06-24 Thread Christopher Martin
Thanks! I saw that too in the Autobahn docs. I'll add that source link to the GitHub issue I'm tracking for that feature @ https://github.com/cgmartin/clj-wamp/issues/3 On Tuesday, June 25, 2013 12:04:21 AM UTC-4, Juha Syrjälä wrote: Nice work. How about adding this

Re: Lazy seq race condition?

2013-06-24 Thread Cedric Greevey
On Tue, Jun 25, 2013 at 12:12 AM, Timothy Baldridge tbaldri...@gmail.comwrote: On Mon, Jun 24, 2013 at 9:08 PM, Cedric Greevey cgree...@gmail.comwrote: So, is the granularity that of seq realization -- individual [first rest] cells for (iterate inc 0), single chunks for (range), etc.? I'd

{ANN} clj-xmemacched release 0.2.2

2013-06-24 Thread dennis zhuang
An opensource memcached client for clojure wrapping xmemcachedhttp://code.google.com/p/xmemcached/.It released 0.2.2, added 'clj-json-transcoder' that encode/decode values using clojure.data.json. https://github.com/killme2008/clj-xmemcached -- 庄晓丹 Email:killme2...@gmail.com

Re: Unnecessary boxing with 1.5?

2013-06-24 Thread Andy Fingerhut
You have what is likely an undesired right paren at the end of the let line, ending the scope of the let. Andy On Mon, Jun 24, 2013 at 4:32 PM, Cedric Greevey cgree...@gmail.com wrote: (defn foo [x y z] (let [x (long x) y (long y) z (long z)]) (loop [a false b (long 0)] (if a b

Re: Unnecessary boxing with 1.5?

2013-06-24 Thread Cedric Greevey
Huh. How did that happen? And why didn't my IDE indent the code differently, making the problem obvious? On Tue, Jun 25, 2013 at 12:48 AM, Andy Fingerhut andy.finger...@gmail.comwrote: You have what is likely an undesired right paren at the end of the let line, ending the scope of the let.

Re: Lazy seq race condition?

2013-06-24 Thread Carlo Zancanaro
On Mon, Jun 24, 2013 at 4:17 PM, Cedric Greevey cgree...@gmail.com wrote: Ah, thanks. The locking granularity is local to the cons cell (or analogue; first/rest pair) being realized, I hope? So one thread actually calculates an element and neither call returns until it's calculated, and then