This appendix summarizes the interpreter-level built-ins documented in the Nex Reference. It is not intended to replace the full reference pages, but to give one compact place to look up the core types used throughout the tutorial.
| Name | Signature | Purpose |
|---|---|---|
print |
print(...args) |
Write values to interpreter output. |
println |
println(...args) |
Line-oriented output. |
type_of |
type_of(value): String |
Return runtime type name. |
type_is |
type_is(type_name: String, value): Boolean |
Check runtime type compatibility. |
sleep |
sleep(ms: Integer) |
Pause the current task for ms milliseconds. |
await_all |
await_all(tasks: Array[Task]) |
Block until all tasks in the array complete. |
await_any |
await_any(tasks: Array[Task]) |
Block until at least one task in the array completes. |
| Type | Main Features | Notes |
|---|---|---|
Function |
call0 through call32 |
Invocation protocol for function-like values. |
Comparable |
compare |
Ordering support for scalars and other comparable values. |
Hashable |
hash |
Required for map keys. |
Cursor |
start, item, next, at_end |
Iteration protocol used by across. |
StringCommon operations:
lengthindex_ofsubstring(start, end)to_upper, to_lowerto_integer, to_integer64, to_real, to_decimalcontains, starts_with, ends_withtrim, replacechar_atsplitcompare, hash, cursorExample:
let s: String := " Nex "
print(s.trim().to_upper()) -- "NEX"
print(s.split(" ")) -- array of pieces
IntegerCommon operations:
to_stringabs, min, maxpickbitwise_left_shift, bitwise_right_shift, bitwise_logical_right_shiftbitwise_rotate_left, bitwise_rotate_rightbitwise_is_set, bitwise_set, bitwise_unsetbitwise_and, bitwise_or, bitwise_xor, bitwise_notplus, minus, times, divided_bycompare, hashBitwise operations use 32-bit integer semantics. Bit 0 is the least-significant bit. When calling a bitwise method on an integer literal, wrap the literal in parentheses:
print((5).bitwise_left_shift(1)) -- 10
print((6).bitwise_and(3)) -- 2
print((5).bitwise_is_set(0)) -- true
Integer64Common operations parallel Integer:
to_stringabs, min, maxcompare, hashRealCommon operations:
to_stringabs, min, max, roundcompare, hashDecimalCommon operations:
to_stringabs, min, max, roundcompare, hashBooleanCommon operations:
to_stringand, or, notcompare, hashCharCommon operations:
to_stringto_upper, to_lowercompare, hashArray[T]Construction:
[]
Main methods:
| Method | Purpose |
|---|---|
get(index) |
Read element at index. |
add(value) |
Append value. |
add_at(index, value) |
Insert value. |
put(index, value) |
Replace value at index. |
length |
Element count. |
is_empty |
Check emptiness. |
contains(elem) |
Membership test. |
index_of(elem) |
First index or -1. |
remove(index) |
Remove element at index. |
reverse |
Return reversed array. |
sort |
Sort array. |
slice(start, end) |
Subrange. |
concat(other) |
Return a new array with other appended. |
cursor |
Iterator for across. |
Map[K, V]Construction:
{}
Main methods:
| Method | Purpose |
|---|---|
get(key) |
Read value for key. |
try_get(key, default) |
Read value or fallback. |
set(key, value) |
Add or replace an entry. |
put(key, value) |
Alias for set. |
size |
Number of entries. |
is_empty |
Check emptiness. |
contains_key(key) |
Membership by key. |
keys |
Array of keys. |
values |
Array of values. |
remove(key) |
Delete entry. |
cursor |
Iterator over entries. |
Set[T]Construction:
create Set[Integer].from_array([1, 2, 3])
#{}
#{1, 2, 3}
Notes:
#{1, 2, 3} create sets.#{}.{} still creates an empty map.Main methods:
| Method | Purpose |
|---|---|
contains(value) |
Membership test. |
union(other) |
Set union. |
difference(other) |
Elements in this set but not in other. |
intersection(other) |
Common elements. |
symmetric_difference(other) |
Elements that occur in exactly one set. |
size |
Number of elements. |
is_empty |
Check emptiness. |
cursor |
Iterator for across. |
Stack[T]Stack[T] is not a built-in collection type. It is the standard tutorial example of a user-defined generic collection class built on top of Array[T].
Typical operations:
| Method | Purpose |
|---|---|
push(value) |
Add an element to the top. |
pop() |
Remove and return the top element. |
peek() |
Return the top element without removing it. |
is_empty() |
Check emptiness. |
size() |
Number of stored elements. |
Concrete cursor classes:
ArrayCursorStringCursorMapCursorSetCursorThey implement the Cursor protocol and are usually used indirectly through across.
ConsoleConstruction:
create Console
Main methods:
printprint_lineread_lineerrornew_lineflushread_integerread_realProcessConstruction:
create Process
Main methods:
getenvsetenvcommand_lineTask[T]Construction:
let t: Task[Integer] := spawn do
result := 42
end
Main methods:
awaitawait(ms)cancelis_doneis_cancelledChannel[T]Construction:
create Channel[Integer]
create Channel[Integer].with_capacity(2)
Main methods:
sendsend(value, ms)try_sendreceivereceive(ms)try_receivecloseis_closedcapacitysizeComparable and Hashable.length; map and set element counts use size.Task and Channel are built-in concurrency abstractions available directly in Nex programs.For the fuller per-type reference, see the Nex Reference.