count multimethod

Methods

count(e:Eachable1, predicate:Any) Source: stdlib.ngs:1863
Count number of items that satisfy the predicate.

Parameters

eItems to look at
predicateTest function

Returns

Int

Example

[1,2,3,11,12].count(X>10)  # 2
count(e:Arr) Source: stdlib.ngs:1877
Count all true values.

Parameters

eItems to look at

Returns

Int

Example

[0,1,2,null,false].count()  # 2 (Only 1 and 2 count as true values)
count(e:Eachable2, predicate:Any) Source: stdlib.ngs:2603
Count number of key-value pairs in Hash that satisfy the predicate.

Parameters

eSomething to check, typically a Hash
predicateTest function to be called with one key and one value at a time

Returns

Int

Example

{'a': 1, 'b': 2, 'c': 11}.count(F(k, v) v>10)  # 1