Arr type
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 occurred ...
Direct parent types
- Eachable1
Eachable which each() calls the callback with one argument Direct subtypes: 18
Constructors
- Arr(mm:MultiMethod)
Get methods of a MultiMethod Returns
Arr
- Arr() Source: stdlib.ngs:574
Make empty array Returns
[]
- Arr(al:ArrLike) Source: stdlib.ngs:2077
Get the underlying array of ArrLike. Not a copy. Returns
Arr
- Arr(h:Hash) Source: stdlib.ngs:3549
Make Arr from Hash. Each key/value pair becomes two-items array. Returns
Arr of form [[k1, v1], [k2, v2], ...]Example
Arr({'x': 7, 'y': 8}) # [['x', 7], ['y', 8]]
- Arr(something:Eachable1) Source: stdlib.ngs:3571
Convert Eachable1 (anything with "each" method that takes callback of one parameter) to an array Example
Arr(1..3) # [1,2] Arr(1...3) # [1,2,3]
- Arr(arr:Arr) Source: stdlib.ngs:3581
Make Arr from Arr. A no-op. Returns
arr
- Arr(g:Doc::Group) Source: autoload/globals/Doc.ngs:74
Get all items (children) of document elements group Returns
Arr
Methods
- "$*"(components:Arr) Source: stdlib.ngs:5515
String expansion handler. Called automatically for every double-quoted string that has $* components. Automatically called by NGS for syntax
"abc$*{something}def"Example
"$*{ENV.PATH.split(":")}/od".filter(File(X)) # Find out where in PATH is the "od" binary
- *(arr:Arr, n:Int) Source: stdlib.ngs:3778
Repeat all elements in arr n times Parameters
arr Elements to repeat n Number of times to repeat the elements Returns
ArrExample
[10,20] * 2 # [10,20,10,20]
- *(a:Arr, b:Arr) Source: stdlib.ngs:3788
Cartesian product Returns
Arr of Arr[2]Example
[10,20] * [30,40] # [[10, 30], [10, 40], [20, 30], [20, 40]]
- +(a:Arr, b:Arr)
Array concatenation. Returns
ArrExample
[1,2]+[3,4] # [1,2,3,4]
- -(a:Arr, b:Arr) Source: stdlib.ngs:3385
Filter out all values in a that are also in b Returns
ArrExample
[1,2,3] - [5,6,1] # [2,3]
- .(a:Arr, field:Str) Source: stdlib.ngs:3105
Return array made of given field of each element of given array. Will throw KeyNotFound if any of the elements does not have the desired field. Use get() to handle missing field differently. Returns
ArrExample
[{"x": 1}, {"x": 2}].x # [1, 2] [{"x": 1}, {"y": 2}].x # KeyNotFound exception [{"x": 1}, {"y": 2}].get("x") # [1] - skip [{"x": 1}, {"y": 2}].get("x", null) # [1, null] - use default value
- .=(t:Type, field:Str, a:Arr) Source: stdlib.ngs:2537
Undocumented Automatically called by NGS for syntax
SUBTYPE_OF_NAMEDINSTANCES.NamedInstances = ['SOME', 'NAMES', ...]
- .=(a:Arr, field:Str, e:Eachable1) Source: stdlib.ngs:3115
Set field of every element in array to corresponding item in e. Uses Iter(e) internally. Returns
aExample
a=[{"x": 1}, {"x": 2}] a.y = [10, 20] # a == [{"x": 1, "y": 10}, {"x": 2, "y": 20}]
- <=(a:Arr, b:Arr) Source: stdlib.ngs:3205
Compare arrays, element-wise. If all elements are equal, the longest array considered to be the "big" one. Returns
BoolExample
[1, 2] <= [1, 3] # true [1] <= [1, 2] # true
- ==(a:Arr, b:Arr) Source: stdlib.ngs:3190
Arrays equality test. True if arrays are of the same length and all elements are equal (==) Returns
Bool
- =~(x:Any, a:Arr, mc:MatchContext) Source: stdlib.ngs:1416
Checks that 1. The x is Eachable1 but not Str or Int 2. Each element of x matches (=~) corresponding element in a (If number of elements does not match - there is no match)
- >=(a:Arr, b:Arr) Source: stdlib.ngs:3222
Compare arrays, element-wise. If all elements are equal, the longest array considered to be the "big" one. Exactly the same as b <= a. Returns
Bool
- [](arr:Arr, range:NumRange)
Get array elements at specified indexes. Parameters
range NumRange, exclusive end. Non-negative Int .start. Non-negative Int .end, or null .end for the end of the array Returns
ArrExample
[10,20,30,40][1..3] # [20,30] [10,20,30,40][1..null] # [20,30,40]
- [](arr:Arr, idx:Int)
Get element at the given index or throw IndexNotFound if the index is out of range (element at the given index does not exist). Returns
Any
- [](arr:Arr, idx:Int) Source: stdlib.ngs:3592
Get array element by index from the end (negative indexes handler). Throws IndexNotFound if abs(idx) > len(arr). Parameters
idx Negative index Example
[10,20,30][-1] # 30
- [](arr:Arr, r:NumRange) Source: stdlib.ngs:3616
Get array elements at specified indexes. Indexes specified by NumRange. Parameters
r NumRange with negative .end Returns
ArrExample
[10,20,30,40][1..-1] # [20,30]
- [](arr:Arr, r:NumRange) Source: stdlib.ngs:3629
Get array elements at specified indexes. Indexes specified by NumRange. Parameters
r NumRange with negative .start Returns
ArrExample
[10,20,30,40][-2..null] # [30,40]
- [](arr:Arr, r:PredRange) Source: stdlib.ngs:3683
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 . null r.start means from the first element, null r.end means to the last element, both inclusive regardless of .. or ... . Example
%[a1 a2 b1 b2][/^a/../^b/] # ['a2'] %[a1 a2 b1 b2][null../^b/] # ['a1', 'a2'] %[a1 a2 b1 b2][/^b/..null] # ['b2'] %[a1 a2 b1 b2][/^a/.../^b/] # ['a1', 'a2', 'b1'] %[a1 a2 b1 b2][/^a/.../^x/] # IndexNotFound exception
- [](arr:Arr, indexes:Arr) Source: stdlib.ngs:3730
Get array elements at specified indexes. Parameters
arr Array to pick items from indexes Indexes of items to pick Returns
ArrExample
[10,20,30,40][[0,3]] # [10, 40]
- []=(arr:Arr, range:NumRange, replacement:Arr)
Set array elements at specified indexes. Parameters
range NumRange, exclusive end. Non-negative Int .start. Non-negative Int .end, or null .end for the end of the array Returns
replacementExample
a=[1,2,3,4]; a[1..3]=[9]; a # [1,9,4] a=[1,2,3,4]; a[1..null]=[9]; a # [1,9]
- []=(arr:Arr, idx:Int, v:Any)
Set element at the given index or throw IndexNotFound if the index is out of range. Returns
v
- []=(arr:Arr, idx:Int, val:Any) Source: stdlib.ngs:3602
Set array element by index from the end (negative indexes handler). Throws IndexNotFound if abs(idx) > len(arr). Parameters
idx Negative index Example
a = [1, 2, 3]; a[-1] = 99 # [1, 2, 99]
- []=(arr:Arr, r:PredRange, replacement:Arr) Source: stdlib.ngs:3700
Replace array elements. Parameters
arr Array to operate on. r Range of elements to replace. null r.start means from the first element, null r.end means to the last element, both inclusive regardless of .. or ... . replacement New elements. Example
a = %[a1 a2 b1 b2] a[/^a/.../^b/] = [7] # a == [7, 'b2'] MARKERS = '# generated - start'..'# generated - end' text[MARKERS] = newly_generated_content_lines
- \(name:Str, attributes:Hash, children:Arr)experimental Source: stdlib.ngs:9456
Undocumented Automatically called by NGS for syntax
\name attr1=val1 attr2=val2 ... [ ... ]
- Argv(a:Arr)deprecated Source: stdlib.ngs:7275
Deprecated. Do not use!
- assert_hash_keys(actual:Any, expected:Arr, title:Str='Must be a hash with keys') Source: autoload/globals/test.ngs:127
Assert actual is a Hash and it has the expected keys. Throws TestFail. Returns
actualExample
assert_hash_keys({}, ['kk']) # Throws TestFail. assert_hash_keys({'kk': 7}, ['kk']) # OK
- Box(a:Arr, idx:Int) Source: stdlib.ngs:4637
Convert array value indexed by the given index Parameters
idx key to look in hash Returns
Box. FullBox if the array has the element indexed by idx, EmptyBox otherwise.Example
my_array = [10, 20] my_array.Box(1).map(X*2).each(echo) # output: 40 my_array.Box(5).map(X*2).each(echo) # no output
- c_execve(filename:Str, argv:Arr, envp:Arr)
Call EXECVE(2)
- 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)
Undocumented
- calculate_num_cols_to_show(t:Table, max_columns_widths:Arr, available_cols:Int) Source: autoload/globals/Table.ngs:108
Internal method. Please do not use.
- cell_display_width(x:Arr) Source: autoload/globals/Table.ngs:24
Calculate cell display width for an array
- cell_display_width(x:Arr) Source: autoload/globals/Table.ngs:27
Calculate cell display width for an empty array
- code(a:Arr) Source: stdlib.ngs:3937
Convert an array to NGS code that would produce the array when executed. Not fully functional yet. Returns
Str
- collector(a:Arr, body:Fun) Source: stdlib.ngs:3013
Defines collector { ... collect(...) ... } behaviour for arrays Parameters
a Initial array body The body after collector keyword and possible initial value, wrapped in a function "collector THIS_CODE" or "collector/my_init THIS_CODE" Returns
Constructed arrayExample
items = collector { collect(10) for(i;2) collect(i) collect(20) } echo(items) # Outputs: [10,0,1,20] # Or start with few items: items = collector/[100,200] { collect(10) for(i;2) collect(i) collect(20) } echo(items) # Outputs: [100,200,10,0,1,20]
- copy(arr:Arr)
Shallow copy of arr Returns
Arr
- created(rd:ResDef, resources:Arr, props:Hash) Source: autoload/globals/Res.ngs:200
Called by create() on new resources. Appends the new resources to the list and runs update(). Don't call directly. Parameters
resources Arr of Res
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4833
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not == Parameters
full Do not use Hash, work slower but use == comparison. Example
Diff([1,2], [2,3]) # .add = [3] .remove = [1]
- Diff(a:Arr, b:Arr, eq:Fun)experimental Source: stdlib.ngs:4857
EXPERIMENTAL! Do not use! Compare arrays using eq as equality test. 2*n*m comparisons Returns
ArrDiff
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4863
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not == Parameters
b Arr[PartialPresence] full Do not use Hash, work slower but use == comparison. Returns
ArrDiffExample
Diff([1,2,3], [Present(1)]) # <ArrDiff add=[] remove=[]> Diff([1,2,3], [Present(5)]) # <ArrDiff add=[5] remove=[]> Diff([1,2,3], [Absent(1)]) # <ArrDiff add=[] remove=[1]> Diff([1,2,3], [Absent(5)]) # <ArrDiff add=[] remove=[]> Diff(["a", "b"], [Present("a"), Present("c"), Absent("b"), Absent("d")]) # <ArrDiff add=[c] remove=[b]>
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4890
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not ==. Calls Diff(a, b.map(get), full) Parameters
b Arr[ExactPresence] full Do not use Hash, work slower but use == comparison. Returns
Diff
- digest(a:Arr, chunk_size:Int, marker:Str='(...)') Source: stdlib.ngs:8607
Convert an array to a possibly shorter version, for displaying to human. Parameters
chunk_size number of elements to retain at the beginning and at the end. marker how to mark the cut elements in the middle. Returns
ArrExample
my_array = Arr(1...100) digest(my_array, 2).each(echo) # 1 # 2 # (...) # 99 # 100
- each(arr:Arr, cb:Fun) Source: stdlib.ngs:3296
Iterates over the elements of arr, passing each in turn to cb along with args: cb(ITEM) Parameters
cb Function to be called with values from arr Returns
arrExample
s=0 [1,2,3].each(F(i) { global s; s+=i }) echo(s) # Outputs: 6
- each(arr:Arr, n:Int, cb:Fun) Source: stdlib.ngs:3345
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 Parameters
arr Items to iterate in chunks of n n Number of items in chunk cb Function to be called with values from arr Returns
arrExample
[1,2,3,4].each(2, F(a, b) echo("$a - $b")) # Outputs: "1 - 2" and on the next line "3 - 4"
- each_idx_val(arr:Arr, cb:Fun) Source: stdlib.ngs:3318
Iterates over the elements of arr, passing each in turn to cb along with index and args: cb(INDEX, ITEM) Returns
arrExample
[10,20,30].each_idx_val(F(idx, val) echo("Element #$idx equals to $val"))
- echo_cli(a:Arr)experimental Source: stdlib.ngs:9753
Echo the value as a table before exiting the program, when the value is a result of evaluating the whole program. Only works with TTY and when each element of the array is a Hash and all elements have the same keys.
- ensure(x:Arr, t:Type) Source: stdlib.ngs:2104
Ensures x is of type t. Note that non-Arr x are handled in another implementation, ensure(x, t:Type), where t is Eachable1 or a subtype of Eachable1. Parameters
t ArrLike or a subtype of ArrLike Returns
An instance of type t, with elements from x.
- exec(argv:Arr, env:Hash=ENV) Source: stdlib.ngs:7281
Call EXECVE(2)
- exec(prog:Str, argv:Arr=[], env:Hash=ENV) Source: stdlib.ngs:7288
Call EXECVE(2) Parameters
argv argv, without the program
- fields(e:Eachable2, patterns:Arr) Source: stdlib.ngs:4230
Same as e.fields(AnyOf(patterns)) In some other languages, similar functionality is called "project". Example
{"a": 1, "b": 2}.fields(["a", "a2"]) # {"a": 1}
- finished_ok(p:Process, field_name:Str, ok:Arr)internal Source: stdlib.ngs:6892
Decide whether a process finished normally. Example
$(ok:[0,1,2] ls no-such-file)
- get(a:Arr, idx:Int, dflt:Any=null) Source: stdlib.ngs:3152
Get element at the given index or return dflt if the index is out of range (element at the given index does not exist) Parameters
dflt Default value, defaults to null. If dflt is a Fun, the result of dflt(idx) is used instead. Returns
a[idx] or Value(dflt, idx)Example
[1,2,3].get(0, 10) # 1 [1,2,3].get(5, 10) # 10 [11].get(-1) # 11 [10,20].get(-5, "X") # "X"
- Hash(arr:Arr) Source: stdlib.ngs:4256
Create a Hash from Arr of Arr[2] Parameters
arr Array of Arrays. Each one of the sub-arrays must have exactly two elements. Returns
HashExample
Hash([['a', 1], ['c', 3]]) # {'a': 1, 'c': 3}
- Hash(keys:Arr, values:Arr) Source: stdlib.ngs:4293
Create a Hash from keys in "keys" and corresponding values in "values" Parameters
keys Keys for the new Hash values Values for the new Hash Returns
HashExample
Hash(["a", "b", "c"], [1,2,3]) # {"a": 1, "b": 2, "c": 3}
- in(x:Any, arr:Arr) Source: stdlib.ngs:3178
Checks whether element x is in array arr Parameters
x Needle arr Haystack Returns
BoolExample
1 in [1,2,3] # true 10 in [1,2,3] # false
- index(arr:Arr, pattern:Any=method, start:Int=0, dflt:Any=block) Source: stdlib.ngs:3455
Find index of the first value that matches the pattern. TODO: Make it work on anything with each() method. In future, will throw exception if element is not found and default is not provided. Now returns null for backwards compatibility in this case. Parameters
arr Items to look at pattern Test function or anything else acceptable by (=~), defaults to Bool.constructors start Index to start search at dflt Default value. If dflt is a Fun, the result of dflt() is used instead. Returns
Int or Value(dflt). Temporary also null, for backwards compatibility.Example
[1,2,11,3,4].index(X>10) # 2
- indexes(arr:Arr, r:PredRange, dflt:Any=block) Source: stdlib.ngs:3641
Find the indexes of elements of the given PredRange. Throws IndexNotFound if there is no match between the elements of arr and r and dflt is not given. Parameters
dflt Default value. If dflt is a Fun, the result of dflt() is used instead. Returns
NumRange with .include_start=true and .include_end=false, or Value(dflt)Example
%[a1 a2 b1 b2 c1].indexes(/^a/../^b/) # <NumRange 1..2 include_start=true include_end=false step=1> %[a1 a2 b1 b2 c1].indexes(/^a/.../^b/) # <NumRange 0..3 include_start=true include_end=false step=1>
- init(ms:MatchSuccess, matches:Arr, pattern:Any) Source: stdlib.ngs:1143
Successful match constructor
- init(al:ArrLike, arr:Arr) Source: stdlib.ngs:2052
Undocumented
- init(i:ArrIter, arr:Arr) Source: autoload/globals/Iter.ngs:292
ArrIter constructor. Example
i = ArrIter([10, 20, 30])
- init(rd:AWS::SecGroup, anchor:Arr)deprecated Source: autoload/globals/AWS.ngs:496
Initialize SecGroup from Arr of [name, vpc_id].
- init(pmy:ParamsMatchY, args:Arr, kwargs:Hash) Source: autoload/globals/ArgvMatcher.ngs:12
Undocumented
- init(ds:DelimStr, a:Arr, delim:Str=':') Source: autoload/globals/DelimStr.ngs:11
DelimStr constructor
- init(n:Doc::Node, name:Str, children:Arr=null, **attrs:Hash) Source: autoload/globals/Doc.ngs:42
Initialize document node Example
Doc::Node('span', class='inline-param') with [ Doc::Text(param.name) Doc::Text(':') Doc::Text(param.type.name) ... ]
- init(g:Doc::Group, children:Arr=null, **attrs:Hash) Source: autoload/globals/Doc.ngs:54
Initialize document nodes group Example
Doc::Group() with [ Doc::Text('something') ... ]
- init(t:Table, name:Any, rows_hashes:Arr) Source: autoload/globals/Table.ngs:45
Create named table containing provided rows Parameters
name name of the table for display and for configuration purposes rows_hashes rows, each row is a Hash
- init(t:Table, rows_hashes:Arr) Source: autoload/globals/Table.ngs:57
Create unnamed table containing provided rows
- init(tv:TableView, name:Any=null, view_name:Str=null, columns:Arr=null) Source: autoload/globals/Table2.ngs:9
Undocumented
- init(t:Table, name:AnyOf(Str, Null), rows_hashes:Arr) Source: autoload/globals/Table2.ngs:152
Create named table containing provided rows Parameters
name name of the table for display and for configuration purposes rows_hashes rows, each row is a Hash
- init(t:Table, rows_hashes:Arr) Source: autoload/globals/Table2.ngs:177
Create unnamed table containing provided rows
- inspect(path:Arr, val:Any)internal Source: stdlib.ngs:646
Internal method. Please do not use. Inspect any value. Returns
Arr with exactly one Str of the form <TYPE_NAME ...>
- inspect(path:Arr, e:Eachable1)internal Source: stdlib.ngs:659
Internal method. Please do not use. Inspect Eachable1 Returns
Arr of Str
- inspect(path:Arr, x:Any)internal Source: stdlib.ngs:709
Internal method. Please do not use. For Type, NativeMethod, UserDefinedMethod Returns
Arr of Str
- inspect(path:Arr, mm:MultiMethod)internal Source: stdlib.ngs:724
Internal method. Please do not use. Inspect MultiMethod Returns
Arr of Str
- inspect(path:Arr, s:Str)internal Source: stdlib.ngs:731
Internal method. Please do not use. Inspect Str Returns
Arr of Str
- inspect(path:Arr, h:Any)internal Source: stdlib.ngs:738
Internal method. Please do not use. Inspect Hash and similar data structures Returns
Arr of Str
- inspect(path:Arr, cp:CommandsPipeline)internal Source: stdlib.ngs:751
Internal method. Please do not use. Inspect CommandsPipeline Returns
Arr of Str
- inspect(path:Arr, a:Set) Source: stdlib.ngs:2472
Inspect Set Returns
Arr of Str
- intersperse(a:Arr, delim:Any) Source: stdlib.ngs:3912
Insert delimiter element between each two elements in an array Returns
ArrExample
[1,2,3].intersperse(0) # [1,0,2,0,3]
- Iter(arr:Arr) Source: autoload/globals/Iter.ngs:287
Calls ArrIter constructor. Returns
ArrIterExample
i = Iter([10, 20, 30])
- join(arr:Arr, s:Str)
Join strings using s as glue Parameters
arr Arr of Str
- join(a:Arr, sep:Arr) Source: stdlib.ngs:3532
EXPERIMENTAL! Do not use! Parameters
a Array of arrays to join sep Separator elements Example
[[1,2], [3,4]].join([10,20]) # [1,2,10,20,3,4]
- join(a:Arr, s:Str) Source: stdlib.ngs:3814
Join non-strings. Converts elements to string first, then uses native join(). Parameters
a Array to join s Delimiter Returns
StrExample
[1,2,3].join("::") # The string 1::2::3
- join(threads:Arr)deprecated Source: stdlib.ngs:5672
Joins threads. Parameters
threads Arr of Thread. Returns
Arr, the results from threads, in order.
- JsonData(arr:Arr) Source: stdlib.ngs:3584
Convert Arr into JSON compatible data structure - array
- len(arr:Arr)
Get number of elements in the array Returns
Int
- limit(a:Arr, l:Int) Source: stdlib.ngs:3741
Truncate an array if necessary so it would have maximum l elements. Parameters
a Array to (possibly) truncate. l Maximum elements Returns
Either a or new Arr of length lExample
[10,11,12].limit(2) # [10,11] [10,11,12].limit(10) # [10,11,12]
- lines(f:File, lines_:Arr) Source: stdlib.ngs:6767
Write given lines to the file. Overwrites the file. Returns
f
- map(arr:Arr, n:Int, mapper:Fun) Source: stdlib.ngs:3366
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
- merge_sorted(a:Arr, b:Arr, lte:Fun) Source: stdlib.ngs:3824
Merge sorted arrays. Parameters
lte Less-then-or-equal function to use for comparison of items in a and b Returns
ArrExample
merge_sorted([1,3,10], [0, 7], (<=)) # [0, 1, 3, 7, 10]
- MultiMethod(methods:Arr)
Construct MultiMethod from the given methods Returns
MultiMethod
- pop(arr:Arr)
Pop item from an array. Removes last item in array and returns it. Throws EmptyArrayFail. Returns
AnyExample
a=[1,2]; a.pop() # 2, a is now [1]
- push(arr:Arr, v:Any)
Append item to an array. Returns
arrExample
a=[1,2]; a.push(3) # a is now [1,2,3]
- push(t:Table, row_arr:Arr) Source: autoload/globals/Table.ngs:66
Append given row to the table Returns
t
- push(t:Table, row_arr:Arr) Source: autoload/globals/Table2.ngs:206
Append given row to the table Returns
t
- rand(a:Arr) Source: stdlib.ngs:9078
Pick one random element from array Returns
Any
- reverse(arr:Arr) Source: stdlib.ngs:3503
Make new array which is a reversed given array Returns
ArrExample
[1,2,3].reverse() # [3,2,1]
- shift(arr:Arr)
Get the first element and remove it from the array. Throws EmptyArrayFail if there are no elements in the array. Returns
Any
- shift(arr:Arr, dflt:Any)
Get the first element and remove it from the array. Returns dflt if there are no elements in the array. Returns
Any
- sort(a:Arr, lte:Fun=method) Source: stdlib.ngs:3847
Sort an array. Parameters
lte Less-then-or-equal function to use for comparison of the items in a Returns
ArrExample
sort([0,5,3,-1], (<=)) # [-1, 0, 3, 5]
- sort(a:Arr, field:Str, lte:Fun=method) Source: stdlib.ngs:3862
Sort an array based on field value Parameters
lte Less-then-or-equal function to use for comparison of the items' fields Returns
ArrExample
[{'x': 1}, {'x': 5}, {'x': 3}].sort('x') # [{'x': 1}, {'x': 3}, {'x': 5}]
- stdlib_aws_straighten_tags(a:Arr) Source: stdlib.ngs:7824
Do not use directly. Subject to change. Convert "Tags" array in each element of AWS resources (typically returned by AWS CLI) into Hash. Makes "Tags" much more usable.
- Str(a:Arr) Source: stdlib.ngs:5081
Convert Arr to string Returns
Str
- subset(smaller:Arr, larger:Arr) Source: stdlib.ngs:3280
Undocumented
- tr(x:Any, a:Arr, tc:TrContext) Source: autoload/globals/tr.ngs:114
Match / transform x using the pattern in a Returns
Lit or TrCommand
- Type(t:Str, doc:Any, ns:Any, parents:Arr) Source: stdlib.ngs:116
Create a new type. Do not use directly. Automatically called by NGS for syntax
type MyType2([MyParent1, MyParent2, ...])
- unshift(arr:Arr, elt:Any) Source: stdlib.ngs:3521
Prepend one element to the given array Returns
Modified arrExample
x=[1,2] x.unshift(3) echo(x) # Outputs: [3,1,2]
- ~(arr:Arr, r:PredRange) Source: stdlib.ngs:3711
Check whether the array contains the given range. Finds first match. Returns
MatchResultExample
a = %[a1 a2 b1 b2] m = a ~ /^a/../^b/ # Exclusive range # m.matches == [['a2']] # m.before == ['a1'] # m.after == ['b1', 'b2']
- ~(argv:Arr, udm:UserDefinedMethod) Source: autoload/globals/ArgvMatcher.ngs:42
Please do not use directly! Tries to match command line arguments with closure parameters. Parameters
argv Command line arguments, typically ARGV udm UserDefinedMethod to match with Returns
Match (ParamsMatchY on success, ParamsMatchN on failure). If ParamsMatchY is returned it has "matches" field with values in suitable order to call c. If ParamsMatchN is returned, it has "message" field explaining why there was no match. Currently it's not printed anywhere.Example
ArgvMatcher; (["--b", "B", "A", "C"] ~ F(a,b,c) 7).matches # %[A B C] (["A", "C", "D", "--b", "B"] ~ ArgvMatcher("positionals", "a") do F(a,b) 7).matches # %[%[A C D] B]
- AWS::util::world_open_port(port:Arr, proto:Str='tcp') Source: autoload/globals/AWS.ngs:1512
Undocumented
- AWS::util::world_open_ip_proto(proto:Arr) Source: autoload/globals/AWS.ngs:1521
Undocumented
- AWS2::regions(cb:Fun, regs:Arr=[]) Source: autoload/globals/AWS2.ngs:89
Call cb in parallel threads, each with AWS region name as argument. Parameters
cb Must return an array. regions() sets ._Region in the result and flattens the results Returns
ArrExample
ins = AWS2::regions({ ``aws ec2 describe-instances --region $A $*filters`` })
- AWS2::regions(cp:CommandsPipeline, regs:Arr=[]) Source: autoload/globals/AWS2.ngs:102
Undocumented
- Doc::transform(dps:Arr, transformer:Any) Source: autoload/globals/Doc.ngs:105
Undocumented
- Doc::visit(p:Doc::Part, cb:Fun, parents:Arr=[]) Source: autoload/globals/Doc.ngs:110
Undocumented