"some" is already lazy, so you may not need to change anything at
all.  You might also be able to use "filter", which will not do
anything until you consume the output sequence.
-Stuart Sierra


On Jan 11, 4:44 pm, samppi <rbysam...@gmail.com> wrote:
> Let's say I have a function, alt:
>
> (defn alt [& functions]
>   (fn [tokens]
>     (some #(% tokens) functions)))
>
> It creates a function from a bunch of sub-functions that accepts one
> collection of tokens and figures out which sub-function returns a true
> value when the tokens are plugged into it.
>
> Is there a way to change alt—maybe to a macro—that lazily evaluates
> the functions? This is so that with:
>
> (defn a-meta-meta-function [c]
>   (alt (sub-function1 c) (sub-function2 c) (sub-function3 c)))
>
> ...calling ((a-meta-meta-function foo) some-tokens) doesn't evaluate
> (sub-function 2 c) and (sub-function3 c) until needed to receive some-
> tokens.
--~--~---------~--~----~------------~-------~--~----~
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
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