Another option that I've been using a bit recently is:
(->> [(if some-condition? some-thing)
(if some-other-condition? some-other-thing)
...]
(filterv (complement nil?)))
Which when the list of expressions is long (more than 3-4 or so) is the
most readable alternative I've come u
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
> (
Hi Colin,
Have a look at the 'as->' macro, its very helpful in some cases, as:
(-> []
(conj some-element)
(as-> some-seq
(if some-condition? (conj some-seq some-element) some-seq)
(if some-other-condition? (conj some-seq some-other-element)
some-seq))
(t
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)