Types

Arr

Array - list of items accessed by zero-based index

Parent types

Example

x = ["first", "second", "third", "fourth"]

echo(x)
# Output:
#   ['first','second','third','fourth']

echo(x.len())
# Output:
#   4

echo(x[1])
# Output:
#   second

echo(x[10])
# ... Exception of type IndexNotFound occured ...

Constructors

Arr(h:Hash)
Make Arr from Hash. Each key/value pair becomes two-items array:
Arr(arr:Arr)
Make Arr from Arr. A no-op.
Arr(r:Eachable1)
Convert range to an array
Arr(fb:FullBox)
Convert FullBox to array
Arr(eb:EmptyBox)
Convert EmptyBox to array
Arr(t:TextCollector)

Methods

"$*"(components:Arr)
String expansion handler. Called automatically for every double-quoted string that has $* components.
*(arr:Arr, n:Int)
Repeat all elements in arr n times
*(a:Arr, b:Arr)
Cartesian product
+(a:Arr, b:Arr)
Array concatenation.
+(s:Str, a:Arr)
Prepend each line in a with s
+(a:Arr, s:Str)
Append s to each line in a
-(a:Arr, b:Arr)
Filter out all values in a that are also in b
.(a:Arr, attr:Str)
Return array made of given attribute of each element of given array
==(a:Arr, b:Arr)
Arrays equality test. True if arrays are of the same length and all elements are equal (==)
[](arr:Arr, range:NumRange)
[](arr:Arr, idx:Int)
[](arr:Arr, idx:Int)
Get array element by index from the end
[](arr:Arr, r:NumRange)
Get array elements at specified indexes. Indexes specified by NumRange.
[](arr:Arr, r:PredRange)
Extract array elements between the element that matches r.start and the element that matches r.end . Starting and ending elements are optionally included, depending on r.include_start and r.include_end .
[](arr:Arr, indexes:Arr)
Get array elements at specified indexes.
[]=(arr:Arr, range:NumRange, replacement:Arr)
[]=(arr:Arr, idx:Int, v:Any)
Arr(arr:Arr)
Make Arr from Arr. A no-op.
assert_hash_keys(actual:Any, expected:Arr, title:Any=null)
Box(a:Arr)
Convert array to a Box. Throws InvalidArgument if length of the array is not 0 or 1.
Box(a:Arr, idx:Any)
Convert array value indexed by the given index
c_execve(filename:Str, argv:Arr, envp:Arr)
c_ffi_call(cif:c_ffi_cif, fn:CSym, argv:Arr)
Unfinished feature. Don't use!
c_ffi_prep_cif(rtype:c_ffi_type, atypes:Arr)
Unfinished feature. Don't use!
c_poll(fds_evs:Arr, timeout:Int)
calculate_num_cols_to_show(t:Table, max_colums_widths:Arr, available_cols:Int)
cell_display_width(x:Arr)
Calculate cell display width for an array
cell_display_width(x:Arr)
Calculate cell display width for an empty array
code(a:Arr)
Convert an array to NGS code that would produce the array when executed. Not fully functional yet.
collector(a:Arr, body:Fun)
Defines collector { ... collect(...) ... } behaviour for arrays
copy(arr:Arr)
count(arr:Arr, predicate:Any)
Count number of items that satisfy the predicate. TODO: Make it work on anything with each() method.
count(arr:Arr)
Count all true values.
created(rd:ResDef, resources:Arr, props:Hash)
dflt(arr:Arr, k:Any, v:Any)
Set an attribute on instances if it's not already set
Diff(a:Arr, b:Arr, full:Bool=false)
Compare arrays. Warning: Hash is used so internal Hash keys comparison is used, not ==
Diff(a:Arr, b:Arr, full:Bool=false)
Diff(a:Arr, b:Arr, full:Bool=false)
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_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)
get(arr:Arr, idx:Int, dflt:Any)
group(a:Arr, cb:Fun)
TODO. Group items from a by key returned by cb
Hash(arr:Arr)
Create a Hash from Arr of Arr[2]
Hash(arr:Arr, attr:Str)
TODO. Not sure it's used anywhere. Maybe remove?
Hash(arr:Arr, cb:Fun)
Create a Hash from keys in arr using cb for values calculation
Hash(keys:Arr, values:Arr)
Create a Hash from keys in "keys" and corresponding values in "values"
Hash(arr:Arr, key_attr:Str, val_attr:Str)
Create Hash from Arr of something that has key and value attribute
in(x:Any, arr:Arr)
Checks whether element x is in array arr
index(arr:Arr, predicate:Any)
Find index of first value that satisfies the predicate. TODO: Make it work on anything with each() method.
indexes(arr:Arr, predicate:Any)
Find all indexes of values that satisfy the predicate TODO: Make it work on anything with each() method
init(my:MatchY, matches:Arr)
Successful match constructor
init(rd:SecGroup, anchor:Arr)
init(ds:DelimStr, a:Arr, delim:Str=:)
DelimStr constructor
init(i:ArrIter, arr:Arr)
ArrIter constructor.
init(s:Stats, a:Arr)
Makes Stats, with each element in the array counted as if push()ed
init(t:Table, name:Any, rows_hashes:Arr)
Create named table containing provided rows
init(t:Table, rows_hashes:Arr)
init(dn:DocNode, children:Arr=null)
init(tdn:TextDocNode, text:Arr)
inspect(a:Arr)
Inspect Arr
Iter(arr:Arr)
Calls ArrIter constructor.
join(arr:Arr, s:Str)
join(a:Arr, sep:Arr)
EXPERIMENTAL! Do not use!
join(a:Arr, s:Str)
Join non-strings. Converts a elements to string first, then uses built-in join().
join(threads:Arr)
len(arr:Arr)
limit(a:Arr, l:Int)
Truncate an array if necessary so it would have maximum l elements.
lines(f:File, lines_:Arr)
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_idx_val(arr:Arr, mapper:Fun)
Map an Arr to an Arr (array) of values using mapper mapper is called as mapper(INDEX, ITEM)
max(arr:Arr)
TODO
max(arr:Arr, cb:Fun)
TODO
merge_sorted(a:Arr, b:Arr, lte:Fun)
Merge sorted arrays.
min(arr:Arr)
TODO
min(arr:Arr, cb:Fun)
TODO
nuke_null(a:Arr)
Used for command line arguments such as ['--vpc-id', my_vpc_id()].nuke_null() If my_vpc_id() is null the whole array is not needed
pmap(a:Arr, mapper:Fun)
pop(arr:Arr)
Pop item from an array. Removes last item in array and returns it. Throws EmptyArrayFail.
push(arr:Arr, v:Any)
Append item to an array.
push(t:Table, row_arr:Arr)
rand(a:Arr)
Pick one random element from array
reverse(arr:Arr)
Make new array which is a reversed given array
shift(arr:Arr)
shift(arr:Arr, dflt:Any)
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
split(a:Arr, delim:Any)
TODO. Is it used even?
stdlib_aws_straighten_tags(a:Arr)
Convert "Tags" array in each element of AWS resources (typically returned by AWS CLI) into Hash. Makes "Tags" much more usable.
Str(a:Arr)
Convert Arr to string
subset(smaller:Arr, larger:Arr)
Type(t:Str, doc:Any, parents:Arr)
Type constructor
uniq(arr:Arr)
Return unique values. Warning: uses Hash so comparison is not using == but a built-in hash keys comparison.
unshift(arr:Arr, elt:Any)
Prepend one element to the given array
without(arr:Arr, without_elt:Any)
Filter out all occurrences of specific value
~(argv:Arr, c:Closure)
Tries to match command line arguments with closure parameters.