Re: (Newbie) simple tack

2008-11-19 Thread Brian Doyle
I like this solution as well. You have to pull in the seq-utils for the indexed function though. (use 'clojure.contrib.seq-utils) (defn nonzero-idxs [s] (for [[i n] (indexed s) :when (and n (not (zero? n)))] i)) On Wed, Nov 19, 2008 at 10:39 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > >

Re: (Newbie) simple tack

2008-11-19 Thread Rich Hickey
On Nov 19, 11:18 am, capricorn20 <[EMAIL PROTECTED]> wrote: > I want create seq which keep indexes of non-zero elements of > collection. > Code: > > (defn nonzero-inx [s] > (filter (fn [x] (not (nil? x))) (map (fn [a b] (if (not (== a 0)) > b)) s (range (count s) > > look complicated than

(Newbie) simple tack

2008-11-19 Thread capricorn20
I want create seq which keep indexes of non-zero elements of collection. Code: (defn nonzero-inx [s] (filter (fn [x] (not (nil? x))) (map (fn [a b] (if (not (== a 0)) b)) s (range (count s) look complicated than solution in most imperative languages. May be possible simplest way in Clojure