function
boot.janet on line 1126, column 1
(count pred ind & inds)
Count the number of values in a data structure `ind` for which
applying `pred` yields a truthy value, but only if no `inds` are
provided. Multiple data structures can be handled if each `inds` is
a data structure and `pred` is a function of arity one more than
the number of `inds`. Note that `pred` is only applied to values at
indeces up to the largest index of the shortest of `ind` and each
of `inds`.
(count even? [1 2 3 4 5]) # => 2
(count (fn [x] (> x 3)) [1 2 3 4 5]) # => 2
(count |(> $ 3) [1 2 3 4 5]) # => 2
(count (fn [x] (truthy? x)) [nil false true 42 :a "foo"]) # => 4
(count |(truthy? $) [nil false true 42 :a "foo"]) # => 4
(var f even?)
(count f [1 2 3 4 5]) # => 2
(set f odd?)
(count f [1 2 3 4 5]) # => 3
(map (fn [f] (count f [1 2 3 4 5])) [even? odd?]) # => @[2 3]
(map |(count $ [1 2 3 4 5]) [even? odd?]) # => @[2 3]