Re: weird bug with cljs.core.async + macros

2014-02-17 Thread t x
Building on Michal's example, here is a "more minimal example" -- which also "fails" in Clojure: (ns test (:require [clojure.core.async :as async])) (defmacro silly [obj pat1 body1 other] `(case ~obj ~pat1 ~body1 ~other)) (let [] (def out (java.io.StringWriter.)) (defn log

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
Hmmm, looks like I can replace #(not (nil? %)) by (complement nil?) which seems more elegant. Also, it looks like I don't need that (into [] ), which will keep the code cleaner. I think I could also get rid of the (or) by always adding "(last params)" at the end of the sequence from which I

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
So here is a new attempt at the quantize function so that I no longer have to deal with the "infinity" problem: (defn quantize-2 [x params] (let [f (partial (fn [a [b c]] (cond(<= a c) b)) x)] (or (first (filter #(not (nil? %)) (map f (into [](partition 2 params) (last p

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
So here is a new attempt at the quantize function so that I no longer have to deal with the "infinity" problem: (defn quantize-2 [x params] (let [f (partial (fn [a [b c]] (cond(<= a c) b)) x)] (println (first (filter #(not (nil? %))(map f (into [](partition 2 params)) (or

Re: rseq for subvec in clojurescript

2014-02-17 Thread Sunil S Nandihalli
thanks Michal for the fix. On Mon, Feb 17, 2014 at 12:58 AM, Michał Marczyk wrote: > 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 > wrote: > > Hi Everybody, > > > > I get the followin

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
So here is a new attempt at the quantize function so that I no longer have to deal with the "infinity" problem: (defn quantize-2 [x params] (let [f (partial (fn [a [b c]] (cond(<= a c) b)) x)] (or (first (filter #(not (nil? %)) (map f (into [](partition 2 2 params))) (las

Re: Grouping a list by 'sublists'..

2014-02-17 Thread Leif
Hi, Joerg. When I have a sequence I want to split into sub-sequences, I use the partition.* functions: (->> your-seq (partition-by string?) (partition 2)) will get you very close to your solution. A slightly lower-level technique if you need more control is to construct a lazy sequence yourself

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
All good points Andy. Thanks. I'll continue working on it until I'm happy. I am almost never happy with anonymous functions either. In this particular case, though, the function is so simple that I felt it would be overkill to externalize it into another function (unless I'm really going to use

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread t x
Hi Michal, Does this mean: (a) the reported behavior is normal (and my bug report is invalid) or (b) this error happens in both cljs + clojure ? Thanks! On Mon, Feb 17, 2014 at 4:33 PM, Michał Marczyk wrote: > Just to be clear, the above is a version of t x's bug-report modified > to us

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Andy-
On Monday, February 17, 2014 6:43:18 PM UTC-5, Laurent Droin wrote: > > > (def inf Long/MAX_VALUE) > (defn quantize > [x markers values] > (let > [f (partial (fn([%1 %2 %3] (cond (<= %1 %2) %3))) x)] > (first (filter #(not (nil? %))(map f (conj markers inf) values) > > The reason I

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread Michał Marczyk
Just to be clear, the above is a version of t x's bug-report modified to use a StringWriter instead of console.log. Cheers, Michał On 18 February 2014 01:25, Michał Marczyk wrote: > The same thing happens in Clojure: > > (defmacro silly [object pat1 body1 pat2 body2] > `(case (:tag ~object) >

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread Michał Marczyk
The same thing happens in Clojure: (defmacro silly [object pat1 body1 pat2 body2] `(case (:tag ~object) ~pat1 ~body1 ~body2)) (def out (java.io.StringWriter.)) (defn log [& args] (doseq [arg args] (.write out (str arg)) (.write out "\n"))) (defn init [] (silly {:tag :dog

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread t x
Thanks for verifying! @tbaldridge: can you enlighten us on if: * I'm doing something stupid or * this is an actual bug in cljs/core.async? Thanks! On Mon, Feb 17, 2014 at 2:10 PM, Manuel Paccagnella wrote: > Tested on Linux x64, Chromium 31.0.1650.63 and Firefox 26.0. Same behaviour > that

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
All the good feedback here had me thinking a lot... Especially Andy who pushed me towards more abstraction. I loved the idea of functions that return functions and researching all this led me to embrace "partials". Here is my current implementation of "quantize". It came out of a lot of trial a

Re: Grouping a list by 'sublists'..

2014-02-17 Thread Joerg
so, each string(type) is used as a grouping-key, which prefixes every each following string-in-a-vector as an argument to myfunc in the result list. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Grouping a list by 'sublists'..

2014-02-17 Thread Joerg
Hi, >From a for-function over some xml-input (filtered and mapped), I get this list: ("ITEM2" ["ITEM1"] ["B"] "A" "ITEM1" ["C"]) Now what I want is: ((myfunc ITEM2 ITEM1) (myfunc ITEM2 B) (myfunc ITEM1 C)) that is.. every string can have 0 or more vectors as follow-up items The String "A" has

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread Manuel Paccagnella
Tested on Linux x64, Chromium 31.0.1650.63 and Firefox 26.0. Same behaviour that you have seen. However, I haven't looked at the code yet. Il giorno lunedì 17 febbraio 2014 20:34:22 UTC+1, t x ha scritto: > > Can anyone verify whether this bug is reproducible? > > On Mon, Feb 17, 2014 at 12:28 A

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Jules
Glen, I did start the implementation in Clojure, but had to move it under the skin of PersistentHashMap to achieve what I needed, so it is now written in Java and is part of PersistentHashMap... I don't think it would be practical to make it an add-on - but it would be nice :-). I'll keep it in

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Jules
Alex, thanks for the suggestion - I'll look at collection-check and raise the appropriate JIRA when I am happier with the code / idea. Jules On Monday, 17 February 2014 13:21:28 UTC, Alex Miller wrote: > > It is too late, but an enhancement jira would be appropriate. I would > highly encourag

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Jules
I've started doing some more serious testing and have not encountered any problems so far. I was a bit worried about the interaction of splice and transient/persistent!, but have not encountered any problems yet. I am going to read through the code again to satisfy myself that there is no issue

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread t x
Can anyone verify whether this bug is reproducible? On Mon, Feb 17, 2014 at 12:28 AM, t x wrote: > Hi, > > repo: https://github.com/txrev319/bug-report > > I have a really weird bug where: > > * (my-macro ...) ==> everything works > > * (async/go (my-macro ...)) ==> something weird happen

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Johanna Belanger
Thanks for this! On Monday, February 17, 2014 4:49:38 AM UTC-8, Andy- wrote: > > On Sunday, February 16, 2014 11:19:58 PM UTC-5, Bruno Kim Medeiros Cesar > wrote: >> >> (BTW, Andy, how do you format your code so prettily?) >> > I usually just paste it into pygments.org and then paste it back into

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Johanna Belanger
Hi, I'm fairly new to clojure as well, but I like this way, and I *think* it's idiomatic: Data structure: [{:zone-max 100 :zone-key :hr-zone-1} {:zone-max 120 :zone-key :hr-zone-2} {:zone-max 140 :zone-key :hr-zone-3} {:zone-max 160 :zone-key :hr-zone-4} {:zone-max 333 :zone-key :hr-zone-5}

Re: Lein, Speclj & clojure 1.6.0-beta1

2014-02-17 Thread Glen Mailer
:eval-in can be overridden in your project.clj, just add: :speclj-eval-in :subprocess I agree that the default is rather odd - especially when the only reason I'm aware of is "it's a bit faster" Cheers Glen On Monday, 17 February 2014 12:09:13 UTC, Karsten Schmidt wrote: > > Hi all, am tryin

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Glen Mailer
Is there a specific part of this implementation which means it needs to live in core? It would be cool to have this as a library that could be used with existing versions of clojure (I have no idea if enough of the internals are exposed to make this viable) Glen On Saturday, 15 February 2014

Re: [ANN] Clojure 1.6.0-beta1

2014-02-17 Thread Alex Miller
CLJ-700 is a bug, regardless of whether it is marked as alpha or not. This ticket has a strange history of approval statuses (pre-dating my involvement with jira) that caused it not to be included in 1.6 earlier. Unfortunately, I think it is too big a change to consider at this point in 1.6 (d

Re: [ANN] Clojure 1.6.0-beta1

2014-02-17 Thread Herwig Hochleitner
Since transients are no longer marked as alpha, I want to take this (last?) chance to raise an interface question concerning them: Right now, we cannot distinguish whether a transient contains a key with a nik value or if it doesn't contain the key, because contains? doesn't work on transients. Is

Re: clojurescript source maps: chrome's expected behavior, firefox support

2014-02-17 Thread David Nolen
On Mon, Feb 17, 2014 at 3:43 AM, Ransom Williams wrote: > First of all thanks to everyone working on clojure for making web > development suck less. I recently sandboxed a clojure server application, > and the tooling, documentation, and availability of libraries are all > awesome. > > Anyway, I'

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

2014-02-17 Thread icamts
Hi t x and Jan, what about performing the side effect part of the function adding a watch? (They are no more in alpha with the upcoming 1.6.) Cheers, Luca Il giorno lunedì 17 febbraio 2014 09:29:57 UTC+1, t x ha scritto: > > Hi Jan, > > Thanks for your explanations. > > I have no idea how

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
Wow, thanks Gianluco, Andy and Bruno. Lots of good feedback I am trying to process. It's amazing how coming up with a satisfying "functional programing" style function is a complex process when you've been doing imperative programing all your life. It's really a whole different way of thinking.

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Alex Miller
It is too late, but an enhancement jira would be appropriate. I would highly encourage some generative tests in such a patch and perhaps looking at https://github.com/ztellman/collection-check. With simple.check moving into contrib as test.check, we expect to be able to use test.check within Cl

Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Andy-
On Sunday, February 16, 2014 11:19:58 PM UTC-5, Bruno Kim Medeiros Cesar wrote: > > (BTW, Andy, how do you format your code so prettily?) > I usually just paste it into pygments.org and then paste it back into google groups (which accepts the generated HTML). Cheers -- You received this messa

Re: Lein, Speclj & clojure 1.6.0-beta1

2014-02-17 Thread Karsten Schmidt
Oh I just saw that's a known issue with Speclj and its setting of `:eval-in :leiningen` https://github.com/slagyr/speclj/issues/78 I guess i will have to switch to another test framework then... On 17 Feb 2014 12:09, "Karsten Schmidt" wrote: > Hi all, am trying to test out the new hashing appro

Lein, Speclj & clojure 1.6.0-beta1

2014-02-17 Thread Karsten Schmidt
Hi all, am trying to test out the new hashing approach for my datatypes in 1.6 but it seems that even though I'm referring to the latest beta in my project.clj, Speclj is overriding that dependency with 1.5.1 and I can't run my tests. How can I force it to honor my setting and use 1.6.0-beta1? I gu

clojurescript source maps: chrome's expected behavior, firefox support

2014-02-17 Thread Ransom Williams
First of all thanks to everyone working on clojure for making web development suck less. I recently sandboxed a clojure server application, and the tooling, documentation, and availability of libraries are all awesome. Anyway, I'm starting in with a clojurescript client now and want to confirm

Re: fast parallel reduction into hash-set/map

2014-02-17 Thread Jean Niklas L'orange
On Sunday, February 16, 2014 11:49:38 AM UTC+1, Mikera wrote: > > 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? > Yeah, this is probably too late for 1.6 =/ Anyway, cool stuff you got going on here. I'm playing around with s

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

2014-02-17 Thread Jean Niklas L'orange
Hi Mark, On Monday, February 17, 2014 12:05:24 AM UTC+1, puzzler wrote: > > I am unable to find a style file that supports clojure code in LaTeX. Can > anyone point me in the right direction? > I always use Minted for this kind of stuff: See https://code.google.com/p/minted/ It is available i

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

2014-02-17 Thread Oleh
Sure. 1. Setup MELPA: (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/";)) 2. Install `lispy` from MELPA: M-x package-install lispy 3. Get `clojure-semantic` from git: cd ~/git git clon

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

2014-02-17 Thread t x
Hi Jan, Thanks for your explanations. I have no idea how I managed to completely misunderstand clojure/atom for the past few years -- I suspect it's because I never use clojure/STM, and as a result, I've never had an atom roll back on me. I've decided to switch to agents. Thanks again f

weird bug with cljs.core.async + macros

2014-02-17 Thread t x
Hi, repo: https://github.com/txrev319/bug-report I have a really weird bug where: * (my-macro ...) ==> everything works * (async/go (my-macro ...)) ==> something weird happens A minimal failure case is documented at: https://github.com/txrev319/bug-report/blob/master/src/app.cljx