Types

Fun

Function type: an Array of Closures, a Closure, or a native method

Methods

%(x:Any, cb:Fun)
Each operator. Same as calling x.each(cb)
*(cb:Fun, n:Int)
Call cb n times without any parameters and accumulate the results.
+(f:Fun, g:Fun)
Compose functions
/(x:Any, mapper:Fun)
Map operator. Same as calling x.map(mapper)
?(x:Any, predicate:Fun)
Filter operator. Same as calling x.filter(predicate)
\(x:Any, f:Fun)
Call operator. Same as calling f(x)
acquire(l:Lock, cb:Fun)
aws_regions(cb:Fun)
cached(cb:Fun)
collector(a:Arr, body:Fun)
Defines collector { ... collect(...) ... } behaviour for arrays
collector(h:Hash, body:Fun)
Defines collector { ... collect(...) ... } behaviour for hashes
collector(n:Int, body:Fun)
Defines collector { ... collect(...) ... } behaviour for integers (summarizes collected items).
dir(dirname:Str, cb:Fun, subtype:Any=false)
List directory contents and call cb with Path() of each found item. Warning: "." and ".." are included.
each(al:ArrLike, cb:Fun)
Call cb for each element in the underlying array.
each(hl:HashLike, cb:Fun)
each(r:NumRange, cb:Fun)
Iterates over the elements of r, passing each in turn to cb.
each(arr:Arr, cb:Fun)
Iterates over the elements of arr, passing each in turn to cb along with args: cb(ITEM)
each(arr:Arr, n:Int, cb:Fun)
Process each N elements of an Array at a time. Throws InvalidArgument if number of items in arr is not divisible by n. cb is called as cb(eltI, ..., eltJ) where I is multiple of n and J is I+n-1
each(h:Hash, cb:Fun)
Iterate a Hash.
each(fb:FullBox, cb:Fun)
Call cb with the value of the FullBox
each(eb:EmptyBox, cb:Fun)
Do nothing
each(n:Int, cb:Fun)
Iterate from zero up to but not including n
each(s:Str, cb:Fun)
Iterates over all string characters (currently bytes). TODO: example.
each(rd:ResDef, cb:Fun)
each(i:Iter, cb:Fun)
Calls cb with each element from i
each(t:Table, cb:Fun)
each_idx_key_val(h:Hash, cb:Fun)
Iterate a Hash.
each_idx_val(arr:Arr, cb:Fun)
Iterates over the elements of arr, passing each in turn to cb along with index and args: cb(INDEX, ITEM)
filter(hl:HashLike, cb:Fun)
finally(body:Fun, cleanup:Fun)
TODO: make sure cleanup() is not run twice in case of exception in cleanup() itself
group(a:Arr, cb:Fun)
TODO. Group items from a by key returned by cb
Hash(arr:Arr, cb:Fun)
Create a Hash from keys in arr using cb for values calculation
init(t:Thread, f:Fun, arg:Any)
init(t:Thread, f:Fun)
lines(s:Str, cb:Fun)
Split s to strings using end-of-line separators and call cb for each one of the lines. TODO: More efficient implementation, which would not have temporary array of all lines.
lines(f:File, cb:Fun)
Iterate over lines of the file
lines(p:Process, cb:Fun)
Iterate lines of Process' stdout, calling cb with successive lines. Warning: current implementation waits for the process to finish and accumulates all its stdout.
map(something:Eachable, mapper:Fun)
Map something to an Arr (array) of values using mapper.
map(arr:Arr, n:Int, mapper:Fun)
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
map(h:Hash, mapper:Fun)
Map a Hash
map(fb:FullBox, mapper:Fun)
Map FullBox value
map(eb:EmptyBox, mapper:Fun)
Do nothing
map_base_idx(base:Any, n:Int, mapper:Fun)
EXPERIMENTAL! Map when there is more than one element. If there is exactly one element, it's left as is
map_idx_val(arr:Arr, mapper:Fun)
Map an Arr to an Arr (array) of values using mapper mapper is called as mapper(INDEX, ITEM)
mapk(h:Hash, mapper:Fun)
Map Hash keys. Build new Hash with same values as in h but keys mapped by mapper.
mapkv(h:Hash, mapper:Fun)
Map Hash keys and values. Build new Hash with keys and values mapped by mapper.
mapv(h:Hash, mapper:Fun)
Map Hash values. Build new Hash with same keys as in h but values mapped by mapper.
max(arr:Arr, cb:Fun)
TODO
merge_sorted(a:Arr, b:Arr, lte:Fun)
Merge sorted arrays.
min(arr:Arr, cb:Fun)
TODO
none(e:Eachable1, predicate:Fun)
Check that there is no element in e that satisfies the given predicate. Exactly same as not(any(e, predicate)) .
only(predicate:Any, mapper:Fun)
Transform mapper to handle only items matching predicate. Non-matching items will be returned as is.
opt_prop(rd:ResDef, name:Str, props:Hash, cb:Fun)
Run cb with optional resource property if it exists, uses opt_prop(ResDef, Str, Hash)
partial(f:Fun, *bind_args:Arr)
Returns partially-applied function
partial_tail(f:Fun, *bind_args:Arr)
Same as partial() but the bound arguments are last ones
pmap(a:Arr, mapper:Fun)
pmap(n:Int, mapper:Fun)
Pred(f:Fun)
Convert a function to predicate.
ptimes(n:Int, cb:Fun)
reduce(something:Eachable1, start:Any, f:Fun)
Combine items to a single value using the supplied binary function First f is applied to start and the first element of something then on each step f is applied to previous result and next element of something.
replace(s:Str, r:RegExp, mapper:Fun)
Replace all occurrences of r
retry(times:Int=60, sleep:Any=1, logger:Fun=(a function), success_predicate:Any=(a function), catch_exceptions:Bool=true, title:Any=<retry>, progress_cb:Fun=(a function), success_cb:Fun=(a function), fail_cb:Any=null, body:Fun=(a function))
Retry. Executes given "body" "times" times. Throws RetryFail if all calls fail and fail_cb is not provided.
sort(a:Arr, lte:Fun=(a function))
Sort an array.
sort(a:Arr, attr:Str, lte:Fun=(a function))
Sort an array based on attribute value
sort(h:Hash, lte:Fun=(a function))
Sort a Hash.
sortk(h:Hash, lte:Fun=(a function))
Sort Hash by keys
StrParams(f:Fun)
TODO: Defaut values
tap(val:Any, cb:Fun)
Call cb with val
test(name:Str, f:Fun)
the_one(something:Eachable1, predicate:Any, body:Fun, found_more:Fun=(a function), found_none:Fun=(a function))
Find the only element that satisfies the predicate and execute given code with the value
times(n:Int, cb:Fun)
Call cb n times without arguments.