Skip to main content

Standard Library

The Aleph Standard Library provides essential types, functions, and utilities for Aleph programming.

It includes fundamental data types (numbers, strings, booleans), collection types (List, Map, Set, Pair), mathematical functions, string manipulation utilities, asynchronous programming, and comprehensive operator overloading.

The stdlib forms the foundation of the Aleph language runtime and is automatically available in all Aleph programs.

Global Constants

NameDescription
global_timerA global timer instance that can be used to measure elapsed time across the application. It is initialized when the module is loaded and can be used to track time without creating new Timer instances.
start_epochThe epoch time (in seconds) when the Aleph interpreter started.

Types

NameDescription
ActionRepresents a Function that has no arguments and return no value.
ArithmeticErrorError thrown when arithmetic operations encounter invalid conditions or produce undefined results.
BenchmarkResultContains statistical results from benchmarking operations.
CSVDocumentRepresents a CSV document that can be loaded from a file and queried.
CSVValueConverterFuncA function type used to convert CSV string values to other types.
DynamicObjectA flexible object type that allows dynamic creation and modification of attributes at runtime.
ErrorThe base type for all exceptions and error conditions in Aleph.
EvalErrorError thrown when an error occurs during script evaluation or execution.
FuncRepresents a Function that has no arguments and return a single value.
FunctionRepresents callable code blocks or routines.
FutureRepresents the result of an asynchronous operation that may not be available yet.
InvalidArgumentErrorThis class defines the type of objects thrown as exceptions to report an invalid argument.
ListA dynamic array that can grow and shrink in size during runtime.
ListSorterRepresents a Function that can be used to sort a List.
LogicErrorError thrown when there is a flaw in the logic or internal structure of the program that could be detected before runtime.
MapAn associative container that stores key-value pairs in sorted order.
MapPairPair type that corresponds with the Map type.
NumberRepresents numeric values in the language. This type is a supertype that encompasses both integer and real (floating-point) numbers.
ObjectThe root type of the language. All values are instances of Object.
OutOfRangeErrorError thrown when an operation attempts to access an element outside the valid range of a container or data structure.
PairA container that holds exactly two values, which may be of different types.
RuntimeErrorError thrown for errors that can only be detected during program execution.
SetA container that stores unique elements in no particular order.
SliceRepresents a range specification for indexing operations with start, stop, and step parameters.
SlicesA collection of Slice objects used for multi-dimensional indexing and data access operations.
StringSorterRepresents a Function that can be used to sort a string.
TimerA Timer is used to track elapsed time.
TimerDurationRepresents a duration of time with nanosecond precision.
TypeConverterFunA function type used for converting values between different types.
TypeInfoContains metadata and information about types in the Aleph type system.
boolRepresents a logical value: either true or false.
complexRepresents a complex number with real and imaginary components.
integerRepresents whole numbers (positive, negative, or zero). Uses 64 bits precision, so it ranges between -2^31 and 2^31 - 1.
realRepresents floating-point numbers (numbers with fractional parts). Uses IEEE 754 double-precision semantics.
stringRepresents a sequence of characters.
voidRepresents the absence of a value. It has exactly one value (void) and no methods, as it is not a value you operate on.

Module Functions

NameDescription
RetroUnwraps a reverse range back to its original direction.
Retro::backReturns the last value in reverse traversal order.
Retro::emptyTests whether the reverse range is exhausted.
Retro::frontReturns the first value in reverse traversal order.
Retro::pop_backRemoves the last value in reverse traversal order.
Retro::pop_frontRemoves the first value in reverse traversal order.
absGet the absolute value of a number.
all_ofTests whether every element satisfies a predicate.
any_ofTests whether any element satisfies a predicate.
asyncExecutes a function asynchronously and returns a Future object.
available_threadsReturns the number of hardware threads available on this system.
await_allWaits for every Future in the provided List and returns the completed results in order.
benchmarkBenchmarks a function by running it a specified number of times and collecting timing statistics.
benchmark_forBenchmarks a function by running it repeatedly for a specified duration and collecting timing statistics.
binary_searchReturns the index of the first element in the container that is not less than the given value. The container is assumed to be sorted and the bisection algorithm is used.
boolParses a string and converts it to a bool.
cloneClones a string value and its variable attributes.
collateCollects two values into a list.
complexConverts a complex to a complex (identity function).
concatConcatenates two containers.
conjugateComplex conjugates a number in-place.
conjugatedGet the complex conjugate of a number.
containsTests whether a container contains an equal item.
dropDrops a number of leading elements.
drop_whileDrops leading elements satisfying a predicate.
epochReturns the number of seconds since Unix epoch.
epoch_msReturns the number of milliseconds since Unix epoch.
epsilonReturns the epsilon value of a real
eqCompares two values for equality when equality is supported.
evenTests whether an integer is even.
exitExits the Aleph interpreter with the specified return code.
filterSelects elements satisfying a predicate.
foldlFolds a container from the left.
for_eachInvokes a function for every element in a container.
from_jsonParses a JSON string and converts it to Aleph objects.
generate_rangeGenerates a range of real numbers from start to stop.
gtCompares two values using their ordering or type names.
helpDisplays help information about the Aleph interpreter.
imagGet the imaginary part of a complex number.
integerParses a string and converts it to a integer.
joinJoins container elements into a string.
lowestReturns the lowest value of a bool
ltCompares two values using their ordering or type names.
mapTransforms a container into a new container.
maxReturns the maximum value of a real
max_threadsReturns the maximum number of threads Aleph is configured to use.
minReturns the minimum value of a real
oddTests whether an integer is odd.
parallel_mapApplies a mapper function to every element of a List in parallel using the shared async thread pool.
phaseGet the complex phase of a number.
printPrints a value followed by a newline.
productMultiplies the elements of a container.
putsPrints a value without a trailing newline.
quitQuits the Aleph interpreter with the specified return code.
rangeCreates a range backed by a container's internal range.
realGet the real part of a complex number.
reduceReduces a container using its first element as the accumulator.
reverseReverses a container.
set_max_threadsSets the maximum number of threads Aleph will use.
sleepSuspends execution for the specified number of seconds.
stringFormats a ranged container as a string.
sumSums the elements of a container.
takeTakes the first number of elements into a new container.
take_whileTakes the leading elements satisfying a predicate.
throwThrows the specified value as an exception.
throws_exceptionExecutes an action and returns any exception message as a string.
timeTimes the execution of a function and returns the elapsed duration.
to_jsonConverts an Aleph object to a JSON string.
versionReturns the aleph version number.
zipPairs corresponding elements from two containers.
zip_withCombines corresponding elements into a list.

Module Symbols

NameDescription
!Performs logical NOT operation.
!=Checks if two numbers are not equal.
%Calculates the remainder of the division of two numbers.
%=Calculates the remainder of division and assigns the result.
&Performs a bitwise AND operation.
&=Performs a bitwise AND operation and assigns the result.
*Multiplies two numbers.
**Exponentiates the left-hand side number by the right-hand side number.
**=Exponentiates the left-hand side number by the right-hand side number and assigns the result.
*=Multiplies two numbers and assigns the result.
+Adds two numbers.
++Increments the number by 1 and returns the result.
+=Adds two numbers and assigns the result.
-Negates the number unchanged.
--Decrements the number by 1 and returns the result.
-=Subtracts two numbers and assigns the result.
/Divides the left-hand side number by the right-hand side number.
/=Divides two numbers and assigns the result.
<Checks if the left-hand side number is less than the right-hand side number.
<<Performs a left bitwise shift.
<<=Performs a left bitwise shift and assigns the result.
<=Checks if the left-hand side number is less than or equal to the right-hand side number.
=Assigns the value of the right-hand side to the left-hand side.
==Checks if two numbers are equal.
>Checks if the left-hand side number is greater than the right-hand side number.
>=Checks if the left-hand side number is greater than or equal to the right-hand side number.
>>Performs a right bitwise shift.
>>=Performs a right bitwise shift and assigns the result.
^Performs a bitwise XOR operation.
^=Performs a bitwise XOR operation and assigns the result.
|Performs a bitwise OR operation.
|=Performs a bitwise OR operation and assigns the result.
~Performs a bitwise NOT operation.