module base.base64
Implement base64 encoding scheme
pub fn base64_encode(data: Bytes) -> str
pub fn base64_decode(text: str) -> Bytes
module base.bitset
Bit set data type.
pub fn new_bitset(n: int64) -> BitSet
Create a bit set with n bits.
pub class BitSet
Compactly store an vector of booleans
pub fn unset(bit?: int64)
pub fn remove(bit?: int64)
pub fn isset(bit?: int64) -> bool
pub fn contains(bit?: int64) -> bool
pub fn or_assign(other?: BitSet)
pub fn and_assign(other?: BitSet)
pub fn andnot_assign(other?: BitSet)
pub fn equals(other?: BitSet) -> bool
pub fn is_empty() -> bool
fn bit_mask(bit: int64) -> int64
fn bit_slot(bit: int64) -> int64
pub class SmallBitSet
A bitset with a single integer with bits.
pub fn unset(bit?: int64)
pub fn remove(bit?: int64)
pub fn is_empty() -> bool
module base.bytes
Data types for bytes
pub class Bytes
Immutable bytes
pub fn get(index: int64) -> int64
pub fn get_byte(index: int64) -> uint8
pub fn set_byte(index: int64, value: uint8)
pub fn as_hex() -> str
Return bytes as hexadecimal text
pub fn as_array() -> [uint8]
pub class ByteReader
pub fn read_bytes(size: int64) -> Bytes
pub fn peek_byte(ahead: int64) -> int64
pub fn read_byte() -> int64
pub fn read_u16_be() -> int64
pub fn read_u16_le() -> int64
pub fn read_u32_be() -> int64
pub fn read_u32_le() -> int64
pub fn read_u64_be() -> int64
pub fn read_u64_le() -> int64
pub class ByteArray
Mutable bytes
pub fn append(byte?: int64)
pub fn as_array() -> [uint8]
pub fn get(index: int64) -> int64
pub fn set(index: int64, value: int64)
pub fn extend(bytes?: Bytes)
pub fn pack_f64_le(value?: float64)
pub fn pack_f64_be(value?: float64)
pub fn pack_f32_le(value?: float32)
pub fn pack_f32_be(value?: float32)
pub fn pack_u64_le(value?: int64)
pub fn pack_u64_be(value?: int64)
pub fn pack_u32_le(value?: int64)
pub fn pack_u32_be(value?: int64)
pub fn pack_u16_le(value?: int64)
pub fn pack_u16_be(value?: int64)
pub fn is_empty() -> bool
pub fn to_bytes() -> Bytes
pub fn byte_as_hex(byte?: uint8) -> str
pub fn bytes_from_hex_text(text: str) -> Bytes
pub fn new_bytes() -> Bytes
fn new_bytes_with_size(size: int64) -> Bytes
Bytes object with the given size. Uninitialized memory.
pub fn fill_bytes(n: int64, fill: int64) -> Bytes
pub fn bytes_from_ascii(text: str) -> Bytes
pub fn bytes_to_ascii(data: Bytes) -> str
pub fn get_byte_from_array(buffer: [uint8], index: int64) -> int64
pub fn set_byte_into_array(buffer: [uint8], index: int64, value: int64)
module base.cbor
CBOR (Concise Binary Object Representation)
See also: https://cbor.io/
pub class CborWriter
pub fn write_int(value?: int64)
pub fn write_bool(value?: bool)
pub fn write_bytes(data?: Bytes)
pub fn write_string(text?: str)
pub fn start_array(size: int64)
pub fn start_map(size: int64)
pub fn write_float(value?: float64)
fn emit_varsized(major: int64, info: int64)
fn write_header(major: int64, info: int64)
fn emit_u32(value?: int64)
fn emit_u16(value?: int64)
fn emit_u8(value?: int64)
fn emit_bytes(data?: Bytes)
fn emit_byte(value?: int64)
module base.crypto
pub fn leftrotate(value: uint32, amount: int64) -> uint32
pub fn right_rotate(value: uint32, amount: int64) -> uint32
pub fn right_shift(value: uint32, amount: int64) -> uint32
pub fn compute_md5_K(K: [int64])
pub fn fill_md5_K(K: [int64])
Pre computed table of
floor(2^32 * abs(sin(i + 1)))
fn sha_pre_process(data: Bytes) -> Bytes
Append a 1 bit, and align to 512 bits.
pub fn sha256(data: Bytes) -> Bytes
SHA256 hash.
See also: https://en.wikipedia.org/wiki/SHA-2
module base.datetime
Date time function
pub fn unix_to_str(seconds: int64) -> str
pub fn unix_to_datetime(z: int64) -> DateTime
pub fn datetime_to_unix(dt: DateTime) -> int64
fn two_digits(n?: int64) -> str
pub fn datetime_to_str(d: DateTime) -> str
pub struct DateTime
year: int64month: int64day: int64hour: int64minute: int64second: int64
struct Civil
year: int64month: int64day: int64
fn days_from_civil(ymd: Civil) -> int64
fn civil_from_days(z: int64) -> Civil
module base.deflate
Implement RFC 1951: deflate format.
DEFLATE uses huffman trees and LZ77 compression.
pub fn deflate_decompress(data?: Bytes) -> Bytes
Decompress the given data using deflate
See: RFC 1951
pub fn deflate_compress(data: Bytes) -> Bytes
Compress data in DEFLATE format
enum Action
Literal(int64)Copy(int64, int64)
fn find_index(base: [int64], bits: [int64], size: int64, value: int64) -> int64
fn get_widths(frequencies: [int64], size: int64) -> Vector[int64]
Given a set of frequencies, determine the width in bits of each symbol.
fn assign_bit_width(widths: Vector[int64], node: TreeNode, level: int64)
enum RunLengthOpcode
Literal(int64)Repeat(int64)FewZeroes(int64)ManyZeroes(int64)
class DeflateCompressor
pub fn compress() -> Bytes
fn write_block_header(last_block: int64, btype: int64)
fn write_uncompressed_block(size: int64, last_block: int64)
fn write_bits(n: int64, value: int64)
pub class DeflateDecoder
pub fn deflate() -> Bytes
fn read_bits(n?: int64) -> int64
fn read_u16_le() -> int64
fn create_fixed_literal_lengths() -> Vector[int64]
fn create_fixed_distance_lengths() -> Vector[int64]
module base.deque
pub fn new_queue[T]() -> Queue[T]
pub fn new_queue_with_capacity[T](capacity: int64) -> Queue[T]
pub class Queue[T]
Implement a FIFO queue data type
pub fn push(value?: T)
Append a value to the queue
pub fn pop() -> T
Pop first value from the queue
pub fn is_empty() -> bool
fn inc(value?: int64) -> int64
module base.diff
Implement diff using Myers linear space algorithm
left variables: a, n, x, left, right
right variables: b, m, y, top, bottom
Use the relation k = x - y
Implemented while reading this blog:
https://blog.jcoglan.com/2017/04/25/myers-diff-in-linear-space-implementation/
pub fn ratio(a: str, b: str) -> float64
Calculate similarity ratio between two strings.
This has remotely to do with Levenshtein distance.
Returns a value between 0 and 1 indicating similarity
pub fn count_diff_changes[T](edits: List[Edit]) -> int64
Count number of changes
pub fn render_diff(edits: List[Edit], show_unchanged_lines: bool)
Print diff to console
fn old_range_to_str(pos: int64, size: int64) -> str
struct UnifiedBlock
Single block of unified diff output
pos1: int64size1: int64pos2: int64size2: int64lines: List[str]has_deltas: bool
fn new_unified_block(pos1: int64, pos2: int64) -> UnifiedBlock
pub fn show_unified(edits: List[Edit], context: int64)
Create unified output, with a given amount of context
fn pos_size_to_str(pos: int64, size: int64) -> str
pub fn diff_strings(a: str, b: str) -> List[Edit]
Compare two strings
fn str_to_char_vector(s?: str) -> Vector[char]
struct Context[T]
Diff problem context
struct Point
x: int64y: int64
class Area
pub fn to_string() -> str
fn diff_linear_space[T](ctx: Context, area: Area, edits: List[Edit])
Recursively divide and conquer the graph in subgraphs
fn find_middle_snake[T](ctx: Context, area: Area) -> Point
Simultaniously search paths from start and from end.
fn is_odd(x?: int64) -> bool
Test if the given number is odd
fn is_even(x?: int64) -> bool
Test if the given number is even
fn merge_two_edits[T](first: Edit, second: Edit) -> Option
Try to merge two edits into a single edit
module base.fs
Functionality to operate on files and folders.
TODO: merge with pathlib?
pub fn path_compare(a: Path, b: Path) -> bool
pub fn new_path(filename: str) -> Path
pub class Path
pub fn open(mode: str) -> int64
pub fn read_text() -> str
pub fn read_lines() -> Vector[str]
pub fn write_lines(lines?: Vector[str])
Write text lines to this path
pub fn to_string() -> str
pub fn with_suffix(suffix: str) -> Path
Create a new path with the new suffix
pub fn get_extension() -> str
pub fn read_bytes() -> Bytes
pub fn write_bytes(data: Bytes)
pub fn read_whole_file_as_bytes(path: Path) -> Bytes
pub fn write_bytes_to_file(path: Path, data: Bytes)
module base.functools
fn add_int(left: int64, right: int64) -> int64
pub fn sum_integers(values: List[int64]) -> int64
pub fn reduce[T](values: List[T], f: fn (T, T) -> T) -> T
pub fn map[T,V](values: List[T], function: fn (T) -> V) -> List[V]
pub fn filter[T](values: List[T], criterium: fn (T) -> bool) -> List[T]
pub fn all[T](values: List[T], check: fn (T) -> bool) -> bool
module base.graphlib
A graph consists of nodes and edges between them.
There are directed and undirected graph types.
pub class DiGraph
A directed graph
pub fn add_edge(src: str, dst: str)
pub fn remove_edge(src: str, dst: str)
pub fn has_edge(src: str, dst: str) -> bool
pub fn successors(n?: str) -> Set[str]
pub fn has_preds(n?: str) -> bool
pub fn has_edges() -> bool
pub class Graph
Undirected graph
pub fn add_edge(src?: str, dst?: str)
pub fn has_edge(src?: str, dst?: str) -> bool
pub fn neighbours(n?: str) -> Set[str]
pub fn find_max_cliques(g: Graph) -> List[Set[str]]
Find maximum cliques with the Bron Kerbosch algorithm
fn bron_kerbosch(r: Set[str], p: Set[str], x: Set[str], g: Graph, output: List[Set[str]])
An algorithm for solving the clique problem:
https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm
pub fn find_all_cliques_of_size(g: Graph, k: int64) -> List[Set[str]]
fn bron_kerbosch_k(r: Set[str], p: Set[str], x: Set[str], g: Graph, k: int64, output: List[Set[str]])
A mutated Bron Kerbosch algorithm
pub fn dfs(g: DiGraph, start: str) -> List[str]
Depth first search
module base.gzip
See RFC-1952: GZIP file format.
fn read_zero_terminated_string(reader: ByteReader) -> str
pub fn calc_crc32(data: Bytes) -> int64
pub fn calc_adler32(data: Bytes) -> int64
module base.hashlib
pub fn elf_hash(text: str) -> uint32
pub fn djb2(text: str) -> uint32
module base.hashmap
Hash map data type.
Idea: have an array with buckets.
pub fn new_hashmap_int[V]() -> HashMap[int64,V]
Create a new hashmap with integer keys
pub fn new_hashmap_uint32[V]() -> HashMap[uint32,V]
Create a new hashmap with uin32 keys
pub fn new_hashmap_str[V]() -> HashMap[str,V]
Create a new hashmap with string keys
pub fn new_hashmap_char[V]() -> HashMap[char,V]
Create a new hashmap with char keys
pub fn new_hashmap[K,V](f_hash: fn (K) -> uint32, f_eq: fn (K, K) -> bool) -> HashMap[K,V]
pub fn str_hash(text?: str) -> uint32
pub fn str_eq(a?: str, b?: str) -> bool
pub fn int_eq(a: int64, b: int64) -> bool
pub fn int_hash(x: int64) -> uint32
pub fn uint32_eq(a: uint32, b: uint32) -> bool
pub fn uint32_hash(x: uint32) -> uint32
pub fn char_eq(a: char, b: char) -> bool
pub fn char_hash(x: char) -> uint32
pub class HashMap[K,V]
fn get_hash(key: K) -> uint32
fn get_index(hash: uint32) -> int64
pub fn contains(key: K) -> bool
pub fn get_or_else(key: K, default: V) -> V
pub fn insert(key: K, value: V)
pub fn pop(key: K) -> Option
remove an item from this dictionary
pub fn is_empty() -> bool
fn create_buckets(n: int64)
pub fn values() -> List[V]
module base.heapq
Binary heap implementation.
A binary heap is an implementation for a priority queue.
fn cmp_int_item(a?: int64, b?: int64) -> bool
pub fn new_priority_queue_with_capacity[T](capacity: int64, f: fn (T, T) -> bool) -> PriorityQueue[T]
pub class PriorityQueue[T]
fn sift_down(index?: int64)
fn sift_up(index?: int64)
pub fn is_empty() -> bool
fn get(index?: int64) -> T
fn compare(index1?: int64, index2?: int64) -> bool
fn swap(a?: int64, b?: int64)
module base.huffman
Procedures related to Huffman coding.
pub fn decode_symbol(tree: Tree, bit_reader: BitReader) -> int64
Decode a value with the given Huffman tree
pub struct CodeEntry
code: int64length: int64
pub class BitReader
pub fn read_bits(n?: int64) -> int64
pub class BitWriter
pub fn write_bits(n: int64, value: int64)
pub fn to_bytes() -> Bytes
pub struct Tree
counts: [int64]symbols: [int64]
pub fn zero_int_array(size: int64) -> [int64]
module base.integersetlib
Implementation of range-set
pub class IntegerSet
pub fn to_string() -> str
pub fn is_empty() -> bool
pub fn contains(value: int64) -> bool
pub fn new_empty_int_set() -> IntegerSet
Create an new empty integer set
pub fn new_int_set(begin: int64, end: int64) -> IntegerSet
Create a new integer set with a single range
fn is_true(b?: bool) -> bool
module base.json
JSON data serialization library
pub fn json_to_string(value?: JsonValue) -> str
pub class JsonBrowser
pub fn has_attribute(attr: str) -> bool
pub fn find_attribute(attr: str) -> Option
pub fn get_text_attribute(attr: str) -> str
pub fn get_integer_attribute(attr: str) -> int64
pub fn get_boolean_attribute(attr: str) -> bool
pub fn is_string() -> bool
pub fn get_text() -> str
Get text from current node
pub fn get_integer() -> int64
Get integer from current node
pub fn get_boolean() -> bool
Get boolean from current node
pub fn enter_attribute(attr: str)
pub class JsonBuilder
pub fn add_attribute(attr: str, value: JsonValue)
pub fn add_boolean_attribute(attr: str, value: bool)
pub fn add_text_attribute(attr: str, text: str)
pub fn add_text_as_element(text: str)
pub fn add_integer_attribute(attr: str, value: int64)
pub fn end_object_as_element()
pub fn end_object_as_attribute(attr: str)
pub fn end_array_as_attribute(attr: str)
enum JsonTokenKind
BracketLeftBracketRightBraceLeftBraceRightCommaColonInteger(int64)String(str)Id(str)EofUnexpectedEofError(char)
fn is_id(c: char) -> bool
module base.leb128
LEB128 encoding.
pub fn pack_unsigned_leb128(out: ByteArray, value: int64)
pub fn pack_signed_leb128(out: ByteArray, value: int64)
module base.listtype
List data type
pub fn list1[T](v1?: T) -> List[T]
pub fn list2[T](v1?: T, v2?: T) -> List[T]
pub fn list3[T](v1?: T, v2?: T, v3?: T) -> List[T]
pub fn list4[T](v1?: T, v2?: T, v3?: T, v4?: T) -> List[T]
pub fn list5[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T) -> List[T]
pub fn list6[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T, v6?: T) -> List[T]
pub fn list7[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T, v6?: T, v7?: T) -> List[T]
pub fn list8[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T, v6?: T, v7?: T, v8?: T) -> List[T]
pub fn list9[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T, v6?: T, v7?: T, v8?: T, v9?: T) -> List[T]
pub class List[T]
pub fn is_empty() -> bool
pub fn get(index: int64) -> T
pub fn set(index: int64, value: T)
pub fn delete_at(index: int64)
pub fn reversed() -> List[T]
pub fn take(n: int64) -> List[T]
Create a new list with the first n items
pub fn take_extend(other?: List[T])
pub fn extend2(other?: List[T])
module base.logging
Logger.
pub fn set_log_level(level: int64)
pub fn log_error(message?: str)
pub fn log_warning(message?: str)
pub fn log_info(message?: str)
pub fn log_debug(message?: str)
pub fn log_trace(message?: str)
fn log_it(level: str, message: str)
module base.math
pub fn min(a: int64, b: int64) -> int64
pub fn max(a?: int64, b?: int64) -> int64
pub fn fmin(a?: float64, b?: float64) -> float64
pub fn fmax(a?: float64, b?: float64) -> float64
pub fn abs(a?: int64) -> int64
pub fn fabs(a?: float64) -> float64
pub fn sqrt(x?: float64) -> float64
Take the square root
pub fn factorial(x?: int64) -> int64
pub fn sin(x?: float64) -> float64
pub fn cos(value?: float64) -> float64
fn sin_kernel(x?: float64) -> float64
Implement sin on range -pi/4 .. pi/4 by using a taylor series
x^3 x^5 x^7
sin(x) ~ x - --- + --- - --- + --- ....
3! 5! 7!
pub fn tan(value?: float64) -> float64
pub fn degrees(radians: float64) -> float64
Convert radians to degrees
pub fn radians(degrees: float64) -> float64
Convert degrees to radians
pub fn round_up_to_multiple(value: int64, multiple: int64) -> int64
Integer round to higher multiple
fn fmod(x?: float64, divisor: float64) -> float64
pub fn hypot(x?: float64, y: float64) -> float64
pub fn modulo(value: int64, divisor: int64) -> int64
pub fn powf(x?: float64, y?: float64) -> float64
Raise x to the power of y.
Implemented as:
x^y = e^(y*log(x))
This follow from: x^y = exp(log(x))^y = exp(y * log(x))
pub fn log10(x?: float64) -> float64
pub fn log2(x?: float64) -> float64
pub fn log(x?: float64) -> float64
Natural logarithm
See: https://en.wikipedia.org/wiki/Natural_logarithm
For implementation algorithm: https://ben.land/post/2021/02/24/power-without-math-lib/
Use the series:
2 ?
log(x) = Sum ----- * (---)^(2n+1)
2*n+1 ?
pub fn exp(x?: float64) -> float64
Use Taylor series:
x^1 x^2 x^3
e^x = 1 + --- + --- + --- + ...
1! 2! 3!
pub fn floor(value?: float64) -> int64
pub fn ceil(value?: float64) -> int64
module base.optiontype
pub fn option_unwrap[T](option?: Option) -> T
pub fn option_unwrap_or[T](option: Option, default: T) -> T
pub fn option_is_some[T](opt?: Option) -> bool
pub fn option_is_none[T](opt?: Option) -> bool
module base.pathlib
pub fn basename(path: str) -> str
retrieve 'bla' from 'for/bar/bla.txt'
pub fn split_path(path: str) -> List[str]
module base.profiling
Application profiling
enum Event
Enter(str)Leave
pub class Profiler
pub fn enter(name: str)
Enter a measured zone
pub fn add_event(event?: Event)
pub fn write_json(filename: Path)
Generate speedscope compatible json file
module base.random
pub fn new_rand() -> Rand
pub class Rand
32 bit PCG random number generator
Really minimal PCG32 code, ported to slang lang.
Original C code by (c) 2014 M.E. O'Neill / pcg-random.org
Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
pub fn seed(initstate: uint64, initseq: uint64)
pub fn next() -> uint32
Generate a random 32 bit number
range: 0 <= x < 2**32
pub fn next_float() -> float64
Generate a random float with 32 bits of randomness
range: 0 <= x < 1
Note that '1' is not included in the possible range.
pub fn next_int(min: int64, max: int64) -> int64
Generate a random interger
range:
min <= x < max
or
min <= x <= (max - 1)
Note that 'max' is not included in the possible range.
module base.rangelib
pub struct Range
begin: int64end: int64
pub fn ranges_overlap(self: Range, other: Range) -> bool
pub fn range_contains(self: Range, value: int64) -> bool
pub fn range_to_string(r?: Range) -> str
module base.regex
Regex library
Based on [Brzozowski derivatives](https://en.wikipedia.org/wiki/Brzozowski_derivative).
Ported from code: [MichaelPaddon/epsilon](https://github.com/MichaelPaddon/epsilon)
pub fn find(pattern: str, text: str) -> Option
pub fn find_all(pattern: str, text: str) -> List[Match]
Find all regular expression in the given text.
pub fn find_all_text(pattern: str, text: str) -> List[str]
fn get_text(m: Match) -> str
pub fn split_at_pattern(text: str, pattern: str) -> List[str]
Split a string at the given regex
pub struct Match
begin: int64end: int64text: str
pub fn compile(pattern: str) -> Machine
class Machine
pub fn next_state(state_nr: int64, c: char) -> int64
pub fn accepts(state_nr: int64) -> bool
fn parse(pattern: str) -> Regex
pub fn print_machine(machine: Machine)
fn print_regex(rx: Regex, level: int64)
fn new_char_set(c: char) -> IntegerSet
Single character set
fn symbol_regex(c: char) -> Regex
Regex for single character
fn epsilon_regex() -> Regex
pub fn sigma_regex() -> Regex
Regex with all symbols!
class Regex
pub fn to_string() -> str
pub fn equals(other: Regex) -> bool
pub fn is_epsilon() -> bool
pub fn is_kleene() -> bool
pub fn is_logical_not() -> bool
pub fn derivative(c: int64) -> Regex
pub fn is_nullable() -> bool
module base.rope
Rope data type for modifiable text.
Idea is to store text in a binary tree. Each node has
extra meta-data. Leaf nodes contain the actual characters of
the text.
A rope data type can be used in a text editor. Inserting text
can be seen as splitting the tree, and then merging the nodes
again.
pub class RopeText
pub fn insert(pos: int64, text: str)
Insert text at the given position
pub fn delete(pos: int64, size: int64)
Delete some text
fn new_leaf_node(text: str) -> Node
fn to_text(node: Node) -> str
module base.settype
Set datatype, build upon the HashMap datatype.
pub fn new_set[T](f_hash: fn (T) -> uint32, f_eq: fn (T, T) -> bool) -> Set[T]
pub fn new_str_set() -> Set[str]
pub fn new_int_set() -> Set[int64]
pub fn new_uint32_set() -> Set[uint32]
pub class Set[T]
pub fn contains(value?: T) -> bool
pub fn is_empty() -> bool
fn new_empty_set() -> Set[T]
pub fn union(other?: Set[T]) -> Set[T]
New set with items from both sets
pub fn union_add(other?: Set[T])
Add all items from the other set
pub fn intersection(other?: Set[T]) -> Set[T]
New set with only items that are in both sets
pub fn difference(other?: Set[T]) -> Set[T]
New set with only items from other removed
pub fn equals(other?: Set[T]) -> bool
module base.shapelib
Geometry function library.
pub struct Point
x: int64y: int64
pub fn str_point(p?: Point) -> str
pub fn shoelace(points: List[Point]) -> float64
module base.sorting
pub fn find_min_value[T](values: List[T], cmp: fn (T, T) -> bool) -> T
pub fn find_max_value[T](values: List[T], cmp: fn (T, T) -> bool) -> T
pub fn sort_list[T](x?: List[T], cmp: fn (T, T) -> bool) -> List[T]
fn merge_sort[T](m: List[T], cmp: fn (T, T) -> bool) -> List[T]
module base.strlib
pub fn split_string2(text: str, sep: str) -> List[str]
Split string by other string
pub fn split_string(text: str, sep: char) -> List[str]
pub fn rsplit_string(text: str, sep: char, maxsplit: int64) -> List[str]
Split string based on separator, and a maximum amount of splits
pub fn lexical_sort(values?: List[str]) -> List[str]
pub fn string_compare(a: str, b: str) -> bool
pub fn str_repeat(text: str, count: int64) -> str
pub fn str_pad_right(text: str, length: int64, fill: str) -> str
pub fn str_pad_left(text: str, length: int64, fill: str) -> str
pub fn str_join(parts: List[str], sep: str) -> str
pub fn is_space(c: char) -> bool
pub fn is_tab(c: char) -> bool
pub fn is_lf(c: char) -> bool
fn is_cr(c: char) -> bool
fn is_whitespace(c?: char) -> bool
pub fn str_to_int(text?: str) -> int64
pub fn hex_to_int(hextext: str) -> int64
Convert hex text
pub fn bin_to_int(bintext: str) -> int64
Convert bin text to integer value
For example, convert 101 to 5
pub fn is_digit(c: char) -> bool
Check if a character is a digit.
pub fn digit_to_int(c: char) -> int64
pub fn hex_digit_to_int(c: char) -> int64
pub fn is_hex_digit(c: char) -> bool
Check if a character is a hex digit.
pub fn int_to_hex_string(value?: int64) -> str
pub fn hex_char(value?: int64) -> char
pub fn is_bin_digit(c: char) -> bool
pub fn bin_digit_to_int(c: char) -> int64
pub fn trim(text?: str) -> str
pub fn find_char(text: str, criterium: fn (char) -> bool) -> Option
pub fn reverse_find_char(text: str, criterium: fn (char) -> bool) -> Option
fn str_comparison(a: str, b: str) -> int64
pub fn split_lines(text: str) -> List[str]
module base.terminal
Terminal colors
pub enum Color
BlackRedGreenYellowBlueMagentaCyanWhite
pub fn colored_text(text: str, color: Color) -> str
fn sgr(code?: int64) -> str
fn get_color_code(color: Color) -> int64
module base.text_out
pub fn new_console_text_out() -> TextOut
enum TextOutType
ConsoleFile(int64)
module base.unittest
Unit testing helper functions.
pub fn assert_str_equals(a?: str, b?: str)
pub fn assert_int_equals(a?: int64, b?: int64)
pub fn assert_almost_equals(a?: float64, b?: float64)
pub fn assert_list_equals(a?: List[str], b?: List[str])
pub fn assert_true(condition?: bool)
pub fn assert_false(condition?: bool)
module base.utils
pub fn panic(message?: str) -> UNREACHABLE-TYPE
pub fn unimplemented(message?: str) -> UNREACHABLE-TYPE
pub fn assert(condition: bool, message: str)
module base.vectype
Vector datatype.
As opposed to the Linked List, we use an array here.
The allocated array will be larger than the actual amount of values,
and when appendingwe might need to re-allocate the array and copy
the old values.
pub fn new_vector[T]() -> Vector[T]
pub fn new_vector_with_capacity[T](capacity: int64) -> Vector[T]
pub fn new_vector_of_size[T](size: int64, default: T) -> Vector[T]
pub fn vec3[T](v1?: T, v2?: T, v3?: T) -> Vector[T]
pub fn vec4[T](v1?: T, v2?: T, v3?: T, v4?: T) -> Vector[T]
pub fn vec5[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T) -> Vector[T]
pub fn vec8[T](v1?: T, v2?: T, v3?: T, v4?: T, v5?: T, v6?: T, v7?: T, v8?: T) -> Vector[T]
pub class Vector[T]
pub fn is_empty() -> bool
pub fn drop_last_n(n: int64)
pub fn extend(other?: Vector[T])
Append all elements of other to this vector
pub fn get(index: int64) -> T
pub fn set(index: int64, value: T)
pub fn slice(offset: int64, amount: int64) -> Vector[T]
Extract a sub sequence
pub fn take(amount?: int64) -> Vector[T]
Create a new vector with the given amount of items
pub fn skip(amount?: int64) -> Vector[T]
module base.xml
XML parsing routines.
pub class Node
pub fn add_attribute(name: str, value: str)
pub fn add_child(node?: Node)
pub fn add_content(text: str)
pub fn read_xml() -> Node
module base.zip
ZIP file format.
module std