JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

all

core-api


    function
    boot.janet on line 2533, column 1

    (all pred x & xs)

    Apply `pred` to values of `x`. Return true if all results are 
    truthy; if any result is falsey, stop applying `pred` and return 
    the result.

    Also functions variadically, i.e. takes additional arguments, with 
    suitable changes to the arity of `pred`. `pred` is called with both 
    values from `x` and additional arguments, and only as many times as 
    the length of the shortest of `x` and each element of `xs`. If `x` 
    or any element of `xs` is empty, returns true.

    `x` and elements of `xs` can be values of type bytes, indexed, 
    dictionary, fiber, or abstract with suitable `get` and `next` 
    methods.


See also:any?some2 examplesSign in to add an example
Loading...
# janet 1.10.1

(all pos? [1 2 3])     # => true
(all pos? [1 2 3 -4])  # => false
(all pos? [1 2 3 0])   # => false

(all (partial string/has-prefix? "a") ["aa" "ab"])       # => true
(all (partial string/has-prefix? "a") ["aa" "ab" "bb"])  # => false

(all truthy? [1 2])              # => true
(all truthy? [1 2 3])            # => true
(all truthy? [1 2 nil 3])        # => false
(all truthy? [1 false 2 nil 3])  # => false

(all (fn [x] x) [1 2])              # => 2
(all (fn [x] x) [1 2 3])            # => 3
(all (fn [x] x) [1 2 nil 3])        # => nil
(all (fn [x] x) [1 false 2 nil 3])  # => false
cellularmitosisPlayground
janet:2:> (all true? [true true false])
false
janet:3:> (all even? [2 4 6 7])
false
janet:5:> (all even? [2 4 6])
true
swlkrPlayground