1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-16 10:19:55 +00:00

Clarify docs for some and all.

This commit is contained in:
Calvin Rose 2020-02-05 21:06:39 -06:00
parent d8d482e433
commit fcc09d7ea9

View File

@ -1583,14 +1583,16 @@
ret)
(defn all
"Returns true if all xs are truthy, otherwise the first false or nil value."
"Returns true if all xs are truthy, otherwise the resulty of first
falsey predicate value, (pred x)."
[pred xs]
(var ret true)
(loop [x :in xs :while ret] (set ret (pred x)))
ret)
(defn some
"Returns nil if all xs are false or nil, otherwise returns the first true value."
"Returns nil if all xs are false or nil, otherwise returns the result of the
first truthy predicate, (pred x)."
[pred xs]
(var ret nil)
(loop [x :in xs :while (not ret)] (if-let [y (pred x)] (set ret y)))