1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-25 22:53:16 +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) ret)
(defn all (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] [pred xs]
(var ret true) (var ret true)
(loop [x :in xs :while ret] (set ret (pred x))) (loop [x :in xs :while ret] (set ret (pred x)))
ret) ret)
(defn some (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] [pred xs]
(var ret nil) (var ret nil)
(loop [x :in xs :while (not ret)] (if-let [y (pred x)] (set ret y))) (loop [x :in xs :while (not ret)] (if-let [y (pred x)] (set ret y)))