filter multimethod
Methods
- filter(e:Eachable1, predicate:Any) Source: stdlib.ngs:302
Filter e using predicate. Parameters
e Eachable1. WARNING: instances of same type as e must have empty constructor and push() method. predicate Decision function to be called with each item as first argument. When predicate(item) returns true, the item will appear in the resulting array. Returns
Of same type as eExample
(1...10).filter(F(num) num % 2 == 0) # Gives [2,4,6,8,10] (1...10).filter(X<5) # Gives [1,2,3,4], predicate called as predicate(item, 5)
- filter(something:Eachable1, field:Str, predicate:Any)deprecated Source: stdlib.ngs:317
DEPRECATED! Do not use! Use something.filter({field: predicate}) instead.
- filter(e:Eachable1)deprecated Source: stdlib.ngs:442
Filter nulls out. DEPRECATED, USE something.without(null) INSTEAD. Returns
Arr (array) of original items without nulls
- filter(hl:HashLike, predicate:Fun) Source: stdlib.ngs:744
Filter hash. Build new HashLike with kev-value pairs selected by predicate. Parameters
predicate Test function to be called with one key and one value at a time. Returns
HashLikeExample
my_hashlike.filter(F(k, v) k == 'a')
- filter(h:Hash, predicate:Any) Source: stdlib.ngs:2419
Filter hash. Build new hash with kev-value pairs selected by predicate. Parameters
h Source hash predicate Test function to be called with one key and one value at a time Example
{'a': 1, 'b': 2}.filter(F(k, v) k == 'a') # {'a': 1}
- filter(fb:FullBox, predicate:Any) Source: stdlib.ngs:2736
Conditionaly convert FullBox to EmptyBox. Parameters
predicate Test function to be called with the value in the FullBox Returns
Box. fb if predicate succeeds, EmptyBox if not.Example
Box(10).filter(X>5) # <FullBox val=10> Box(10).filter(X>20) # <EmptyBox>
- filter(eb:EmptyBox, predicate:Any) Source: stdlib.ngs:2744
Do nothing Returns
ebExample
EmptyBox().filter(X>20) # <EmptyBox>
- filter(s:Success, predicate:Any) Source: stdlib.ngs:2948
Run predicate on wrapped value. Returns
s or FailureExample
Success(10).filter(X>5) # <Success val=10> Success(10).filter(X>15) # <Failure val=<ResultFail ...>>
- filter(f:Failure, predicate:Any) Source: stdlib.ngs:2956
No-op, returns f Returns
fExample
Failure("blah").filter(X>5) # <Failure val=blah>
- filter(rd:ResDef, predicate:Fun) Source: autoload/Res.ngs:93
Create new resource definition by filtering resources of rd. Parameters
rd Original resource definition. Not modified. Returns
ResDefExample
# Get instances with last private IP octet less than 20: AWS::Instance().filter({A.PrivateIpAddress.split(".")[-1].Int()<20})
- filter(i:Iter, predicate:Fun) Source: autoload/Iter.ngs:181
EXPERIMENTAL! Do not use!
- filter(ds:DelimStr, predicate:Any) Source: autoload/DelimStr.ngs:23
Get new DelimStr with some elements filtered out Example
DelimStr("/bin:/usr/bin:/usr/local/bin").filter(/usr/).Str() # "/usr/bin:/usr/local/bin"