NumRange type

Numerical range

Direct parent types

Range
A range
Direct subtypes: 2
Eachable1
Eachable which each() calls the callback with one argument
Direct subtypes: 16

Methods

[](arr:Arr, range:NumRange)
Get array elements at specified indexes.

Returns

Arr
[](s:Str, range:NumRange)
Get substring

Example

"abcd"[1..3]  # "bc"
[](arr:Arr, r:NumRange) Source: stdlib.ngs:2049
Get array elements at specified indexes. Indexes specified by NumRange.

Parameters

rNumRange with negatve .end

Returns

Arr

Example

[10,20,30,40][1..-1]  # [20,30]
[](s:Str, r:NumRange) Source: stdlib.ngs:3458
Get a substring. Indexes in s are specified by NumRange.

Parameters

sOriginal string
rNumRange with negatve .end

Returns

Str

Example

"(Look ma, no parens)"[1..-1]  # "Look ma, no parens"
[]=(arr:Arr, range:NumRange, replacement:Arr)
Set array elements at specified indexes.

Returns

replacement
[]=(s:Str, range:NumRange, replacement:Str)
Change substring

Returns

replacement

Example

s="abcd"; s[1..3]="X"; s  # "aXd"
each(r:NumRange, cb:Fun) Source: stdlib.ngs:1344
Iterates over the elements of r, passing each in turn to cb.

Parameters

cbFunction to be called with values from r

Returns

r

Example

s=0
(1...10).each(F(i) { global s; s+=i })
echo(s)  # Outputs: 55
finished_ok(p:Process, field_name:Str, ok:NumRange)internal Source: stdlib.ngs:4719
Decide whether a process finished normally.

Example

$(ok:0..10 ls no-such-file)
in(n:Int, r:NumRange) Source: stdlib.ngs:1356
Check whether the number is in range 10 in 10..20 # true 1 in 10..20 # false
init(i:RangeIter, r:NumRange) Source: autoload/Iter.ngs:248
Initialize RangeIter. Will throw NotImplemented if r.start or r.step are not Int
Iter(r:NumRange) Source: autoload/Iter.ngs:241
Create Iter from NumRange
rand(r:NumRange) Source: stdlib.ngs:6319
Pick one random element from a range

Returns

Any