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