Maybe not what you're looking for, but this is my take on this particular problem:
(defn rem-dup [str] (->> str (partition-by (partial = \space)) (map #(if (= (first %) \space) \space %)) flatten)) I find partition-by the 'weapon of choice' when a sequence contains values that needs to be distinguished from the rest (such as spaces). This makes the code pretty simple to understand. The partition-by statement clearly says that spaces should be in one group, and the rest should be in another group. Jonathan On Tue, May 31, 2011 at 12:15 AM, iz bash <killernemesisbl...@gmail.com>wrote: > so clojures like my first programming language. most of the time > now ,i use map /reduce/.. with lazy sequences but sometimes i just > cant seem to find a solution other than using loop-recur. then i read > somewhere almost all loop recur situations can be translated into > reduce. so ive posted a function below...how'd you implement it using > only higher order functions? > > > (defn rem-dup [stri] > (loop [[x y & z] (seq stri) ,bui []] > (cond (nil? x) bui > (= x y \space) (recur (cons y z) bui) > :else (recur (cons y z) (conj bui x))))) > > > (rem-dup "aaaa bb cc") => [\a \a \a \a \space \b > \b \space \c \c] > > also itd be great if you guys could give some pointers on using higher > order functions and lazy sequences in place of a loop recur. > > Thanks!! > and btw clojures totally awesome :) > > -- > 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 -- 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