count multimethod

Methods

count(e:Eachable1, pattern:Any=method) Source: stdlib.ngs:2703
Count number of items that match the pattern.

Parameters

eItems to look at
patternTest function or anything else acceptable by (=~), defaults to Bool.constructors

Returns

Int

Example

[1,2,3,11,12].count(X>10)  # 2
count(e:Eachable2, predicate:Fun) Source: stdlib.ngs:3456
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: predicate(k, v)

Returns

Int

Example

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