It's an elegant puzzle. Thanks Sean!

Here's my take:
(defn sift [pred? s]
  (lazy-seq
    (if (seq s)
      (let [key (first s)
            [vals remaining] (split-with #(not (pred? %)) (rest s))]
        (cons [key vals] (sift pred? remaining))))))

Running:
(sift string? ["a" 2 "b" 3 4 "c" "d" 4])

Returns:
(["a" (2)] ["b" (3 4)] ["c" ()] ["d" (4)])

I'm interested in what you came up with. =)
  -Patrick

-- 
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

Reply via email to