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 valu
On Tue, May 31, 2011 at 3:45 PM, iz bash wrote:
>
> thanks everyone!! that was really great help.
You're welcome.
Hopefully, reading and understanding the code posted here (not just
mine) will both get you a better grasp of the various ways these kinds
of things can be tackled using HOFs like ma
thanks everyone!! that was really great help.
--
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 u
For this particular case, you could also use regexps:
user> (require '[clojure.string :as s])
nil
user> (s/replace " bb cc" #" +" " ")
" bb cc"
Regards,
Stuart
On 31 May 2011 08:15, iz bash wrote:
> so clojures like my first programming language. most of the time
> now ,i
On May 30, 6:15 pm, iz bash wrote:
> how'd you implement it using only higher order functions?
> (rem-dup " bb cc") => [\a \a \a \a \space \b \b
> \space \c \c]
(defn rem-dup [stri]
(->> stri
(partition-all 2 1)
(filter (partial apply not= \space))
(map fir
On Mon, May 30, 2011 at 11:29 PM, Alan Malloy wrote:
> (filter identity (map f xs)) is more clearly written as (keep f xs),
> unless you're relying on the former to retain false (not nil) elements.
Eh -- filter identity doesn't retain false:
=> (filter identity [false nil 42 "foo" []])
(42 "foo"
On May 30, 7:56 pm, Ken Wesson wrote:
> On Mon, May 30, 2011 at 6:15 PM, iz bash 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
On Mon, May 30, 2011 at 6:15 PM, iz bash 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 situati
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 functi