View on GitHub

Riddim

Interpreted language made in C++ designed for algorithms / data structures

Summary

builtins

Auto imported module. Contains built-in variables.

builtins.Deque

Deque

Double ended queue data type. A queue supporting front / back operations

Deque.add

Pushes back an item

Deque.add(item)

Deque.add_front

Pushes front an item

Deque.add_front(item)

Returns the index of item in a sorted collection using the binary search algorithm. Returns -1 if not found.

Deque.bin_search(item)

Deque.empty

Returns whether it is empty

Deque.empty()

Deque.filter

Returns a collection with all values that matches the predicate f

Deque.filter(f, [init])

Deque.for_each

Applies f to every item of the collection

Deque.for_each(f)

Deque.index

Returns the index of the first occurence of item. Returns -1 if not found.

Deque.index(item)

Deque.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

Deque.last_index(item)

Deque.map

Returns a collection with all values mapped by f

Deque.map(f, [init])

Deque.not_empty

Returns whether it is not empty

Deque.not_empty()

Deque.pop

Removes an item at a target index (by default, the last item is popped out)

Deque.pop([index])

Deque.pop_front

Removes the first item and returns it. It is an alias for pop(0)

Deque.pop_front()

Deque.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

Deque.reduce(f, [init])

Deque.sort

Sorts the collection inplace

Deque.sort([cmp])

Deque.sum

Returns the sum of all items. Returns empty_result if the collection is empty

Deque.sum([empty_result])

builtins.File

File

A file stream. Can be material or virtual

File.close

Closes the file

File.close()

File.read

Reads the content of the file

File.read()

File.read_char

Reads the next character (or byte) of the file

File.read_char()

File.read_line

Reads the next line of the file

File.read_line()

File.stderr

Standard error output stream

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

stdin

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

write

Writes the textual / binary content to the file

File.write()

stdout

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

stdin

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

write

Writes the textual / binary content to the file

File.write()

write

Writes the textual / binary content to the file

File.write()

write

Writes the textual / binary content to the file

File.write()

File.stdin

Standard input stream

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

write

Writes the textual / binary content to the file

File.write()

File.stdout

Standard output stream

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

stdin

close

Closes the file

File.close()

read

Reads the content of the file

File.read()

read_char

Reads the next character (or byte) of the file

File.read_char()

read_line

Reads the next line of the file

File.read_line()

write

Writes the textual / binary content to the file

File.write()

write

Writes the textual / binary content to the file

File.write()

File.write

Writes the textual / binary content to the file

File.write(s)

builtins.HashMap

HashMap

HashMap data type. Creates a mapping between key / value pairs. This is the object created with the {k: v} syntax.

HashMap.empty

Returns whether it is empty

HashMap.empty()

HashMap.filter

Returns a collection with all values that matches the predicate f

HashMap.filter(f, [init])

HashMap.for_each

Applies f to every item of the collection

HashMap.for_each(f)

HashMap.index

Returns the index of the first occurence of item. Returns -1 if not found.

HashMap.index(item)

HashMap.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

HashMap.last_index(item)

HashMap.map

Returns a collection with all values mapped by f

HashMap.map(f, [init])

HashMap.not_empty

Returns whether it is not empty

HashMap.not_empty()

HashMap.pop

Removes a mapping by key

HashMap.pop(key)

HashMap.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

HashMap.reduce(f, [init])

HashMap.sum

Returns the sum of all items. Returns empty_result if the collection is empty

HashMap.sum([empty_result])

builtins.HashSet

HashSet

HashSet data type. Set with O(1) time to insert an item (best case).

HashSet.add

Inserts an item

HashSet.add(item)

HashSet.empty

Returns whether it is empty

HashSet.empty()

HashSet.filter

Returns a collection with all values that matches the predicate f

HashSet.filter(f, [init])

HashSet.for_each

Applies f to every item of the collection

HashSet.for_each(f)

HashSet.index

Returns the index of the first occurence of item. Returns -1 if not found.

HashSet.index(item)

HashSet.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

HashSet.last_index(item)

HashSet.map

Returns a collection with all values mapped by f

HashSet.map(f, [init])

HashSet.not_empty

Returns whether it is not empty

HashSet.not_empty()

HashSet.pop

Removes an item

HashSet.pop(item)

HashSet.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

HashSet.reduce(f, [init])

HashSet.sum

Returns the sum of all items. Returns empty_result if the collection is empty

HashSet.sum([empty_result])

builtins.SegTree

SegTree

Segment Tree, used to compute range queries in O(log N) time

Returns the index of item in a sorted collection using the binary search algorithm. Returns -1 if not found.

SegTree.bin_search(item)

SegTree.empty

Returns whether it is empty

SegTree.empty()

SegTree.filter

Returns a collection with all values that matches the predicate f

SegTree.filter(f, [init])

SegTree.for_each

Applies f to every item of the collection

SegTree.for_each(f)

SegTree.index

Returns the index of the first occurence of item. Returns -1 if not found.

SegTree.index(item)

SegTree.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

SegTree.last_index(item)

SegTree.map

Returns a collection with all values mapped by f

SegTree.map(f, [init])

SegTree.not_empty

Returns whether it is not empty

SegTree.not_empty()

SegTree.query

Queries the segment tree from start (included) to end (excluded)

SegTree.query(start, end, [init_val : 0])

SegTree.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

SegTree.reduce(f, [init])

SegTree.sort

Sorts the collection inplace

SegTree.sort([cmp])

SegTree.sum

Returns the sum of all items. Returns empty_result if the collection is empty

SegTree.sum([empty_result])

builtins.Str

Str

String data type

Str.add

Appends the other string

Str.add(s)

Returns the index of item in a sorted collection using the binary search algorithm. Returns -1 if not found.

Str.bin_search(item)

Str.chr

Returns the character associated to the code

Str.chr(code)

Str.empty

Returns whether it is empty

Str.empty()

Str.erase

Removes all occurences of target

Str.erase(target)

Str.filter

Returns a collection with all values that matches the predicate f

Str.filter(f, [init])

Str.for_each

Applies f to every item of the collection

Str.for_each(f)

Str.index

Returns the index of the first occurence of item. Returns -1 if not found.

Str.index(item)

Str.join

Concatenates every item of the iterable into a string, the current string separates every item.

Str.join(iterable)

Str.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

Str.last_index(item)

Str.lower

Transforms the string in lower case characters (inplace)

Str.lower()

Str.map

Returns a collection with all values mapped by f

Str.map(f, [init])

Str.not_empty

Returns whether it is not empty

Str.not_empty()

Str.ord

Returns the code associated to the character

Str.ord(char)

Str.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

Str.reduce(f, [init])

Str.replace

Replaces all occurences of old by new

Str.replace(old, new)

Str.sort

Sorts the collection inplace

Str.sort([cmp])

Str.split

Splits the string into substrings delimited by delim.

Str.split([delim])

Str.sum

Returns the sum of all items. Returns empty_result if the collection is empty

Str.sum([empty_result])

Str.upper

Transforms the string in upper case characters (inplace)

Str.upper()

builtins.TreeMap

TreeMap

TreeMap data type. Creates a mapping between key / value pairs. Keys must be comparable since they are ordered (a BST is used).

TreeMap.empty

Returns whether it is empty

TreeMap.empty()

TreeMap.filter

Returns a collection with all values that matches the predicate f

TreeMap.filter(f, [init])

TreeMap.for_each

Applies f to every item of the collection

TreeMap.for_each(f)

TreeMap.index

Returns the index of the first occurence of item. Returns -1 if not found.

TreeMap.index(item)

TreeMap.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

TreeMap.last_index(item)

TreeMap.map

Returns a collection with all values mapped by f

TreeMap.map(f, [init])

TreeMap.not_empty

Returns whether it is not empty

TreeMap.not_empty()

TreeMap.pop

Removes a mapping by key

TreeMap.pop(key)

TreeMap.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

TreeMap.reduce(f, [init])

TreeMap.sum

Returns the sum of all items. Returns empty_result if the collection is empty

TreeMap.sum([empty_result])

builtins.TreeSet

TreeSet

TreeSet data type. Set with O(log N) insert time, all values are ordered (and must be comparable).

TreeSet.add

Inserts an item

TreeSet.add(item)

TreeSet.empty

Returns whether it is empty

TreeSet.empty()

TreeSet.filter

Returns a collection with all values that matches the predicate f

TreeSet.filter(f, [init])

TreeSet.for_each

Applies f to every item of the collection

TreeSet.for_each(f)

TreeSet.index

Returns the index of the first occurence of item. Returns -1 if not found.

TreeSet.index(item)

TreeSet.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

TreeSet.last_index(item)

TreeSet.map

Returns a collection with all values mapped by f

TreeSet.map(f, [init])

TreeSet.not_empty

Returns whether it is not empty

TreeSet.not_empty()

TreeSet.pop

Removes an item

TreeSet.pop(item)

TreeSet.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

TreeSet.reduce(f, [init])

TreeSet.sum

Returns the sum of all items. Returns empty_result if the collection is empty

TreeSet.sum([empty_result])

builtins.Vec

Vec

Vector data type. Holds items in a contiguous memory space. This is the object created with the [a, …] syntax.

Vec.add

Pushes back an item

Vec.add(item)

Returns the index of item in a sorted collection using the binary search algorithm. Returns -1 if not found.

Vec.bin_search(item)

Vec.empty

Returns whether it is empty

Vec.empty()

Vec.filter

Returns a collection with all values that matches the predicate f

Vec.filter(f, [init])

Vec.for_each

Applies f to every item of the collection

Vec.for_each(f)

Vec.index

Returns the index of the first occurence of item. Returns -1 if not found.

Vec.index(item)

Vec.last_index

Returns the index of the last occurence of item. Returns -1 if not found.

Vec.last_index(item)

Vec.map

Returns a collection with all values mapped by f

Vec.map(f, [init])

Vec.not_empty

Returns whether it is not empty

Vec.not_empty()

Vec.pop

Removes an item at a target index (by default, the last item is popped out)

Vec.pop([index])

Vec.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

Vec.reduce(f, [init])

Vec.sort

Sorts the collection inplace

Vec.sort([cmp])

Vec.sum

Returns the sum of all items. Returns empty_result if the collection is empty

Vec.sum([empty_result])

builtins.abs

Returns the absolute value of x

abs(x)

builtins.argmax

Returns the index pointing at the maximum of col

argmax(col)

builtins.argmin

Returns the index pointing at the minimum of col

argmin(col)

builtins.argminmax

Returns the index pointing at the minimum and the maximum of col

argminmax(col)

builtins.assert

Throws AssertionError if exp is false

assert(exp, [msg])

builtins.autodoc

Generates the auto documentation for multiple modules in a specified directory

autodoc(dirpath, modules, title, [description], [verbose], [notes], [lowercase_filenames])

builtins.autodoc_std

Generates the Riddim documentation

autodoc_std(dirpath)

builtins.copy

Shallow copies of obj

copy(obj)

Returns the index of item in a sorted collection using the binary search algorithm. Returns -1 if not found.

default_collection_bin_search(item)

builtins.default_collection_empty

Returns whether it is empty

default_collection_empty()

builtins.default_collection_filter

Returns a collection with all values that matches the predicate f

default_collection_filter(f, [init])

builtins.default_collection_for_each

Applies f to every item of the collection

default_collection_for_each(f)

builtins.default_collection_index

Returns the index of the first occurence of item. Returns -1 if not found.

default_collection_index(item)

builtins.default_collection_last_index

Returns the index of the last occurence of item. Returns -1 if not found.

default_collection_last_index(item)

builtins.default_collection_map

Returns a collection with all values mapped by f

default_collection_map(f, [init])

builtins.default_collection_not_empty

Returns whether it is not empty

default_collection_not_empty()

builtins.default_collection_reduce

Returns the cumulative application of f to all elements starting by (init, first element)

default_collection_reduce(f, [init])

builtins.default_collection_sort

Sorts the collection inplace

default_collection_sort([cmp])

builtins.default_collection_sum

Returns the sum of all items. Returns empty_result if the collection is empty

default_collection_sum([empty_result])

builtins.doc

Returns the documentation of obj

doc(obj)

builtins.exit

Exits the program

exit([code])

builtins.fatal

Prints msg to stderr and exits with exit_code

fatal(msg, [exit_code])

builtins.filter

Returns a collection with all values that matches the predicate f

filter(col, f, [init])

builtins.for_each

Applies f to every item of the collection

for_each(col, f)

builtins.hash

Returns the hash value of obj

hash(obj)

builtins.input

Reads the next line of stdin. Throws a RuntimeError if end of file found

input()

builtins.iter

Returns the iterator of iterable (begin position)

iter(iterable)

builtins.len

Returns the length of col

len(col)

builtins.map

Returns a collection with all values mapped by f

map(col, f, [init])

builtins.max

Returns the maximum value within col

max(col)

builtins.min

Returns the minimum value within col

min(col)

builtins.minmax

Returns the minimum and the maximum values within col

minmax(col)

builtins.next

Returns the next element of iterator (or enditer)

next(iterator)

builtins.print

Prints to stdout all arguments

print([args…])

builtins.reduce

Returns the cumulative application of f to all elements starting by (init, first element)

reduce(col, f, [init])

builtins.scan

Scans the string content

scan(content, [args…])

builtins.set_default_collection

Sets up the collection type with default collection methods and attribute variables.

set_default_collection(type, [is_random_access])

builtins.sort

Sorts the collection inplace

sort(col)

builtins.sum

Returns the sum of all items. Returns empty_result if the collection is empty

sum(col, [empty_result])

builtins.throw

Throws error

throw(error)

builtins.typename

Returns the name of type

typename(type)

builtins.typeof

Returns the type of obj

typeof(obj, [cmp])

builtins.version

add

Appends the other string

Str.add()

chr

Returns the character associated to the code

Str.chr()

index

Str.index()

lower

Transforms the string in lower case characters (inplace)

Str.lower()

ord

Returns the code associated to the character

Str.ord()

upper

Transforms the string in upper case characters (inplace)

Str.upper()