JanetDocsPlaygroundI'm feeling luckyGitHub sign in

keep



    function
    boot.janet on line 956, column 1

    (keep pred ind)

    Given a predicate `pred`, return a new array containing the truthy
    results of applying `pred` to each element in the indexed collection
    `ind`. This is different from `filter` which returns an array of the
    original elements where the predicate is truthy.


See also:filter1 exampleSign in to add an example
Loading...
(def person-ids {"Alice" 42 "Bob" 23})

(keep person-ids ["Carl" "Bob" "Alice"])   # -> @[23 42]

(filter person-ids ["Carl" "Bob" "Alice"]) # -> @["Bob" "Alice"]
(map person-ids ["Carl" "Bob" "Alice"])    # -> @[nil 23 42]
felixrPlayground