map multimethod

Methods

map(e:Eachable, mapper:Fun) Source: stdlib.ngs:279
Map e to an Arr (array) of values using mapper.

Parameters

eObject of any type that has each(e, callback) implemented

Returns

Arr

Example

[1,2,3].map(X*4)  # [4,8,12]
map(arr:Arr, n:Int, mapper:Fun) Source: stdlib.ngs:1828
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

arrItems to iterate in chunks of n
nNumber of items in chunk
mapperFunction to be called with values from arr

Returns

Arr

Example

[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:2486
Map a Hash

Parameters

hHash with source keys and values
mapperFunction to be called with keys and values from h

Returns

Arr

Example

{'a': 1, 'b': 2}.map(F(k, v) "${k}-$v")  # ['a-1', 'b-2']
map(fb:FullBox, mapper:Fun) Source: stdlib.ngs:2852
Map FullBox value

Parameters

mappermapper to be called with the FullBox value

Returns

FullBox with value returned by mapper

Example

Box(10).map(X*2)  # <FullBox val=20>
map(eb:EmptyBox, mapper:Fun) Source: stdlib.ngs:2857
Do nothing

Returns

eb

Example

EmptyBox().map(X*2)  # <EmptyBox>
map(s:Success, fun:Fun) Source: stdlib.ngs:3070
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:3083
No-op, returns f

Returns

f
map(i:Iter, mapper:Fun) Source: autoload/Iter.ngs:122
EXPERIMENTAL! Do not use!