According to the docs the range
function has four forms:
(range)
0 - Infinity(range end)
0 - end(range start end)
start - end(range start end step)
start - end skipping by stepSo how would I declare a range representing x
to Infinity?
I may also be asking how do reference infinity, as something like (range x infinity)
might work?
(iterate inc x)
will give you a lazy, infinite sequence of numbers starting with x
.
How about something like this:
(defn my-range
([start] (iterate inc' start))
([start step] (iterate #(+' % step) start)))
Please note inc'
and +'
to support arbitrary precision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With