I'm not aware of such a construct, but it's trivial enough to write
something like this using `range` or perhaps write a function that will
yield a lazy seq:
(defn inf-list
([x y]
(cons x (cons y (inf-list x y 2))))
([x y c]
(cons (+ x (* c (- y x)))
(lazy-seq (inf-list x y (inc c))))))
No macros required
On Tue, Dec 13, 2016 at 9:14 PM, bill nom nom <[email protected]>
wrote:
> In Haskell, I can get an infinite lazy list that is incremented by two by,
> starting at 4
> [4,6..]
>
> which yields the result
> [4,6,8,10...]
>
> the more general form
> [x,y..] produces [x, x + (y-x), x + 2 * (y-x), x + 3 * (y-x)...]
>
> Is there a way to make a macro of this in clojure, or is there something
> already as elegant?
>
> --
> 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.
>
--
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)
--
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.