Hi, here some notes:
On Mar 23, 12:53 pm, Douglas Philips <d...@mac.com> wrote: > (semi-map vowel? list \"Hellow Word\" (iterate inc 1)) > -> (\\H (\\e 1) \\l \\l (\\o 2) \\w \\space \\W (\\o 3) \\r \\d)" I would use vector instead of list in the example since vector is more idiomatic in Clojure. > (if (seq seq1) > (lazy-seq Use when-let (more idiomatic) and move lazy-seq outside to achieve full laziness. Otherwise realisation of the seq is always one step ahead. > (let [[s1 & s1tail] seq1 Don't use this destructuring in this case, because it forces again the realisation of the seq one step ahead. So here is my try: (defn semi-map "Lazy sequence of seq1, optionally combined with seq2. When (pred (first seq1)) item is true, yield (fun (first seq1) (first seq2)) otherwise yield (first seq1) without advancing seq2. Example: (semi-map vowel? vector \"Hellow Word\" (iterate inc 1)) -> (\\H [\\e 1] \\l \\l [\\o 2] \\w \\space \\W [\\o 3] \\r \\d)" [pred f seq1 seq2] (lazy-seq (when-let [seq1 (seq seq1)] (let [fst1 (first seq1)] (if (pred fst1) (cons (f fst1 (first seq2)) (semi-map pred f (rest seq1) (rest seq2))) (cons fst1 (semi-map pred f (rest seq1) seq2))))))) Sincerely Meikel -- 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.