JanetDocsPlaygroundI'm feeling luckyGitHub sign in

find



    function
    boot.janet on line 1054, column 1

    (find pred ind &opt dflt)

    Find the first value in an indexed collection that satisfies a 
    predicate. Returns `dflt` if not found.


See also:find-index2 examplesSign in to add an example
Loading...
(find |(= 2 $) {:a 1 :b 2 :c 3})
# => 2

(get @"Hello" 1)
# => 101

(find |(= 101 $)  @"Hello")
# => 101

(find |(> $ 3)  {:a 1 :b 2 :c 3})
# => nil
leobmPlayground
(def h ["a" "b" :c]) # => ("a" "b" :c)

(find (fn [a] (= "a" a)) h) # => "a"
faywongPlayground