Using seq-utils...

1.  Assume " " is NOT empty
2.  Use partition-by to split
3.  Use remove to clean up
4.  Map!

user=>(map (partial apply str)
  (remove (comp empty? first)
    (partition-by empty? ["a" "" "b" "c"])))
("a" "bc")

I think this satisfies you conditions.

Sean

On Jan 29, 10:25 am, Wilson MacGyver <wmacgy...@gmail.com> wrote:
> I saw this on twitter.
>
> http://pastie.org/796264
>
> The problem: given a list of strings, produce a list where sequential
> non-empty strings are concatenated
>
> # Conditions: Do not use iteration.
> #
> # Example: glom (["a", "b", "c"]) = ["abc"]
> #          glom (["a", "", "b"]) = ["a", "b"]
> #          glom (["a", "b", "", "c"]) = ["ab", "c"]
> #          glom (["a", "b", "", "", "c"]) = ["ab", "c"]
>
> The author had rules like, don't use iteration and avoid recursion.
>
> anyone have any clever solutions? My first reaction was to use reduce, but
> I'm not sure how that'd work.
>
> --
> Omnem crede diem tibi diluxisse supremum.

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