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))
(take some-number-of-elements))
Dňa streda, 21. mája 2014 18:23:06 UTC+2 Colin Yates napísal(-a):
>
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.