-
Notifications
You must be signed in to change notification settings - Fork 0
15. Built‐in Methods
Below is a list of all methods for built-in DSSL types. The expected arguments are written in italics, and the element for which the method is being called is denoted x.
All types:
-
x .clone: Pushes a deep copy of the element. -
x .hash: Pushes an integer equal to the hash code of the element.
Iterable types:
-
x .iter: Pushes an iterator over the element.
String:
-
x .unpack: Pushes all characters in the string to the stack. -
x .size: Pushes an integer equal to the length of the string. -
x .isEmpty: Pushes a true boolean if the string is empty, and a false boolean otherwise. -
(
elem)x .contains: Pushes a true boolean if the string contains the element as a character or substring, and a false boolean otherwise. -
(
iterable)x .containsAll: Pushes a true boolean if the string contains all elements of the iterable argument as characters or substrings, and a false boolean otherwise. -
(
int)x .get: Pushes the character with the integer as its index. -
x .fst: Pushes the first character in the string. -
x .snd: Pushes the second character in the string. -
x .last: Pushes the last character in the string. -
(
elem)x .indexOf: Pushes the start index of the first occurrence of the element as a character or substring if it exists, and null otherwise. -
(
elem)x .lastIndexOf: Pushes the start index of the last occurrence of the element as a character or substring if it exists, and null otherwise. -
(
int1 int2)x .slice: Pushes the substring between the indices given by the first integer (inclusive) and the second integer (exclusive). -
(
elem)x .startsWith: Pushes a true boolean if the string starts with the element as a character or substring, and a false boolean otherwise. -
(
elem)x .endsWith: Pushes a true boolean if the string ends with the element as a character or substring, and a false boolean otherwise. -
(
regex)x .matches: Pushes a true boolean if the string matches the regular expression argument, and a false boolean otherwise. -
(
regex string)x .replace: Pushes a string with all substrings matching the regular expression argument replaced with the second argument. -
(
regex)x .split: Pushes a list of substrings split at matches the regular expression argument. -
x .lower: Pushes a string with all characters converted to lowercase. -
x .upper: Pushes a string with all characters converted to uppercase. -
x .trim: Pushes a string with all surrounding whitespace removed. -
(
iterable)x .format: Pushes a formatted string using the iterable element as arguments.
Range:
-
x .unpack: Pushes all integers in the range to the stack. -
x .size: Pushes an integer equal to the number of integers in the range. -
x .isEmpty: Pushes a true boolean if the range contains no integers, and a false boolean otherwise. -
(
int)x .contains: Pushes a true boolean if the range contains the integer, and a false boolean otherwise. -
(
iterable)x .containsAll: Pushes a true boolean if the range contains all elements of the iterable argument as integers, and a false boolean otherwise. -
(
int)x .get: Pushes the range integer with the argument integer as its index. -
x .fst: Pushes the first integer in the range. -
x .snd: Pushes the second integer in the range. -
x .last: Pushes the last integer in the range. -
(
int)x .indexOf: Pushes the index of the first occurrence of the integer if it exists, and null otherwise. -
(
int1 int2)x .slice: Pushes the subrange between the indices given by the first integer (inclusive) and the second integer (exclusive).
List:
-
x .unpack: Pushes all elements in the list to the stack. -
x .size: Pushes an integer equal to the size of the list. -
x .isEmpty: Pushes a true boolean if the list is empty, and a false boolean otherwise. -
x .clear: Removes all elements from the list. -
(
elem)x .contains: Pushes a true boolean if the list contains the element, and a false boolean otherwise. -
(
iterable)x .containsAll: Pushes a true boolean if the list contains all elements of the iterable argument, and a false boolean otherwise. -
(
int)x .get: Pushes the element with the integer as its index. -
(
int elem)x .set: Sets the value at the index of the list given by the integer to the element. -
x .fst: Pushes the first element in the list. -
x .snd: Pushes the second element in the list. -
x .last: Pushes the last element in the list. -
(
elem)x .indexOf: Pushes the index of the first occurrence of the element if it exists, and null otherwise. -
(
elem)x .lastIndexOf: Pushes the index of the last occurrence of the element if it exists, and null otherwise. -
(
int1 int2)x .slice: Pushes the sublist between the indices given by the first integer (inclusive) and the second integer (exclusive). -
(
elem)x .push: Adds the element to the end of the list. -
(
iterable)x .pushAll: Adds all elements of the iterable argument to the end of the list. -
(
int elem)x .insert: Adds the element into the list at the index given by the integer. -
(
int iterable)x .insertAll: Adds all elements of the iterable argument into the list at the index given by the integer. -
(
int)x .remove: Removes the element at the index given by the integer. -
(
iterable)x .removeAll: Removes the elements at the indices given by the iterable argument. -
x .pop: Removes the last element in the list and pushes it to the stack. -
(
elem)x .removeValue: Removes the first occurrence of the element if present. -
x .reverse: Reverses the order of the elements in the list. -
x .sort: Stably sorts the list using the==and<binary operators defined for the elements. -
(
block)x .sortBy: Stably sorts the list using the comparison function defined by the block. -
x .shuffle: Randomly permutes the elements of the list.
Set:
-
x .unpack: Pushes all elements in the set to the stack. -
x .size: Pushes an integer equal to the size of the set. -
x .isEmpty: Pushes a true boolean if the set is empty, and a false boolean otherwise. -
x .clear: Removes all elements from the set. -
(
elem)x .contains: Pushes a true boolean if the set contains the element, and a false boolean otherwise. -
(
iterable)x .containsAll: Pushes a true boolean if the set contains all elements of the iterable argument, and a false boolean otherwise. -
(
elem)x .add: Adds the element to the set. -
(
iterable)x .addAll: Adds all elements of the iterable argument to the set. -
(
elem)x .remove: Removes the element if present. -
(
iterable)x .removeAll: Removes all elements of the iterable argument which are present.
Dict:
-
x .unpack: Pushes all key-value pairs in the dictionary to the stack. -
x .size: Pushes an integer equal to the number of key-value pairs in the dictionary. -
x .isEmpty: Pushes a true boolean if the dictionary is empty, and a false boolean otherwise. -
x .clear: Removes all key-value pairs from the dictionary. -
(
elem)x .get: Pushes the value with the element as its key, or null if there is no such value. -
(
elem1 elem2)x .put: Puts the first and second elements into the dictionary as a key-value pair. -
(
dict)x .putAll: Puts all key-value pairs of the argument dictionary into this dictionary. -
(
elem)x .remove: Removes the key-value pair with the element as its key if present. -
(
iterable)x .removeAll: Removes all key-value pairs with elements in the iterable argument as their keys which are present. -
(
elem1 elem2)x .removeEntry: Removes the key-value pair specified by the first and second elements if present. -
(
elem)x .containsKey: Pushes a true boolean if the dictionary contains the element as a key, and a false boolean otherwise. -
(
elem)x .containsValue: Pushes a true boolean if the dictionary contains the element as a value, and a false boolean otherwise. -
(
elem1 elem2)x .containsEntry: Pushes a true boolean if the dictionary contains the first and second elements as a key-value pair, and a false boolean otherwise. -
x .keys: Pushes all keys as a set. -
x .values: Pushes all values as a list. -
x .entries: Pushes all key-value pairs as a set.
Iter:
-
x .collectString: Pushes a string built from the characters in the iterator. -
x .collectList: Pushes a list built from the elements in the iterator. -
x .collectSet: Pushes a set built from the elements in the iterator. -
x .collectDict: Pushes a dictionary built from the key-value pairs in the iterator. -
(
int)x .stepBy: Pushes an iterator which steps by the given integer after each iteration. -
(
iter)x .chain: Pushes an iterator over the elements of this iterator followed by the argument iterator. -
(
iter)x .zip: Pushes an iterator over pairs of elements from this iterator and the argument iterator. -
(
block)x .map: Pushes an iterator which maps the iterated elements using the function defined by the block. -
(
block)x .filter: Pushes an iterator which filters the iterated elements using the predicate defined by the block. -
(
block)x .filterMap: Pushes an iterator which maps the iterated elements using the function defined by the block and filters the non-null elements. -
x .enumerate: Pushes an iterator over index-element pairs from this iterator. -
(
block)x .takeWhile: Pushes an iterator over the elements of this iterator while they satisfy the predicate defined by the block. -
(
block)x .mapWhile: Pushes an iterator over the elements of this iterator while they are mapped to non-null elements using the function defined by the block. -
(
int)x .skip: Pushes an iterator which initially skips at least the number of elements of this iterator given by the integer. -
(
int)x .take: Pushes an iterator which only takes at most the number of elements of this iterator given by the integer. -
x .flatten: Pushes an iterator which iterates over each of the iterators of the elements of this iterator. -
(
block)x .flatMap: Pushes an iterator which iterates over each of the iterators produced by the mapping of the elements of this iterator using the function defined by the block. -
(
int)x .chunks: Pushes an iterator which iterates over the elements of this iterator collected into lists of a size given by the integer. -
x .count: Pushes an integer equal to the number of elements of this iterator. -
(
block)x .forEach: Executes the block for each element of this iterator, pushing it to the stack before each iteration. -
x .all: Pushes a true boolean if all of the elements of this iterator are true, and a false boolean otherwise. -
x .any: Pushes a true boolean if any of the elements of this iterator are true, and a false boolean otherwise. -
x .min: Pushes the minimum value of the elements of this iterator. -
x .max: Pushes the maximum value of the elements of this iterator.
Class:
-
x .scope: Pushes the hierarchy to the stack as a dictionary, with identifier strings as keys and labels as values. -
x .supers: Pushes a list of all superclasses, ordered by their priority.