Re: Pattern of Succinctness

2012-08-13 Thread dmirylenka
Using threading operators + anonymous functions sometimes yields more succinct code than using HOF, especially because 'partial' and 'comp' are such long names: (comp count (partial filter nil?) (partial map foo)) #(->> % (map foo) (filter nil?) count) On Sunday, August 12, 2012 7:35:16 PM UT

Re: Pattern of Succinctness

2012-08-13 Thread dmirylenka
Should be (filter (comp not nil?) coll) On Sunday, August 12, 2012 9:44:11 PM UTC+2, Pierre-Henry Perret wrote: > > I prefer (filter (partial not nil?) coll) as a HOF > > Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit : >> >> On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi

Re: Pattern of Succinctness

2012-08-12 Thread Alan Malloy
This doesn't work. On Sunday, August 12, 2012 12:44:11 PM UTC-7, Pierre-Henry Perret wrote: > > I prefer (filter (partial not nil?) coll) as a HOF > > Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit : >> >> On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: >> > > (fil

Re: Pattern of Succinctness

2012-08-12 Thread Pierre-Henry Perret
I prefer (filter (partial not nil?) coll) as a HOF Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit : > > On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: > > > (filter (partial not nil?) coll) > > You mean (filter (comp not nil?) coll). > > I'm not sure which is mo

Re: Pattern of Succinctness

2012-08-12 Thread Robert Marianski
On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: > > (filter (partial not nil?) coll) > You mean (filter (comp not nil?) coll). > I'm not sure which is more readable, but thanks for Meikel and Alex, I now > prefer (remove nil? coll). remove is better in this case, but for posterit

Re: Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
> (filter (partial not nil?) coll) You mean (filter (comp not nil?) coll). I'm not sure which is more readable, but thanks for Meikel and Alex, I now prefer (remove nil? coll). Thanks. On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote: > > Is the last one considered gene

AW: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
m Gesendet: So, 12 Aug 2012, 19:35:16 MESZ Betreff: Pattern of Succinctness Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let m

Re: Pattern of Succinctness

2012-08-12 Thread Alex Baranosky
(filter identity foos) and (filter #(not (nil? %)) foos) aren't equivalent. I prefer (remove nil? foos) Succint and direct. On Sun, Aug 12, 2012 at 11:13 PM, Bill Caputo wrote: > > On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote: > > (filter #(not (nil? %)) coll) >> (filter identity coll) ;;

AW: Re: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
Hi, in case you really want only nils filtered out: (filter (complement nil?) coll) or (remove nil? coll) Kind regards Meikel -Ursprüngliche Nachricht- Von: Bill Caputo An: Tamreen Khan Cc: clojure@googlegroups.com Gesendet: So, 12 Aug 2012, 19:43:58 MESZ Betreff: Re: Pattern of

Re: Pattern of Succinctness

2012-08-12 Thread Bill Caputo
On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote: > (filter #(not (nil? %)) coll) > (filter identity coll) ;; nearly equal > Is the last one considered generally more readable? I think the following is > clearer while still not having as much noise as the first filter example: > > (filter (part

Re: Pattern of Succinctness

2012-08-12 Thread Tamreen Khan
Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi wrote: > Hi, > I would like to know common technics that make c

Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received this message