map multimethod
Methods
- map(e:Eachable, mapper:Fun) Source: stdlib.ngs:257
Map e to an Arr (array) of values using mapper. Parameters
e Object of any type that has each(e, callback) implemented Returns
ArrExample
[1,2,3].map(X*4) # [4,8,12]
- map(arr:Arr, n:Int, mapper:Fun) Source: stdlib.ngs:1690
Map each N elements of an Array at a time. mapper is called as cb(eltI, ..., eltJ) where I is multiple of n and J is I+n-1 Throws InvalidArgument if number of items in arr is not divisible by n. mapper is called as mapper(eltI, ..., eltJ) where I is multiple of n and J is I+n-1 Parameters
arr Items to iterate in chunks of n n Number of items in chunk mapper Function to be called with values from arr Returns
ArrExample
[1,2,3,4].map(2, F(a,b) "$a=$b").join("&") # Outputs: 1=2&3=4
- map(h:Hash, mapper:Fun) Source: stdlib.ngs:2347
Map a Hash Parameters
h Hash with source keys and values mapper Function to be called with keys and values from h Returns
ArrExample
{'a': 1, 'b': 2}.map(F(k, v) "${k}-$v") # ['a-1', 'b-2']
- map(fb:FullBox, mapper:Fun) Source: stdlib.ngs:2713
Map FullBox value Parameters
mapper mapper to be called with the FullBox value Returns
FullBox with value returned by mapperExample
Box(10).map(X*2) # <FullBox val=20>
- map(eb:EmptyBox, mapper:Fun) Source: stdlib.ngs:2718
Do nothing Returns
ebExample
EmptyBox().map(X*2) # <EmptyBox>
- map(s:Success, fun:Fun) Source: stdlib.ngs:2928
Run fun with wrapped value. If exception is thrown, Failure is returned; otherwise Success with new vaule is returned. Returns
Result
- map(f:Failure, fun:Fun) Source: stdlib.ngs:2941
No-op, returns f Returns
f
- map(i:Iter, mapper:Fun) Source: autoload/Iter.ngs:122
EXPERIMENTAL! Do not use!