Which looks the same as clojure.contrib.seq/reductions to me... -Steve
On 20 Mar 2010, at 13:54, Per Vognsen wrote: > Learn to love scan: http://gist.github.com/338682 > > -Per > > On Sat, Mar 20, 2010 at 12:13 PM, Douglas Philips <d...@mac.com> wrote: >> Hello all, >> I'm new to clojure, but not lisp. >> I'm looking for a functional way to index/number only some items of a >> list. >> >> For example, I know I can do this (indexed is from the contrib seq_utils >> library): >> (using a short example to keep it >> readable) >> (indexed "Now is") >> -> ([0 \N] [1 \o] [2 \w] [3 \space] [4 \i] [5 \s]) >> >> What I would like to do is only index those elements that satisfy some >> predicate, such as: >> (indexed-pred vowel? "Now is") >> -> ([\N] [0 \o] [\w] [\space] [1 \i] [\s]) >> >> I want the counter to only increment when the predicate is true, so just >> filtering out the index on a fully indexed list isn't what I need, it will >> leave holes in the numbering. >> >> >> I'd be OK with the return result being: ([nil \N] [0 \o] [nil \w] [nil >> \space] [1 \i] [nil \s]) >> since a simple map could strip the nils out. >> >> I can't help feeling that the solution is just on the edge of my >> peripheral vision, but I can't see it. >> >> Thanks, >> -Doug >> >> >> P.S. I want to use this to number the instructions in a road rally, where >> the sequence of instructions are interspersed with other notes and items. >> Numbering the vowels in a string is a nice simplification. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with your >> first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> >> To unsubscribe from this group, send email to >> clojure+unsubscribegooglegroups.com or reply to this email with the words >> "REMOVE ME" as the subject. >> > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > To unsubscribe from this group, send email to > clojure+unsubscribegooglegroups.com or reply to this email with the words > "REMOVE ME" as the subject. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.