Re: flip in clojure

2015-05-01 Thread Ruslan Prokopchuk
And do not miss https://github.com/LonoCloud/synthread for more complex cases ;-) пятница, 1 мая 2015 г., 2:31:05 UTC+3 пользователь Vagmi Mudumbai написал: > > Hi, > > I was introducing one of my colleagues to clojure[1] and we were > trying to parse the reddit json as an exercise. > > (requi

Re: flip in clojure

2015-04-30 Thread Robert Levy
from https://github.com/rplevy/mostly-useful (not updated in a while) (defn flip "given a function, create a flipped 2-argument function" [f] (fn [a b] (f b a))) (defmacro flop "create a version of a function with a modified arity as specified by a vector of zero-indexed positions, e.g

Re: flip in clojure

2015-04-30 Thread Jony Hudson
Another option is to use `as->` https://clojuredocs.org/clojure.core/as-%3E . It's more verbose ... I kind of like that aspect of it, but it may not be to everyone's taste. Jony On Friday, 1 May 2015 00:31:05 UTC+1, Vagmi Mudumbai wrote: > > Hi, > > I was introducing one of my colleagues to c

Re: flip in clojure

2015-04-30 Thread Sean Corfield
I wonder how many code bases out there have their own variant of `flip`? Here’s ours: (defn flip "Like partial except you supply everything but the first argument." ([f b] (fn [a] (f a b))) ([f b c] (fn [a] (f a b c))) ([f b c d & more] (fn [a] (apply f a b c d more Sean On Apr

Re: flip in clojure

2015-04-30 Thread Ben Wolfson
->> and -> actually play nice with each other in this direction: (-> 4 range (->> (map inc)) last) results in 4, because we end up with (-> (range 4) (->> (map inc)) last) --> (-> (->> (range 4) (map inc)) last) --> (last (->> (range 4) (map inc))) --> (last (map inc (range 4)))

flip in clojure

2015-04-30 Thread Vagmi Mudumbai
Hi, I was introducing one of my colleagues to clojure[1] and we were trying to parse the reddit json as an exercise. (require '(clj-http.client :as client)) (require '(clojure.data.json :as json)) (def ^:const REDDIT-URL "http://reddit.com/r/clojure.json?limit=100";) (def ^:const headers {:heade