1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-07 11:03:04 +00:00

Add any? predicate to core.

This is the contrapositive to `every?`, and is analagous to `or` as
`every?` is to `and`.
This commit is contained in:
Calvin Rose
2020-07-06 09:19:10 -05:00
parent 9d8e338a11
commit 7478ad115f
2 changed files with 20 additions and 9 deletions

View File

@@ -1202,6 +1202,15 @@
(if x nil (set res x)))
res)
(defn any?
"Returns the first truthy valye in ind, otherwise nil.
falsey value."
[ind]
(var res nil)
(loop [x :in ind :until res]
(if x (set res x)))
res)
(defn reverse!
"Reverses the order of the elements in a given array or buffer and returns it
mutated."