Hi Micheal, Am 22.04.2009 um 21:18 schrieb Michael Wood:
Your version gives the same answer as mine, but I believe what he wants is something that skips over all the elements that pass the test and only inserts one instance of o after them. That's why in his example there is not a :foo after 1, but only after 5. Laurent's version gets this right.
Oops. Sorry, misread the message. Another try. (defn mystery-function [f o s] (let [step (fn step [b s] (lazy-seq (if-let [s (seq s)] (let [fst (first s)] (cond (and (f fst) b) (cons fst (step b (rest s))) b (cons o (step false s)) :else (cons fst (step (f fst) (rest s))))) (when b (list o)))))] (step false s))) Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature