Fix Python 2 issue in take-nth

It was trying to `return` a value in a generator, which Python 2 forbids.
This commit is contained in:
Kodi Arfer 2017-02-04 11:20:01 -08:00
parent 3ec919278d
commit 9f4b630e14

View File

@ -419,14 +419,13 @@
(defn take-nth [n coll]
"Return every nth member of coll
raises ValueError for (not (pos? n))"
(if (pos? n)
(do
(if (not (pos? n))
(raise (ValueError "n must be positive")))
(setv citer (iter coll) skip (dec n))
(for* [val citer]
(yield val)
(for* [_ (range skip)]
(next citer))))
(raise (ValueError "n must be positive"))))
(defn zero? [n]
"Return true if n is 0"