Return a newly created array of the specified size.
array(number) : array|null
Return a newly created structure.
struct() : struct
Return a newly created set.
set() : set
Insert an object to a set.
insert(set, object) : null
Remove an object from a set.
remove(set, object) : null
Check if a set contains an object.
contains(set, object) : bool|null
Return number of items in an array, struct or set. Return number of characters in a string.
size(array|struct|set|string) : int|null
Create union of two sets.
union(set, set) : set|null
Create intersection of two sets.
intersection(set, set) : set|null
Create difference of two sets.
difference(set, set) : set|null
Push an item to the front of an array.
pushFront(array, object) : null
Push an item to the back of an array.
pushBack(array, object) : null
Remove an item from the front of an array.
popFront(array) : null
Remove an item from the back of an array.
popBack(array) : null
Get the front item of an array.
front(array) : object|null
Get the back item of an array.
back(array) : object|null
Set property with name string and value object to all struct-like items (struct, vertex, edge) saved in the array, struct or set.
setPropertyToAllStructItems(array|struct|set, string, object) : null
Stack implementation using array data type.
function main(argv)
{
stack = array(0);
stack.pushBack(0);
stack.pushBack(1);
stack.pushBack(2);
println(stack.back()); stack.popBack();
println(stack.back()); stack.popBack();
println(stack.back()); stack.popBack();
println(stack.back()); stack.popBack();
}
2 1 0 NULL
Queue implementation using array data type.
function main(argv)
{
queue = array(0);
queue.pushBack(0);
queue.pushBack(1);
queue.pushBack(2);
println(queue.front()); queue.popFront();
println(queue.front()); queue.popFront();
println(queue.front()); queue.popFront();
println(queue.front()); queue.popFront();
}
0 1 2 NULL
Linked list implementation using structs
function listCreate()
{
ret = struct();
ret.val = null;
ret.ptr = null;
return ret;
}
function listPushFront(list, item)
{
ret = struct();
ret.val = item;
ret.ptr = list;
return ret;
}
function listDisplay(list)
{
while(list.ptr != null)
{
echo("Item: " + list.val + "\n");
list = list.ptr;
}
}
function main(argv)
{
list = listCreate();
list = list.listPushFront(1);
list = list.listPushFront(2);
list = list.listPushFront(3.14);
list = list.listPushFront("Hello, world!");
a = array(3);
a[0] = 2.8;
a[2] = "bagr";
list = list.listPushFront(a);
list.listDisplay();
}
Item: #Array Item: Hello, world! Item: 3.14 Item: 2 Item: 1
2D matrix implementation using arrays
function createMatrix(size)
{
num = 0;
matrix = array(size);
foreach(row; matrix)
{
row = array(size);
foreach(item; row)
item = num++;
}
return matrix;
}
function displayMatrix(matrix)
{
foreach(row; matrix)
{
foreach(item; row)
{
echo(item);
echo(" ");
}
echo("\n");
}
}
function main(argv)
{
breakpoint(true);
matrix = createMatrix(3);
matrix.displayMatrix();
}
0 1 2 3 4 5 6 7 8