1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-08 11:33:02 +00:00

Merge branch 'master' into ev

This commit is contained in:
Calvin Rose
2020-08-03 07:54:53 -05:00
6 changed files with 33 additions and 3 deletions

View File

@@ -957,6 +957,18 @@
(def i (find-index pred ind))
(if (= i nil) nil (in ind i)))
(defn index-of
"Find the first key associated with a value x in a data structure, acting like a reverse lookup.
Will not look at table prototypes.
Returns dflt if not found."
[x ind &opt dflt]
(var k (next ind nil))
(var ret dflt)
(while (not= nil k)
(when (= (in ind k) x) (set ret k) (break))
(set k (next ind k)))
ret)
(defn take
"Take first n elements in an indexed type. Returns new indexed instance."
[n ind]
@@ -1212,7 +1224,7 @@
res)
(defn any?
"Returns the first truthy valye in ind, otherwise nil.
"Returns the first truthy value in ind, otherwise nil.
falsey value."
[ind]
(var res nil)