JanetDocsPlaygroundI'm feeling luckyGitHub sign in

take-while



    function
    boot.janet on line 1131, column 1

    (take-while pred ind)

    Given a predicate, take only elements from a fiber, indexed, or 
    bytes type that satisfy the predicate, and abort on first failure. 
    Returns a new array, tuple, or string, respectively.


2 examplesSign in to add an example
Loading...
(take-while number? 
            (fiber/new
              |(each x [1 2 3 :hi]
                 (yield x))))
# => @[1 2 3]
sogaiuPlayground
(take-while number? @[1 2 3 "4" 5 6 7 8 9 "10" 11 "12"]) # => (1 2 3)
jgartePlayground