You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pixie/stdlib.pxi
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1746,6 +1746,19 @@ The new value is thus `(apply f current-value-of-atom args)`."
1746
1746
s)))]
1747
1747
(lazy-seq (step pred coll)))))
1748
1748
1749
+
(defn cycle
1750
+
[coll]
1751
+
(if (empty? coll)
1752
+
()
1753
+
(let [cycle'
1754
+
(fn cycle' [current]
1755
+
(lazy-seq
1756
+
(cons
1757
+
(first current)
1758
+
(let [rst (rest current)]
1759
+
(cycle' (if (empty? rst) coll rst))))))]
1760
+
(cycle' coll))))
1761
+
1749
1762
;; TODO: use a transient map in the future
1750
1763
(defn group-by
1751
1764
{:doc "Groups the collection into a map keyed by the result of applying f on each element. The value at each key is a vector of elements in order of appearance."
0 commit comments