Counting without numbers
I was writing something along these lines:
(loop [state init, n (count some-seq)]
(if (pos? n)
(recur value (dec n))
(ends here)))
when it struck me that seqs are numerals too!
(loop [state init, n some-seq]
(if (seq n)
(recur value (rest n))
(ends here)))
or:
(loop [state init, n (seq some-seq)]
(if n
(recur value (next n))
(ends here)))
Hi there, always i used to check weblog posts here early in the morning, for the reason that i love to learn more and more.|