On Wed, Aug 3, 2011 at 7:03 AM, Chris Rosengren <christopher.roseng...@gmail.com> wrote: > Hi, I'm using an iterative function to do this now but I would like to > start programming in a more functional style > > I have an ordered (ascending) distinct sequence 1 4 5 34 36 38 53 55 > 59 62 > How would I write a function in a functional style that returns the 1- > gaps (integer directly on either side)? > > For the above sequence it should return (35 37 54) > > Thanks.
(filter identity (map #(if (= (+ 2 %1) %2) (inc %1)) s (rest s))) oughta do it. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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