Re: Generalizing -> and ->> forms

2015-08-28 Thread Moe Aboulkheir
On Fri, Aug 28, 2015 at 11:51 PM, Alan Thompson wrote: > I have become very partial to a simple adaptation of as-> from the Tupelo > Core library. I almost always like > to be explicit about the location the previous value, since either -> or > ->> can someti

Re: Generalizing -> and ->> forms

2015-08-28 Thread Matching Socks
The parameter order of as-> makes it convenient to use *inside *-> so you can name the threaded parameter only where it needs naming: (-> "UFOT" (reverse) (->> (apply str)) (string/lower-case) (as-> x (string/replace "slip on a tofu" x "banana peel"))) On Friday, August 28,

Re: Generalizing -> and ->> forms

2015-08-28 Thread Alan Thompson
I have become very partial to a simple adaptation of as-> from the Tupelo Core library. I almost always like to be explicit about the location the previous value, since either -> or ->> can sometimes be difficult if the threading forms don't always want the arg

Interest in a book on Nathan Marz's Specter?

2015-08-28 Thread Brian Marick
Specter https://github.com/nathanmarz/specter is a library for querying and "updating" data structures. For most things, I prefer it to zippers or hand-written descent functions. Specter's approach is similar to lenses, but I find it easier to understand and more featureful. When starting out,

Re: [ANN] Yagni 0.1.4 released

2015-08-28 Thread W. David Jarvis
A link to the project page might not have been a bad idea: https://github.com/venantius/yagni On Friday, August 28, 2015 at 9:59:25 AM UTC-7, W. David Jarvis wrote: > > Happy to announce the long-delayed release of Yagni 0.1.4! > > This release includes the following major changes: > > * Fixed

[ANN] Yagni 0.1.4 released

2015-08-28 Thread W. David Jarvis
Happy to announce the long-delayed release of Yagni 0.1.4! This release includes the following major changes: * Fixed a ClassNotFound exception when Yagni encountered a function with a name like a class constructor (e.g. `->Something`) * Removed the log4j dependency entirely. * Cleaned up th

Strange eval behavior making Java types more generic

2015-08-28 Thread psfblair
I'm pretty new to Clojure, so please bear with me if this is obvious for some reason. Maybe the answer is out there and I've been looking in the wrong place. I'm seeing some strange behavior losing type information when using eval in certain circumstances. Here is an example: Eval-ing a Timest

Re: Generalizing -> and ->> forms

2015-08-28 Thread Akhil Wali
​Good one! On Fri, Aug 28, 2015 at 6:34 PM, Moe Aboulkheir wrote: > The function is actually shorter without cond->: (conj (if first? args > (vec args)) x) -- Akhil Wali # https://github.com/darth10 # https://darth10.github.io -- You received this message because you are subscribed to t

Re: Generalizing -> and ->> forms

2015-08-28 Thread Moe Aboulkheir
The function is actually shorter without cond->: (conj (if first? args (vec args)) x) Take care, Moe On Fri, Aug 28, 2015 at 1:59 PM, Akhil Wali wrote: > That's pretty neat! > But then -> will be implemented using cond->, which is slightly off. > > On Friday, August 28, 2015 at 6:07:46 PM UTC+5

Re: Generalizing -> and ->> forms

2015-08-28 Thread Akhil Wali
That's pretty neat! But then -> will be implemented using cond->, which is slightly off. On Friday, August 28, 2015 at 6:07:46 PM UTC+5:30, Moe Aboulkheir wrote: > > On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali > wrote: > >> >> This does work, but it's a bit of whammy. >> Anyone with suggestions

Re: Generalizing -> and ->> forms

2015-08-28 Thread Moe Aboulkheir
On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali wrote: > > This does work, but it's a bit of whammy. > Anyone with suggestions for improvement? > I went over this quickly, though it seems to work OK: (defn threading [x first? forms] (reduce (fn [x form] (if (seq? form) (let [[op &

Re: Generalizing -> and ->> forms

2015-08-28 Thread Akhil Wali
> > It doesn't appear to work for simple cases (where the expressions > aren't function calls w/ additional arguments), e.g. (-> 1 inc) Thanks for that one. How silly of me :P Here's a better version of threading. (defmacro threading [a b x forms] (loop [x x forms forms] (if fo

Re: Generalizing -> and ->> forms

2015-08-28 Thread Akhil Wali
​On Fri, Aug 28, 2015 at 5:33 PM, Atamert Ölçgen wrote: > Also, you know about as->, don't you? ​Well, I'm aware of all other threading forms like some->, as->, etc. This is just something I'm trying ​with -> and ->>, and thought I'd discuss. Perhaps the definition of as-> can be used as a be

Re: Generalizing -> and ->> forms

2015-08-28 Thread Atamert Ölçgen
Hi, threading doesn't need to be a macro. In fact it would be easier to test if it's just a function. Also, you know about as->, don't you? On Fri, Aug 28, 2015 at 2:37 PM, Akhil Wali wrote: > I've been trying to refactor the -> and ->> forms to use a common macro > form. > Ended up with this

Re: Generalizing -> and ->> forms

2015-08-28 Thread Moe Aboulkheir
On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali wrote: > This does work, but it's a bit of whammy. > Anyone with suggestions for improvement? It doesn't appear to work for simple cases (where the expressions aren't function calls w/ additional arguments), e.g. (-> 1 inc) Take care, Moe -- You re

Generalizing -> and ->> forms

2015-08-28 Thread Akhil Wali
I've been trying to refactor the -> and ->> forms to use a common macro form. Ended up with this. (defmacro threading [a b x forms] (loop [x x forms forms] (if forms (let [form (first forms) f (first form) r (rest form) threaded (if (seq? f