Re: Example in Joy of Clojure, 2nd edition (MEAP)

2014-02-16 Thread gianluca torta
as a side note, since we are within the backquote, simply using r (instead of ~'r) would not work since it would incorrectly expand to the fully qualified symbol, e.g. user/r Gianluca On Saturday, February 15, 2014 5:49:57 PM UTC+1, Jan Herich wrote: Hello Eric, You can rewrite this

Re: use/require/import and quoted form

2014-02-16 Thread Andy Smith
(require 'clojure.string) Im just wondering why the language chose to use the quote form, rather than a string or a keyword e.g. (require clojure.string) (require :clojure.string) There obviously must be a good reason why. -- You received this message because you are subscribed to the

Re: NetBeans?

2014-02-16 Thread Rui Carmo
In case anyone's interested, I've picked up Geertjan's stuff and started a repo at https://github.com/rcarmo/netbeans-clojure, since it's minimally usable already. There's a tentative roadmap there as well -- feel free to ping me directly if you want commit access. Regards, R. On Friday,

Re: fast parallel reduction into hash-set/map

2014-02-16 Thread Jules
Thanks, Mikera You are right about merge: user= (def m1 (apply hash-map (range 1000))) #'user/m1 user= (def m2 (apply hash-map (range 500 1500))) #'user/m2 user= (time (def m3 (merge m1 m2))) Elapsed time: 5432.184582 msecs #'user/m3 user= (time (def m4

Re: fast parallel reduction into hash-set/map

2014-02-16 Thread Mikera
Wow - that's a pretty big win. I think we should try and get this into Clojure ASAP. Are we too late for 1.6? On Sunday, 16 February 2014 18:48:09 UTC+8, Jules wrote: Thanks, Mikera You are right about merge: user= (def m1 (apply hash-map (range 1000))) #'user/m1 user= (def m2

Re: fast parallel reduction into hash-set/map

2014-02-16 Thread Jules
I would have thought so - it's only my first cut - seems to work but I wouldn't like to stake my life on it. It really needs a developer who is familiar with PersistentHashMap to look it over and give it the thumbs up...Still, I guess if it was marked experimental ...:-) Jules On Sunday, 16

Re: fast parallel reduction into hash-set/map

2014-02-16 Thread Jules
Thinking about it a bit more, it would be good to have an interface e.g. Spliceable which e.g. 'into' could take advantage of when it found itself concatenating two seq of the same implementation... Further digging might demonstrate that a similar trick could be used with other seq types ?

Re: use/require/import and quoted form

2014-02-16 Thread James Reeves
Symbols are used in Clojure to represent identifiers, and in this case we're identifying a namespace. I believe it's also the case that a valid symbol is also a valid namespace name. - James On 16 February 2014 10:39, Andy Smith the4thamig...@googlemail.com wrote: (require 'clojure.string)

Some advice about introducing clojurescript into a project using js/jquery

2014-02-16 Thread Kashyap CK
Hi, It took me some time to get started with clojurescript (on windows/cygwin) - http://swannodette.github.io/2013/11/07/clojurescript-101/ worked for me. I'd like to use clojurescript to do some UI component development for product which is built using webkit/js/jquery. I was wondering if it

Re: [ANN] lispy.el 0.8: jump to any Clojure tag in current directory screencast

2014-02-16 Thread Olli Piepponen
This looks very neat, but I was unable to figure out how to use lispy/clojure-semantic the way you were doing in your screencast. Could you give a breakdown of how this works? On Saturday, February 15, 2014 4:46:48 AM UTC+7, Oleh wrote: Hi all, As a follow-up to this post -

rseq for subvec in clojurescript

2014-02-16 Thread Sunil S Nandihalli
Hi Everybody, I get the following error when I do a rseq on a subvec in clojurescript Uncaught Error: No protocol method IReversible.-rseq defined for type cljs.core/Subvec: [(:red :clockwise) (:blue :clockwise) (:yellow :clockwise) (:yellow :clockwise) (:orange :clockwise)] Is this a known

Re: [ANN] Clojure 1.6.0-beta1

2014-02-16 Thread Alex Walker
Part of Rich's objection to not-nil? variants could be that they are a double negative, not-(no value)?, which can decrease clarity and require more coffee. - nil Means 'nothing/no-value'- represents Java null and tests logical false [clojure.org/reader] To compete with some?

[ANN] typed-clojure-mode emacs plugin

2014-02-16 Thread Ambrose Bonnaire-Sergeant
Hi, Happy to announce the first version of typed-clojure-modehttps://github.com/typedclojure/typed-clojure-mode, an emacs minor mode for Typed Clojure. Thanks to John Walker who wrote the core functionality, he earned this open source

Re: rseq for subvec in clojurescript

2014-02-16 Thread MichaƂ Marczyk
It is now, thanks for the report! Ticket with patch: http://dev.clojure.org/jira/browse/CLJS-765 On 16 February 2014 17:48, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody, I get the following error when I do a rseq on a subvec in clojurescript Uncaught Error: No protocol

Re: java.jdbc 0.3.3 select query exception: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

2014-02-16 Thread The Dude (Abides)
You're right :) When I isolated the issue thanks to some help it turns out java.jdbc is working fine but I wasn't getting the resultset output properly in the function. So got it resolved and working like this: (defn get-member [id] (let [id (parse-int id) member (first

ANN: ring-http-response, ring-Swagger, ring-swagger-ui compojure-api

2014-02-16 Thread Tommi Reiman
Hi all. We here at Metosin have been developing and using a bunch of small utilities for Ring-based web api development. Here they are: *1) ring-http-response *(https://github.com/metosin/ring-http-response) Real http status codes for Ring - ported from Spray[1]. There is a response function

Re: ANN: ring-http-response, ring-Swagger, ring-swagger-ui compojure-api

2014-02-16 Thread Gary Trakhman
I was inches away from reinventing something like this for our company's codebase. Maybe you saved us the trouble :-). Will definitely check it out. On Sun, Feb 16, 2014 at 3:20 PM, Tommi Reiman tommi.rei...@gmail.comwrote: Hi all. We here at Metosin have been developing and using a bunch

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread t x
Hi John, Your solution is perfectly valid and optimal for the problem I described above. Unfortunately, I forgot to mention an additional constraint: sometimes I do: (let [ foo (:some-selector @data-atom) ] (swap! data-atom update-in [:other-selector] ... )) which the - doesn't quite

Re: Clojure code for detecting overlap of 3d shapes (specifically tetrahedra)?

2014-02-16 Thread Karsten Schmidt
Yer welcome please do let me know how this works out for you! I've updated the gist[1] to delay more parts of the whole computation and replace most occurrences of `reduce` with `loop` - altogether leading to an almost 2x faster result for the worst case scenario where all test clauses are

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread Ramesh
You can use a ref instead of an atom. And use dosync with multiple alter, so everything is safely inside a transaction. On Feb 16, 2014 2:04 PM, t x txrev...@gmail.com wrote: Hi John, Your solution is perfectly valid and optimal for the problem I described above. Unfortunately, I

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread t x
I believe that's the STM approach, which has the advanrtage of: * can synchronize across multiple pieces of data but has the disadvantage of: * work must be pure since it can be retried * possibly less efficient due to possibility of retrying In the example I posted above, I only need

Looking for advice to fine tune a simple function

2014-02-16 Thread Laurent Droin
Hi, Disclaimer - I am completely new to Clojure. I just implemented my very first (simple) program, letting me find out, from a GPX file, how much time is spent in the various heart rate zones. Now that it's working, I'm reviewing the code and trying to use best practices. From what I have

Latex style file for formatting/coloring clojure code?

2014-02-16 Thread Mark Engelberg
I am unable to find a style file that supports clojure code in LaTeX. Can anyone point me in the right direction? Thanks, Mark -- 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

Re: Looking for advice to fine tune a simple function

2014-02-16 Thread gianluca torta
to me it seems that you are anyway relying on the assumption that the sequence is ordered, so I think it would be convenient to drop the ands Gianluca On Sunday, February 16, 2014 11:31:46 PM UTC+1, Laurent Droin wrote: Hi, Disclaimer - I am completely new to Clojure. I just implemented my

Re: Looking for advice to fine tune a simple function

2014-02-16 Thread Andy-
I'm also very new to clojure but this is how I'd do it: (def hr-zones { [0 100] :low [101 120] :fat-burn [121 140] :aerobic [141 160] :anaerobic [161 333] :max}) (defn hr-zone [hr] (some (fn [x] (and (= (first (key x)) hr (second (key x))) (val x))) hr-zones))

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread Jan Herich
I'm afraid your understanding of atom swap! operations is not quite correct - update function must (or should) be pure as well. See the documentationhttp://clojuredocs.org/clojure_core/clojure.core/swap!for swap!, update function could be potentially called multiple times if there are more

Re: Some advice about introducing clojurescript into a project using js/jquery

2014-02-16 Thread Dave Sann
It works pretty seamlessly. You will need to include a jquery externs file to avoid munging of function call names by the google closure compiler in advanced mode. See also https://github.com/ibdknox/jayq Which adds a few simplifications to usage (particularly some protocols for jQuery

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread t x
Hi Jan, You're right. I'm wrong. I'm grateful you pointed this out -- this would have otherwise been impossible to debug. === To everyone: Why can swap! be retried? This confuses me -- to implement swap!, why can't we * have a lock * ensure that only one

Re: Looking for advice to fine tune a simple function

2014-02-16 Thread Andy-
I realized I could use that at some of my code so I wrote it. Not sure if it's the best possible implementation but here it is: (defn quantizer Returns a function that quantizes input data which when called with 'x' returns: o 1st val if-Inf x = 1st bound o 2st val if 1st bound

Re: [ANN] Clojure 1.6.0-beta1

2014-02-16 Thread Mars0i
I like Alex's suggestions. Another option is something rather than some or exists. Something has the disadvantage that it's long, so when you combine it with addition strings, you get something even longer. On the other hand, for me both some and exists sound like existential quantifiers

Re: Some advice about introducing clojurescript into a project using js/jquery

2014-02-16 Thread Dave Della Costa
Just because you are using jQuery extensively in your JS codebase doesn't mean you need jayq/jQuery in your ClojureScript code. If you are trying to do inter-op and call some of your JavaScript code from your ClojureScript code, then you can simply use standard JavaScript inter-op; if you want to

Re: Latex style file for formatting/coloring clojure code?

2014-02-16 Thread Andy-
On Sunday, February 16, 2014 6:05:24 PM UTC-5, puzzler wrote: I am unable to find a style file that supports clojure code in LaTeX. Can anyone point me in the right direction? Pygments can output LaTeX. (There is also minted) HTH -- You received this message because you are subscribed to

Re: Some advice about introducing clojurescript into a project using js/jquery

2014-02-16 Thread Kashyap CK
Thank you Dave and David, Regards, Kashyap On Monday, February 17, 2014 8:26:25 AM UTC+5:30, David Della Costa wrote: Just because you are using jQuery extensively in your JS codebase doesn't mean you need jayq/jQuery in your ClojureScript code. If you are trying to do inter-op and call

Re: Looking for advice to fine tune a simple function

2014-02-16 Thread Bruno Kim Medeiros Cesar
I can't claim to be an experienced Clojure developer, specially so regarding maintainability as I'm the only reader of what I write. Andy provided a great piece of code, although I scratched my head for a second or two unwrapping the last two lines. You'll be surprised how often (partition *

Re: (series of swap! on atom) == single swap!

2014-02-16 Thread Jan Herich
Hi t x, I think, that lock-free approach an it's semantics is more in line with other Clojure reference types such as refs. It also encourages you to only use pure functions for state transitions, among other things, such as significant performance benefits in comparison with lock based