Types

Int

Integer type. On 64 bit platforms it's a 61 bit signed integer

Parent types

Constructors

Int(r:Real)
Convert Real (floating) number to Int. Floating part is truncated.
Int(s:Str, base:Int)
Convert Str to Int.
Int(s:Str)
Convert base-10 string to Int. Throws InvalidArgument if the number in s is not well-formatted.
Int(b:Bool)
Convert Bool to int.

Methods

%(a:Int, b:Int)
Modulus
*(a:Int, b:Int)
Multiplication
*(arr:Arr, n:Int)
Repeat all elements in arr n times
*(s:Str, n:Int)
Repeat string n times
*(cb:Fun, n:Int)
Call cb n times without any parameters and accumulate the results.
+(a:Int, b:Int)
Addition
-(a:Int, b:Int)
Subtraction
/(a:Int, b:Int)
Division
<(a:Int, b:Int)
Less-than comparison
<=(a:Int, b:Int)
Less-than-or-equal comparison
==(a:Int, b:Int)
Equality comparison
>(a:Int, b:Int)
Greater-than comparison
>=(a:Int, b:Int)
Greater-than-or-equal comparison
[](arr:Arr, idx:Int)
[](al:ArrLike, idx:Int)
Set element in the underlying array.
[](arr:Arr, idx:Int)
Get array element by index from the end
[](s:Str, i:Int)
Get given character (currently byte) of the string
[](s:Str, i:Int)
Get given character (currently byte) of the string. TODO: Document InvalidArgument exception.
[](my:MatchY, idx:Int)
Convenience method to access matches in MatchY
[]=(arr:Arr, idx:Int, v:Any)
[]=(al:ArrLike, idx:Int, x:Any)
Get element from the underlying array.
Arg(x:Int)
assert_exit_code(p:Process, expected:Int, title:Any=null)
band(a:Int, b:Int)
Bitwise and
bor(a:Int, b:Int)
Bitwise or
bxor(a:Int, b:Int)
Bitwise xor
c_access(pathname:Str, mode:Int)
Call ACCESS(2)
c_close(fd:Int)
c_dlopen(filename:Str, flags:Int)
Unfinished feature. Don't use!
c_dup2(oldfd:Int, newfd:Int)
c_dup2(oldfd:Int, newfd:Int)
c_exit(status:Int)
Call EXIT(3)
c_fstat(fd:Int)
Call FSTAT(2)
c_isatty(fd:Int)
c_kill(pid:Int, sig:Int)
c_lseek(fd:Int, offset:Int, whence:Str)
c_pcre_compile(regexp:Str, flags:Int)
Throws RegExpCompileFail on errors.
c_pcre_exec(regexp:RegExp, subject:Str, offset:Int, options:Int)
Search string for regular expression. Uses PCRE_EXEC(3). Do not use this function directly!
c_poll(fds_evs:Arr, timeout:Int)
c_read(fd:Int, count:Int)
c_strerror(errnum:Int)
c_waitpid(pid:Int)
C_WEXITSTATUS(status:Int)
c_write(fd:Int, s:Str)
C_WTERMSIG(status:Int)
calculate_num_cols_to_show(t:Table, max_colums_widths:Arr, available_cols:Int)
chr(code:Int)
Get character (byte) by it's ordinal value.
code(n:Int)
Convert an Int to NGS code that would produce the integer when executed. Not fully functional yet.
collector(n:Int, body:Fun)
Defines collector { ... collect(...) ... } behaviour for integers (summarizes collected items).
column(t:Table, n:Int)
create(rd:ResDef, n:Int, **props:Hash)
drop(i:Iter, n:Int)
Fetch and drop next n values from iterator i.
dup2(oldfd:Int, newfd:Int)
dup2_reading_end(p:Pipe, newfd:Int)
DUP2(2) reading file descriptor
dup2_writing_end(p:Pipe, newfd:Int)
DUP2(2) writing file descriptor
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(n:Int, cb:Fun)
Iterate from zero up to but not including n
echo(fd:Int, s:Str)
Print given string and a newline to a file referenced by descriptor.
expect(rd:ResDef, e:Int)
get(arr:Arr, idx:Int, dflt:Any)
init(pipe:Pipe, direction:Int)
Pipe constructor. Create UNIX pipe using PIPE(2). Throws PipeCreateFail if pipe can not be created.
init(f:File, fd:Int)
init(e:LockFail, op:Str, code:Int, msg:Str)
inspect(i:Int)
Inspect Int
Int(s:Str, base:Int)
Convert Str to Int.
is_global_variable_defined(idx:Int)
Do not use directly! Check whether global variable is defined by index.
isatty(fd:Int)
Check whether given fd represents a TTY. Uses ISATTY(3). Throws TtyCheckFail.
kill(pid:Int, sig:Int=15)
Send signal to a process. Uses KILL(2). Throws KillFail on error.
kill(p:Process, sig:Int=15)
Send signal to a Process. Uses KILL(2). Throws InvalidArgument if Process does not have "pid". Throws KillFail on error.
limit(a:Arr, l:Int)
Truncate an array if necessary so it would have maximum l elements.
limit(h:Hash, l:Int)
Truncate a Hash if necessary so it would have maximum l key-value pairs.
limit(s:Str, n:Int, marker:Str=)
Truncate a string if necessary so it would have maximum n characters (currently bytes).
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_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
ord(s:Str, idx:Int)
Get character (byte) ordinal value. Throws InvalidArgument if idx is not pointing into s.
pmap(n:Int, mapper:Fun)
pos(haystack:Str, needle:Str, start:Int)
Find substring position
print_exception(e:Exception, level:Int=0, parent:Exception=null)
Print exception to stderr. Uses inspect().
ptimes(n:Int, cb:Fun)
rand(something:Any, n:Int)
Pick n elements from something. Uniqueness of picked elements is not guaranteed.
rand(n:Int)
Pick random number from 0 up to but not including n
rand(a:Str, n:Int)
rand_uniq(something:Any, n:Int)
Pick n random unique elements from something
read(fd:Int)
Read all data from a file referenced by file descriptor without parsing it.
Real(n:Int)
Convert Int to Real
resolve_instruction_pointer(ip:Int)
Resolves Instruction Pointer to source location
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.
set_global_variable(idx:Int, val:Any)
Do not use directly! Set global variable by index.
srand(seed:Int)
Seed random generator. Uses SRANDOM(3).
Str(n:Int)
Convert Int to Str
Str(x:Any, target_width:Int)
Convert anything to Str of a given width
Str(s:Str, target_width:Int)
Pad a string to given width with spaces
Str(n:Int, target_width:Int)
Convert a number to a string and pad it
StrForTable(x:Any, width:Int)
StrForTable(x:Null, width:Int)
take(i:Iter, n:Int)
Fetch and convert to array next n values from iterator i.
times(n:Int, cb:Fun)
Call cb n times without arguments.
to_exit_code(n:Int)
write(s:Str, fd:Int)
Write data to a file referenced by file descriptor. WARNING: Incomplete implementation. TODO: handle errors, throw exceptions. TODO: handle possible EINTR.
~(s:Str, r:RegExp, offset:Int=0, options:Int=0)
Find PCRE regular expression in s. Empty string without options returns MatchN. Throws Error if more than 20 captures are used or if there is an error during matching.