19
edits
Changes
→Library Utilities
t.clear();
'''List Module'''
'''List:''' the list type can be imported using the following statement:
private use List;
config const quiet: bool = false;
var new_list: list(int) = 1..5;
writeln(new_list);
Output: [1, 2, 3, 4, 5]
for i in 6..10 do {
new_list.append(i);
}
writeln(new_list);
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
/* parSafe needs to be set to true if the list is going to be used in parallel */
var new_list2: list(int, parSafe=true);
forall i in 0..5 with (ref new_list2) {
new_list2.append(i);
}
writeln(new_list2);
Output: [0, 1, 2, 3, 4, 5]
'''sort():''' used to sort the list in ascending order.
'''pop(index):''' used to pop the element at the specified index.
'''clear():''' used to clear all elements from the list.
'''indexOf(value):''' used to retrieve the index of the value specified, returns -1 if not found.
'''insert(index, value):''' used to insert the value at the specified index.
=== Numerical Libraries ===