> On Feb 17, 2015, at 4:39 PM, Colin Jones <[email protected]> wrote:
>
> Sounds almost like a mirror image of `clojure.core/take-nth`, so something
> like this is kind of fun:
>
> (defn drop-nth [n coll]
> (lazy-seq
> (when-let [s (seq coll)]
> (concat (take (dec n) s) (drop-nth n (drop n s))))))
>
I like that drop-nth. Here's my version of lucky:
(defn lucky
"Returns sequence of Lucky numbers less than max"
([max] (when (pos? max) (lucky 1 (range 1 max 2))))
([i acc]
(if-let [n (nth acc i nil)]
(recur (inc i) (drop-nth n acc))
acc)))
The recur in this case loops back to the top.
--
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.