Int type
Direct parent types
- Eachable1
Eachable which each() calls the callback with one argument Direct subtypes: 16
- Num
A number Direct subtypes: 2
Constructors
- Int(r:Real)
Convert Real (floating) number to Int. Floating part is truncated. Returns
Int
- Int(s:Str, base:Int)
Convert Str to Int. Example
Int("100", 2) # 8 Int("80", 16) # 128
- Int() Source: stdlib.ngs:417
Get zero Returns
0
- Int(i:Int) Source: stdlib.ngs:4256
Convert Int to Int, a no-op Returns
i
- Int(s:Str, base:Any=10) Source: stdlib.ngs:4263
Convert to Int. Throws InvalidArgument if the number in s is not well-formatted. Returns
IntExample
Int(" 100 ") # 100
- Int(b:Bool) Source: stdlib.ngs:4282
Convert Bool to int. Returns
IntExample
true.Int() # 1 false.Int() # 0
- Int(t:Time) Source: stdlib.ngs:7654
Undocumented
Methods
- %(a:Int, b:Int)
Modulus Returns
IntExample
10 % 3 # 1
- *(a:Int, b:Int)
Multiplication
- *(arr:Arr, n:Int) Source: stdlib.ngs:3062
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]
- *(s:Str, n:Int) Source: stdlib.ngs:4474
Repeat string n times Example
"abc" * 3 # "abcabcabc"
- *(cb:Fun, n:Int) Source: stdlib.ngs:7244
Call cb n times without any parameters and accumulate the results. Example
a = Box * 2; a[0] is Box and a[1] is Box and a[0] !== a[1] # true
- +(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)
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
- [](al:ArrLike, idx:Int) Source: stdlib.ngs:1503
Set element in the underlying array.
- [](arr:Arr, idx:Int) Source: stdlib.ngs:2895
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
- [](s:Str, i:Int) Source: stdlib.ngs:4386
Get given character (currently byte) of the string Parameters
s Original string i Index of the character to return Example
"abc"[0] # "a"
- [](s:Str, i:Int) Source: stdlib.ngs:4396
Get given character (currently byte) of the string (negative indexes handler). Throws IndexNotFound if abs(i) > len(s). Parameters
s Original string. i Negative index of the character to return Example
"abc"[-1] # "c"
- [](ms:MatchSuccess, idx:Int) Source: stdlib.ngs:7015
Convenience method to access matches in MatchSuccess Example
("abc" ~ /a(.)c/)[1] # "b"
- []=(arr:Arr, idx:Int, v:Any)
Set element at the given index or throw IndexNotFound if the index is out of range. Returns
v
- []=(al:ArrLike, idx:Int, x:Any) Source: stdlib.ngs:1506
Get element from the underlying array.
- []=(arr:Arr, idx:Int, val:Any) Source: stdlib.ngs:2905
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]
- abs(i:Int) Source: stdlib.ngs:4222
Absolute value of a number Example
abs(5) # 5 abs(-5) # 5
- access(f:File, mode:Int=0) Source: stdlib.ngs:7883
Check whether current process has the specified access to the file. Wrapper around ACCESS(2). Throws CError. Parameters
mode One of the file ACCESS::* modes, defaults to ACCESS::F_OK (test file existence only). Returns
BoolExample
access(File("mydata"), ACCESS::R_OK).not() throws Error("No access to data file").set("file", "mydata")
- Arg(x:Int) Source: stdlib.ngs:6134
Convert to string, appropriate for using as argument to external process. Automatically called by NGS for syntax
$(mycommand $num) # num is Int
- assert_exit_code(pp:ProcessesPipeline, expected:Int, title:Str=null)
Assert process exits with the specified exit code. Throws TestFail. Returns
ppExample
p = $(true); assert_exit_code(p, 0) # OK p = $(false); assert_exit_code(p, 1) # OK p = $(false); assert_exit_code(p, 0) # Throws TestFail
- band(a:Int, b:Int)
Bitwise and Returns
IntExample
7.band(5) # 5
- bor(a:Int, b:Int)
Bitwise or Returns
IntExample
1.bor(8) # 9
- Box(a:Arr, idx:Int) Source: stdlib.ngs:3847
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
- bxor(a:Int, b:Int)
Bitwise xor Returns
IntExample
15.bxor(1) # 14
- c_accept(socket:Int, address:c_sockaddr_un)
Undocumented
- c_access(pathname:Str, mode:Int)
Call ACCESS(2)
- c_bind(socket:Int, address:c_sockaddr_un)
Undocumented
- c_bind(socket:Int, address:c_sockaddr_in)
Undocumented
- c_close(fd:Int)
Close a file. Uses CLOSE(2). Returns
Int - zero on success or -1
- c_dlopen(filename:Str, flags:Int)
Unfinished feature. Don't use!
- c_dup2(oldfd:Int, newfd:Int)
Duplicate a file descriptor. Uses DUP2(2). Returns
Int - file descriptor or -1
- c_exit(status:Int)
Call EXIT(3). Don't use directly unless you must. Use FatalError exception.
- c_fstat(fd:Int)
Call FSTAT(2)
- c_gmtime(timep:Int)
Call GMTIME_R(3) Example
ngs -pl 'c_gmtime(0).Hash().Strs()' tm_sec=0 tm_min=0 tm_hour=0 tm_mday=1 tm_mon=0 tm_year=70 tm_wday=4 tm_yday=0 tm_isdst=0
- c_isatty(fd:Int)
Check if file descriptor refers to a TTY device. Uses ISATTY(3). Returns
Int: 1 or 0
- c_kill(pid:Int, sig:Int)
Call KILL(2). Global variable SIGNALS contains mapping between signals' names and values.
- c_listen(socket:Int, backlog:Int)
Undocumented
- c_localtime(timep:Int)
Call LOCALTIME(3) Example
ngs -pl 'c_gmtime(0).Hash().keys()' tm_sec tm_min tm_hour tm_mday tm_mon tm_year tm_wday tm_yday tm_isdst
- c_lseek(fd:Int, offset:Int, whence:Str)
Call LSEEK(2). Parameters
whence One of: set, cur, end Returns
Int: new offset or -1
- c_pcre_compile(regexp:Str, flags:Int)
Throws RegExpCompileFail on errors. Returns
RegExp
- 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! Returns
Int or Arr of Int
- c_poll(fds_evs:Arr, timeout:Int)
Undocumented
- c_pthread_mutexattr_settype(mutex:c_pthread_mutexattr_t, type:Int)
Call PTHREAD_MUTEXATTR_SETTYPE(3)
- c_read(fd:Int, count:Int)
Read from a file. Uses READ(2). Parameters
count Maximal number of bytes to read. Returns
Arr of two elements: Int - number of bytes read or -1, Str - the read bytes
- c_recvfrom(socket:Int, length:Int, flags:Int, address:c_sockaddr_un)
Undocumented
- c_send(socket:Int, buffer:Str, flags:Int)
Undocumented
- c_socket(domain:Int, type:Int, protocol:Int)
Undocumented
- c_strerror(errnum:Int)
Call STRERROR(2)
- c_sysconf(name:Int)
Undocumented
- c_waitpid(pid:Int)
Call WAITPID(2)
- C_WEXITSTATUS(status:Int)
Use WEXITSTATUS macro.
- c_write(fd:Int, s:Str)
Write to a file. Uses WRITE(2). Returns
Int - number of bytes written or -1
- C_WTERMSIG(status:Int)
Use WTERMSIG macro.
- calculate_num_cols_to_show(t:Table, max_columns_widths:Arr, available_cols:Int)
Internal method. Please do not use.
- chr(code:Int)
Get character (byte) by it's ordinal value. Returns
Str of length 1 (byte).Example
chr(65) # "A" on my machine
- close(fd:Int) Source: stdlib.ngs:5849
Close a file. Uses CLOSE(2). Throws FileIOFail if an underlying error occurs. Returns
fd
- code(n:Int) Source: stdlib.ngs:4289
Convert an Int to NGS code that would produce the integer when executed. Not fully functional yet. Returns
Str
- collector(n:Int, body:Fun) Source: stdlib.ngs:2324
Defines collector { ... collect(...) ... } behaviour for integers (summarizes collected items). Parameters
n Initial number body The body after collector keyword and initial value, wrapped in a function "collector/100 THIS_CODE" Returns
Constructed arrayExample
collector/0 { (1...10).each(collect) } # 55
- column(t:Table, n:Int)
Get values in the given table column. Returns
Arr
- create(rd:ResDef, n:Int, **props:Hash)
Create n resources with given props. Typically called by converge(). Returns
rd
- digest(a:Arr, chunk_size:Int, marker:Str='(...)') Source: stdlib.ngs:7321
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
- drop(i:Iter, n:Int)
Fetch and drop next n values from iterator i. Example
i = Iter([10,20,30]) drop(i, 1) echo(i.next()) # Output: 20
- dup2(oldfd:Int, newfd:Int) Source: stdlib.ngs:5547
Duplicate a file descriptor. Uses DUP2(2). Handles EINTR.
- dup2_reading_end(p:Pipe, newfd:Int) Source: stdlib.ngs:5740
DUP2(2) reading file descriptor
- dup2_writing_end(p:Pipe, newfd:Int) Source: stdlib.ngs:5737
DUP2(2) writing file descriptor
- each(arr:Arr, n:Int, cb:Fun) Source: stdlib.ngs:2649
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(n:Int, cb:Fun) Source: stdlib.ngs:4239
Iterate from zero up to but not including n Parameters
cb Function to call with current number Returns
nExample
10.each(echo) # Outputs numbers from 0 to 9 inclusive, one on each line
- each_chunk(e:Eachable1, n:Int, cb:Fun)experimental Source: stdlib.ngs:3179
Call cb with array of maximum length of n, repeatedly for all items of e. TODO: better doc, rename to each() to be consistent with each(Arr, Int, Fun)?
- echo(fd:Int, s:Str) Source: stdlib.ngs:5639
Write a string followed by newline character to a file descriptor. Throws WriteFail on failure. Returns
nullExample
echo(2, "blah") # Output on stderr: blah"
- encode_base64(s:Str, wrap:Int=0)experimental Source: stdlib.ngs:7976
Undocumented
- encode_base64(s:Str, wrap:Int=0)experimental Source: stdlib.ngs:7982
Undocumented
- ensure(n:Int, r:NumRange) Source: stdlib.ngs:2260
Checks that x is in the range. Example
ensure(3, 3..10) # 3
- ExitCode(n:Int) Source: stdlib.ngs:144
Undocumented Returns
n
- expect(rd:ResDef, e:Int)
Throw an exception unless there is exactly e resources were found. Useful to express assumptions before operating. Returns
rdExample
slave_build_server = AWS::Instance(Tags={'env': 'aux', 'role': 'build-slave'}).expect(1) subnets = AWS::Subnet(my_vpc_anchor).expect(2)
- finished_ok(p:Process, field_name:Str, ok:Int)internal Source: stdlib.ngs:5949
Decide whether a process finished normally. Example
$(ok:1 ls no-such-file) # No exception $(ok:10 ls no-such-file) # ProcessFail exception
- get(al:ArrLike, idx:Int, dflt:Any) Source: stdlib.ngs:1509
Get element at the given index or return dflt if the index is out of range (element at the given index does not exist). See get(Arr).
- get(a:Arr, idx:Int, dflt:Any=null) Source: stdlib.ngs:2463
Get element at the given index or return dflt if the index is out of range (element at the given index does not exist) Returns
AnyExample
[1,2,3].get(0, 10) # 1 [1,2,3].get(5, 10) # 10 [11].get(-1) # 11 [10,20].get(-5, "X") # "X"
- get(ms:MatchSuccess, idx:Int, dflt:Any=null) Source: stdlib.ngs:7018
Get indexed match, returning dflt is the match is not found
- gmtime(t:Int) Source: stdlib.ngs:7580
Low-level function. Do not use directly. Use Time type.
- has_index(e:Eachable1, i:Int) Source: stdlib.ngs:1441
Check whether Eachable1 has the given index: -len(e) <= i < len(e) Returns
Bool
- in(n:Int, r:NumRange) Source: stdlib.ngs:2215
Check whether the number is in range 10 in 10..20 # true 1 in 10..20 # false
- index(arr:Arr, pattern:Any=method, start:Int=0, dflt:Any=block) Source: stdlib.ngs:2770
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 to return when element is not found Returns
Int or dflt. Temporary also null, for backwards compatibility.Example
[1,2,11,3,4].index(X>10) # 2
- init(r:Repeat, pattern:Any, count:Int) Source: stdlib.ngs:962
Undocumented
- init(e:CError, errno:Int, message:Str) Source: stdlib.ngs:2055
CError constructor. In addition to storing message field, adds errno and errno_name fields.
- init(e:LockFail, op:Str, code:Int, msg:Str) Source: stdlib.ngs:2079
Initialize LockFail exception.
- init(ee:ExitException, message:Str, exit_code:Int=1) Source: stdlib.ngs:5019
Initializes ExitException.
- init(ee:ExitException, exit_code:Int=1) Source: stdlib.ngs:5023
Undocumented
- init(f:File, fd:Int) Source: stdlib.ngs:5755
Create File object from the given file descriptor.
- init(t:Time, epoch:Int) Source: stdlib.ngs:7605
Initialize Time object with the given epoch time.
- init(t:Terminal, fd_in:Int, fd_out:Int)
Undocumented
- isatty(fd:Int) Source: stdlib.ngs:5649
Check whether given fd represents a TTY. Uses ISATTY(3). Throws TtyCheckFail. Returns
Bool
- Iter(n:Int)
Create Iter from Int
- JsonData(n:Int) Source: stdlib.ngs:4292
Convert Int into JSON compatible data structure - number
- kill(pid:Int, sig:Int=15) Source: stdlib.ngs:6539
Send signal to a process. Uses KILL(2). Throws KillFail on error. Parameters
sig Signal to send. Defaults to SIGNALS.TERM Returns
unspecified at this time, do not count on it
- kill(p:Process, sig:Int=15) Source: stdlib.ngs:6552
Send signal to a Process. Uses KILL(2). Throws InvalidArgument if Process does not have "pid". Throws KillFail on error. Parameters
sig Signal to send. Defaults to SIGNALS.TERM Returns
unspecified at this time, do not count on it
- kill(pp:ProcessesPipeline, sig:Int=15) Source: stdlib.ngs:6558
Kill all processes in the ProcessesPipeline. Throws InvalidArgument if ProcessesPipeline is not running (yet).
- len(i:Int) Source: stdlib.ngs:4229
Useful for knowing how much times each() callback would be invoked. Alternatively, how many elements map() result would have. Returns
i
- limit(a:Arr, l:Int) Source: stdlib.ngs:3025
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]
- limit(h:Hash, l:Int) Source: stdlib.ngs:3613
Truncate a Hash if necessary so it would have maximum l key-value pairs. Parameters
h Source hash l Maximum elements Returns
HashExample
{"a": 1, "b": 2}.limit(1) # {"a": 1}
- limit(s:Str, n:Int, marker:Str='') Source: stdlib.ngs:4631
Truncate a string if necessary so it would have maximum n characters (currently bytes). Parameters
s The string to (possibly) truncate. n Maximum characters marker The truncation marker Returns
Either s or new Str of length nExample
"abc".limit(5, "...") # "abc" "abcdef".limit(5, "...") # "ab..." "abcdef".limit(2) # "ab"
- ll_is_global_variable_defined(idx:Int)
Do not use directly! Check whether global variable is defined by index.
- ll_set_global_variable(idx:Int, val:Any)
Do not use directly! Set global variable by index.
- localtime(t:Int) Source: stdlib.ngs:7587
Low-level function. Do not use directly. Use Time type.
- map(arr:Arr, n:Int, mapper:Fun) Source: stdlib.ngs:2670
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
- map_base_idx(base:Any, n:Int, mapper:Fun)deprecated Source: stdlib.ngs:1332
Deprecated. Map when there is more than one element. If there is exactly one element, it's left as is Parameters
mapper Will be called with zero based index and successive elements from arr Returns
Arr
- ord(s:Str, idx:Int)
Get character (byte) ordinal value. Throws InvalidArgument if idx is not pointing into s. Parameters
idx Index of the character to get value of Returns
IntExample
ord("A", 0) # 65 on my machine
- pfilter(e:Eachable1, threads:Int, pattern:Any) Source: stdlib.ngs:4979
Parallel filter. Typcally should be used with "heavy" pattern such as SSH. Returns
Of same type as eExample
Set(1..10).pfilter(2, X>3) # <Set 4, 5, 6, 7, 8, 9>
- pmap(e:Eachable1, threads:Int, mapper:Fun) Source: stdlib.ngs:4933
Parallel map. Runs mapper in "threads" total threads. Parameters
e Eachable1 to be mapped threads number of threads to use mapper called with elements from e Returns
Arr, result of applying mapper to elements of e, preserving the order.Example
pages_texts = abs_pages_urls.pmap(F(url) `lynx -dump $url`)
- pos(haystack:Str, needle:Str, start:Int)
Find substring position Parameters
start Non-negative Int, position where the search starts Returns
Int or null. Not -1 as in many languages
- pow(base:Int, exponent:Int) Source: stdlib.ngs:8169
Calls pow(Real, Real) converting parameters and results to and from Real
- print_exception(e:Exception, level:Int=0, parent:Exception=null, echo:Any=method) Source: stdlib.ngs:7468
Print exception to stderr. Uses inspect(). Parameters
level indentation level to use (two spaces for each level) parent parent exception if print_exception() was called for .cause exception
- ptimes(n:Int, cb:Fun) Source: stdlib.ngs:4958
Run cb in n parallel threads. Each thread runs one cb but this might change in future (preserving the total n calls to cb).
- rand(something:Any, n:Int) Source: stdlib.ngs:7699
Pick n elements from something. Uniqueness of picked elements is not guaranteed. Returns
Any
- rand(n:Int) Source: stdlib.ngs:7704
Pick random number from 0 up to but not including n Returns
Int
- rand(a:Str, n:Int) Source: stdlib.ngs:7721
Undocumented
- rand_uniq(something:Any, n:Int) Source: stdlib.ngs:7680
Pick n random unique elements from something Parameters
something Something that has len(something) and something[idx] Returns
Arr or Str, depending on something
- read(fd:Int, count:Any=null) Source: stdlib.ngs:5563
Read all data from a file referenced by file descriptor without parsing it. Parameters
fd File descriptor to read from Returns
StrExample
read(0) # All data from stdin
- read(t:Terminal, count:Int=1)
Undocumented
- Real(n:Int)
Convert Int to Real
- resolve_instruction_pointer(ip:Int)
Resolves Instruction Pointer to source location Parameters
ip Result of calling Backtrace(). Backtrace().frames[0].ip for example. Returns
Hash with keys: file, first_line, first_column, last_line, last_column, ipExample
resolve_instruction_pointer(Backtrace().frames[0].ip) # {ip=4770, file=/etc/ngs/bootstrap.ngs, first_line=245, first_column=1, last_line=245, last_column=34}
- retry(times:Int=60, sleep:Any=1, logger:Fun=method, success_predicate:Any=method, title:Any='<retry>', progress_cb:Fun=method, success_cb:Fun=method, fail_cb:Any=method, body:Fun=method) Source: stdlib.ngs:7760
Retry. Executes given "body" "times" times. Throws RetryFail if all calls fail and fail_cb is not provided. Parameters
times Limit of times to run "body" sleep Either sleep in seconds between tries or Iter that returns successive sleep times in seconds logger Function to use to log attempts, caught body exceptions and sleep times. Defaults to stdlib's debug. success_predicate CANDIDATE FOR REMOVAL. Run against body results to. Says whether the attempt succeeded. Defaults to Bool. title Prefix strings sent to logger with this string. Defaults to "<retry>". progress_cb Called before each attempt with (1) current attempt number and (2) limit of attempts ("times"). Defaults to do nothing. success_cb Called when body succeeds with the result that comes from body. Defaults to identity function. fail_cb If passed, called if all attempts fail. Defaults to null. Returns
Any. Result of success_cb or result of fail_cb.Example
page = retry(times=10, sleep=ExpBackIter(), body={ try `curl "http://flaky-site.com"` })
- skip(i:Iter, count:Int)
Returns the given Iter after consuming first count elements. Returns
IterExample
[3, 4, 5, 34, 5].Iter().skip(3).Arr() == [34, 5]
- split(s:Str, delim:Str, max_parts:Int=0) Source: stdlib.ngs:4426
Split string by substring Parameters
s String to split delim Delimiter to split by max_parts Maximum number of resulting parts, 0 - unlimited Returns
Arr of StrExample
":a:bc:d:".split(":") # ["", "a", "bc", "d", ""] "bucket_name/dir/file".split("/", 2) # ["bucket_name", "dir/file"] ":a:bc:d:".split("bc") # [":a:", ":d:"]
- srand(seed:Int)
Seed random generator. Uses SRANDOM(3). Returns
Unspecified
- Str(n:Int)
Convert Int to Str
- Str(x:Any, target_width:Int, ch:Str=' ') Source: stdlib.ngs:4479
Convert anything to Str of a given width
- Str(s:Str, target_width:Int, ch:Str=' ') Source: stdlib.ngs:4486
Pad a string to given width with spaces Parameters
target_width Positive pads on right, negative pads on left Example
Str("x", 3) # 'x ' Str("x",-3) # ' x'
- Str(n:Int, target_width:Int, ch:Str=' ') Source: stdlib.ngs:4508
Convert a number to a string and pad it Parameters
target_width Positive pads on left, negative pads on right Example
Str(10, 4) # ' 10' Str(10, -4) # '10 '
- StrForTable(x:Any, width:Int)
Internal method. Please do not use.
- StrForTable(x:Null, width:Int)
Internal method. Please do not use.
- sysconf(name:Int) Source: stdlib.ngs:8205
Undocumented
- take(i:Iter, n:Int)
Fetch and convert to array next n values from iterator i. Example
i = Iter([10,20,30]) echo(i.take(2)) # Output: [10,20]
- times(n:Int, cb:Fun) Source: stdlib.ngs:4250
Call cb n times without arguments. Parameters
cb Function to call Example
r=0; 5.times(F() r=r+2); # r is now 10
- write(s:Str, fd:Int)deprecated Source: stdlib.ngs:5595
DEPRECATED! Do not use!
- write(fd:Int, s:Str) Source: stdlib.ngs:5613
Throws WriteFail on failure. Parameters
fd File descriptor to write to s String of bytes to write Returns
fd
- ~(haystack:Str, needle:Str, offset:Int=0) Source: stdlib.ngs:4656
Find substring in string. Uses pos(). Returns
MatchResultExample
"abc" ~ "bc" # <MatchSuccess ...> "abc" ~ "X" # <MatchFailure>
- ~(s:Str, r:RegExp, offset:Int=0, options:Int=0) Source: stdlib.ngs:7045
Find PCRE regular expression in s. Empty string without options returns MatchFailure. Throws Error if more than 20 captures are used or if there is an error during matching. Automatically called by NGS for syntax
my_str ~ my_regexp
Parameters
offset search start offset options options to pass to underlying PCRE_EXEC(3). Returns
MatchResultExample
globals().keys().filter(/^C_PCRE/) # lists possible options "xabcy" ~ /a(.)c/ # <MatchSuccess matches=[abc,b] pattern=<RegExp> named={} positions=[<NumRange 1..4 include_start=true include_end=false step=1>,<NumRange 2..3 include_start=true include_end=false step=1>] whole=abc before=x after=y> m = ("xabcy" ~ /a(?P<mychar>.)c/) echo(m.named.mychar) # Outputs: b
- AWS::util::world_open_port(port:Int, proto:Str='tcp')
Undocumented