Primordials

Arithmetic

amalgam.primordials.arithmetic._add(env: Environment, *nums: am.Numeric)am.Numeric[source]

Returns the sum of nums.

amalgam.primordials.arithmetic._div(env: Environment, *nums: am.Numeric)am.Numeric[source]

Divides nums[0] and the product of nums[1:]

amalgam.primordials.arithmetic._mul(env: Environment, *nums: am.Numeric)am.Numeric[source]

Returns the product of nums.

amalgam.primordials.arithmetic._sub(env: Environment, *nums: am.Numeric)am.Numeric[source]

Subtracts nums[0] and the summation of nums[1:].

Boolean

amalgam.primordials.boolean._and(env: Environment, *exprs: am.Amalgam)am.Atom[source]

Checks the truthiness of the evaluated exprs and performs an and operation. Short-circuits when :FALSE is returned and does not evaluate subsequent expressions.

amalgam.primordials.boolean._bool(env: Environment, expr: am.Amalgam)am.Atom[source]

Checks for the truthiness of an expr.

amalgam.primordials.boolean._not(env: Environment, expr: am.Amalgam)am.Atom[source]

Checks and negates the truthiness of expr.

amalgam.primordials.boolean._or(env: Environment, *exprs: am.Amalgam)am.Atom[source]

Checks the truthiness of the evaluated exprs and performs an or operation. Short-circuits when :TRUE is returned and does not evaluate subsequent expressions.

Comparison

amalgam.primordials.comparison._eq(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs an equals comparison.

amalgam.primordials.comparison._ge(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs a greater than or equal comparison.

amalgam.primordials.comparison._gt(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs a greater than comparison.

amalgam.primordials.comparison._le(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs a less than or equal comparison.

amalgam.primordials.comparison._lt(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs a less than comparison.

amalgam.primordials.comparison._ne(env: Environment, x: am.Amalgam, y: am.Amalgam)am.Atom[source]

Performs a not equals comparison.

Control

amalgam.primordials.control._break(env: Environment)am.Vector[source]

Exits a loop with :NIL.

amalgam.primordials.control._cond(env: Environment, *pairs: am.Vector[am.Amalgam])am.Amalgam[source]

Traverses pairs of conditions and values. If the condition evaluates to :TRUE, returns the value pair and short-circuits evaluation. If no conditions are met, :NIL is returned.

amalgam.primordials.control._do(env: Environment, *exprs: am.Amalgam)am.Amalgam[source]

Evaluates a variadic amount of exprs, returning the final expression evaluated.

amalgam.primordials.control._if(env: Environment, cond: am.Amalgam, then: am.Amalgam, else_: am.Amalgam)am.Amalgam[source]

Checks the truthiness of the evaluated cond, evaluates and returns then if :TRUE, otherwise, evaluates and returns else_.

amalgam.primordials.control._loop(env: Environment, *exprs: am.Amalgam)am.Amalgam[source]

Loops through and evaluates exprs indefinitely until a break or return is encountered.

amalgam.primordials.control._return(env: Environment, result: am.Amalgam)am.Vector[source]

Exits a context with a result.

amalgam.primordials.control._when(env: Environment, cond: am.Amalgam, body: am.Amalgam)am.Amalgam[source]

Synonym for _if() that defaults else to :NIL.

IO

amalgam.primordials.io._exit(env: Environment, exit_code: am.Numeric = <Numeric '0' @ 0x7feb38801710>)am.Amalgam[source]

Exits the program with the given exit_code.

amalgam.primordials.io._print(env: Environment, amalgam: am.Amalgam)am.Amalgam[source]

Prints the provided amalgam and returns it.

amalgam.primordials.io._putstrln(env: Environment, string: am.String)am.String[source]

Prints the provided string and returns it.

Meta

amalgam.primordials.meta._eval(env: Environment, amalgam: am.Amalgam)am.Amalgam[source]

Evaluates a given amalgam.

amalgam.primordials.meta._fn(env: Environment, args: am.Vector[am.Symbol], body: am.Amalgam)am.Function[source]

Creates an anonymous function using the provided arguments.

Binds env to the created amalgams.Function if a closure is formed.

amalgam.primordials.meta._let(env: Environment, pairs: am.Vector[am.Vector], body: am.Amalgam)am.Amalgam[source]

Creates temporary bindings of names to values specified in pairs before evaluating body.

amalgam.primordials.meta._macro(env: Environment, name: am.Symbol, args: am.Vector[am.Symbol], body: am.Amalgam)am.Amalgam[source]

Creates a named macro using the provided arguments.

amalgam.primordials.meta._mkfn(env: Environment, name: am.Symbol, args: am.Vector[am.Symbol], body: am.Amalgam)am.Amalgam[source]

Creates a named function using the provided arguments.

Composes _fn() and _setn().

amalgam.primordials.meta._setn(env: Environment, name: am.Symbol, amalgam: am.Amalgam)am.Amalgam[source]

Binds name to the evaluated amalgam value in the immediate env and returns that value.

amalgam.primordials.meta._setr(env: Environment, rname: am.Amalgam, amalgam: am.Amalgam)am.Amalgam[source]

Attemps to resolve rname to a amalgams.Symbol and binds it to the evaluated amalgam in the immediate env.

amalgam.primordials.meta._unquote(env: Environment, qamalgam: am.Quoted[am.Amalgam])am.Amalgam[source]

Unquotes a given qamalgam.

String

amalgam.primordials.string._concat(env: Environment, *strings: am.String)am.String[source]

Concatenates the given strings.

Utils

amalgam.primordials.utils.make_function(store: Store, name: str, func: Callable[[...], amalgam.primordials.utils.T], defer: bool = False, contextual: bool = False, allows: Sequence[str] = None)Callable[[...], amalgam.primordials.utils.T][source]
amalgam.primordials.utils.make_function(store: Store, name: str, func: None = None, defer: bool = False, contextual: bool = False, allows: Sequence[str] = None)functools.partial

Transforms a func into a amalgams.Function and places it inside of a store.

Vector

amalgam.primordials.vector._at(env: Environment, index: am.Numeric, vector: am.Vector)am.Amalgam[source]

Indexes vector with index.

amalgam.primordials.vector._cons(env: Environment, amalgam: am.Amalgam, vector: am.Vector)am.Vector[source]

Preprends an amalgam to vector.

amalgam.primordials.vector._is_map(env: Environment, vector: am.Vector)am.Atom[source]

Verifies whether vector is a mapping.

amalgam.primordials.vector._len(env: Environment, vector: am.Vector)am.Numeric[source]

Returns the length of a vector.

amalgam.primordials.vector._map_at(env: Environment, vector: am.Vector, atom: am.Atom)am.Amalgam[source]

Obtains the value bound to atom in vector.

amalgam.primordials.vector._map_in(env: Environment, vector: am.Vector, atom: am.Atom)am.Atom[source]

Checks whether atom is a member of vector.

amalgam.primordials.vector._map_up(env: Environment, vector: am.Vector, atom: am.Atom, amalgam: am.Amalgam)am.Vector[source]

Updates the vector mapping with :data:`atom, and amalgam.

amalgam.primordials.vector._merge(env: Environment, *vectors: am.Vector)am.Vector[source]

Merges the given vectors.

amalgam.primordials.vector._remove(env: Environment, index: am.Numeric, vector: am.Vector)am.Vector[source]

Removes an item in vector using index.

amalgam.primordials.vector._slice(env: Environment, vector: am.Vector, start: am.Numeric, stop: am.Numeric, step: am.Numeric = <Numeric '1' @ 0x7feb37f148d0>)am.Vector[source]

Returns a slice of the given vector.

amalgam.primordials.vector._snoc(env: Environment, vector: am.Vector, amalgam: am.Amalgam)am.Vector[source]

Appends an amalgam to vector.