Thanks Herwig, cond-> looks just the ticket. Off the read the core API again :).
On Wednesday, 21 May 2014 17:49:11 UTC+1, Herwig Hochleitner wrote: > > I like to build more complex sequences within the sequence monad, like > this: > > (concat > (when cond1 [start elements]) > main-seq > (when cond2 [end elements])) > > This also composes nicely with function calls. > > Another option for a subset of cases: > > (cond-> start-vec > condition1 (conj end-element1) > condition2 (conj end-element2)) > > kind regards > > > 2014-05-21 18:23 GMT+02:00 Colin Yates <colin...@gmail.com <javascript:>>: > >> I often find myself doing the following: >> >> (let [some-seq [] >> some_seq (if some-condition? (conj some-seq some-element) some-seq) >> some_seq (if some-other-condition? (conj some-seq >> some-other-element) some-seq) >> some_seq etc.]) >> >> In other words building up a sequence which contains the results of >> predicated elements. Building up a where clause in SQL for example. >> >> I experimented with the -> and ->> but that didn't help and just looked >> messier. >> >> How do you handle this pretty common use case? >> >> Thanks! >> >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com<javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/d/optout.