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:
parent
3ec919278d
commit
9f4b630e14
@ -419,14 +419,13 @@
|
|||||||
(defn take-nth [n coll]
|
(defn take-nth [n coll]
|
||||||
"Return every nth member of coll
|
"Return every nth member of coll
|
||||||
raises ValueError for (not (pos? n))"
|
raises ValueError for (not (pos? n))"
|
||||||
(if (pos? n)
|
(if (not (pos? n))
|
||||||
(do
|
(raise (ValueError "n must be positive")))
|
||||||
(setv citer (iter coll) skip (dec n))
|
(setv citer (iter coll) skip (dec n))
|
||||||
(for* [val citer]
|
(for* [val citer]
|
||||||
(yield val)
|
(yield val)
|
||||||
(for* [_ (range skip)]
|
(for* [_ (range skip)]
|
||||||
(next citer))))
|
(next citer))))
|
||||||
(raise (ValueError "n must be positive"))))
|
|
||||||
|
|
||||||
(defn zero? [n]
|
(defn zero? [n]
|
||||||
"Return true if n is 0"
|
"Return true if n is 0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user