Hi, Joerg. When I have a sequence I want to split into sub-sequences, I use the partition.* functions: (->> your-seq (partition-by string?) (partition 2)) will get you very close to your solution.
A slightly lower-level technique if you need more control is to construct a lazy sequence yourself. Refer to the source of the partition fns, e.g. (clojure.repl/source partition-by) I think a combination of lazy-seq with (split-with sequential?) would work. Yet another option is to see if it is cleaner to change the original xml parsing function to give you the nested data structure you want directly. Happy coding, Leif On Monday, February 17, 2014 5:50:13 PM UTC-5, Joerg wrote: > > Hi, > > From a for-function over some xml-input (filtered and mapped), I get this > list: > > ("ITEM2" ["ITEM1"] ["B"] "A" "ITEM1" ["C"]) > > Now what I want is: > > ((myfunc ITEM2 ITEM1) (myfunc ITEM2 B) (myfunc ITEM1 C)) > > that is.. every string can have 0 or more vectors as follow-up items > The String "A" has not, so ideally it is not in my resulting list, but > filtering the "A" would be a minor issue anyway > > Searching for a transformation, I always get into thinking about > loop-recur constructs, > but I think there maust be a simpler solution for this. > > group-by and split-with don't seem to fit here > > Best, > Joerg > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.