Welcome to amalgam-lisp’s documentation!

_images/logo.png

LISP-like interpreted language implemented in Python.

Functions

Documentation for the various built-in functions.

Arithmetic

(+ e0 e1 ... en)

Performs a summation of the provided expressions.

(* e0 e1 ... en)

Performs a multiplication of the provided expressions.

(- e0 e1 ... en)

Subtracts e0 by the sum of e1 ... en.

(/ e0 e1 ... en)

Divides e0 by the product of e1 ... en

Boolean

(bool e)

Checks for the truthiness of an expression

(not e)

Checks for the falsiness of an expression

(and e0 e1 ... en)

Evaluates and reduces the expressions using an and operation, short-circuiting evaluation when a falsy value is encountered.

(or e0 e1 ... en)

Evaluates and reduces the expressions using an or operation, short-circuiting evaluation when a truthy value is encountered.

Control

(if condition then else)

Basic branching construct. If condition evaluates to a truthy value, evaluates then, otherwise, evaluates else.

(when condition then)

Synonym for if where else defaults to NIL.

(cond [[condition value] ...])

Traverses pairs of conditions and values. If the condition evaluates to a truthy value, returns the provided value, short-circuiting evaluation. Returns NIL when no conditions are met.

(do expression...)

Evaluates each expression, returning what was evaluated last.

(loop expression...)

Evaluates each expression, looping back at the end. Can be broken by the return and break functions.

(return expression)

Breaks out of a loop evaluating to a value.

(break)

Breaks out of a loop evaluating to NIL.

Comparison

(> x y)

Performs a greater than operation.

(< x y)

Performs a less than operation.

(= x y)

Performs a equal to operation.

(/= x y)

Performs a not equal to operation.

(>= x y)

Performs a greater than or equal to operation.

(<= x y)

Performs a less than or equal to operation.

IO

(print expression)

Prints an expression.

(putstrln string)

Prints the contents of a string.

(exit code)

Stops the execution of the program.

Meta

(require module-path)

Loads a module given its module-path, importing the exposed symbols to the current environment with respect to the export list created by provide.

(provide symbols...)

Creates an export list of symbols when loaded through require.

(setn name value)

Lexically binds a literal name to a value.

(setr name-ref value)

Lexically binds an evaluated name-ref to a value.

(unquote qexpression)

Unquotes a given qexpression.

(eval expression)

Fully evaluates an expression, optionally removing a layer of quoting.

(fn [args...] body)

Creates a scoped lambda given a vector of args, and a body. Binds to a closure when created inside of one.

(mkfn name [args...] body)

Creates a scoped function given a name, a vector of args, and a body. Binds to a closure when created inside of one.

(macro name [qargs...] body)

Creates a scoped macro given a name, a vector of qargs, and a body. Binds to a closure when created inside of one.

(let [[name value]...] body)

Creates a closure where each value is bound to a name before evaluating body.

String

(concat s0 s1 ... sn)

Concatenates strings together.

Vector

(merge v0 v1 ... vn)

Merges vectors together.

(slice vector start stop step)

Slices a vector using start, stop, and step.

(at index vector)

Returns an item from a vector given its index.

(remove index vector)

Removes an item from a vector given its index.

(len vector)

Returns the length of a vector.

(cons item vector)

Prepends an item to a vector.

(snoc vector item)

Appends an item to a vector.

(is-map vector)

Verifies if the vector is a map.

(map-in vector atom)

Checks whether atom is a member of vector.

(map-at vector atom)

Obtains the value bound to atom in vector.

(map-up vector atom value)

Sets or updates the atom member of vector with atom.

Tutorials

Creating Macros

Macros are a flexible way to define new language constructs within the language. This tutorial implements a for-each loop as an example.

First, let’s define the form of our for-each loop:

(for target in vector expression)

target is the name of the symbol, vector is the sequence we’re iterating through, and expression being the actions performed for every iteration.

We can use the macro function to define this form:

(macro for [qtarget in qvector qexpression] ...)

target, vector, and expression are prefixed with q as arguments to macros are passed literally as quoted values that are not evaluated, giving the macro the ability to selective unquote and evaluate expressions.

Let’s now define what happens within the macro:

(macro for [qtarget in qvector qexpression]
       (do (setn target (unquote qtarget))
           (setn vector (unquote qvector))
           (setn expression (unquote qexpression))
           (setn index 0)
           (setn final (len vector))
           (loop (when (= index final) (break))
                 (setr target (at index vector))
                 (eval expression)
                 (setn index (+ index 1)))))

The values being manipulated in the macro are first unquoted and bound to names without their q prefix:

(do (setn target (unquote qtarget))
    (setn vector (unquote qvector))
    (setn expression (unquote qexpression)))

Then, the looping logic is defined:

(setn index 0)
(setn final (len vector))
(loop (when (= index final) (break))
      (setr target (at index vector))
      (eval expression)
      (setn index (+ index 1)))

Two things are to be observed here, specifically, the use of setr and eval. As described by the form that we’ve defined earlier, target is the name of the symbol that we’re assigning to, and as such, we’ll have to use setr instead of setn to make sure that we’re not binding to target literally. We then evaluate the expression literal, which then has access to the value bound to target.

Let’s test it out on the REPL:

> (macro for [qtarget in qvector qexpression]
|        (do (setn target (unquote qtarget))
|            (setn vector (unquote qvector))
|            (setn expression (unquote qexpression))
|            (setn index 0)
|            (setn final (len vector))
|            (loop (when (= index final) (break))
|                  (setr target (at index vector))
|                  (eval expression)
|                  (setn index (+ index 1)))))
for
> (for x in [1 2 3 4 5]
|      (print (* x x)))
1
4
9
16
25
:NIL

The newly defined for macro is able to iterate through the vector, binding each number to x before evaluating the expression.

Note: Macros create their own closure, and symbols bound within them are inaccessible after evaluation.

Modifying the macro to return the expression evaluated last is left as an exercise for the reader.

Amalgams

Internal documentation for the amalgam.amalgams module.

class amalgam.amalgams.Amalgam[source]

The abstract base class for language constructs.

_make_repr(value: Any) → str[source]

Helper method for creating a __repr__().

bind(environment: amalgam.environment.Environment)amalgam.amalgams.Amalgam[source]

Protocol for implementing environment binding for Function.

This base implementation is responsible for allowing bind to be called on other Amalgam subclasses by performing no operation aside from returning self.

call(environment: amalgam.environment.Environment, *arguments: amalgam.amalgams.Amalgam)amalgam.amalgams.Amalgam[source]

Protocol for implementing function calls for Function.

This base implementation is responsible for making the type signature of SExpression.func to properly type check when SExpression.evaluate() is called, as well as raising NotImplementedError for non-callable types.

abstract evaluate(environment: amalgam.environment.Environment) → Any[source]

Protocol for evaluating or unwrapping Amalgam objects.

class amalgam.amalgams.Atom(value: str)[source]

An Amalgam that represents different atoms.

value

The name of the atom.

Type

str

evaluate(_environment: amalgam.environment.Environment)amalgam.amalgams.Atom[source]

Evaluates to the same Atom reference.

class amalgam.amalgams.Numeric(value: N)[source]

An Amalgam that wraps around numeric types.

Parameterized as a Generic by: N = TypeVar("N", int, float, Fraction)

value

The numeric value being wrapped.

Type

N

evaluate(_environment: amalgam.environment.Environment)amalgam.amalgams.Numeric[source]

Evaluates to the same Numeric reference.

class amalgam.amalgams.Symbol(value: str)[source]

An Amalgam that wraps around symbols.

value

The name of the symbol.

Type

str

evaluate(environment: amalgam.environment.Environment)amalgam.amalgams.Amalgam[source]

Searches the provided environment fully with Symbol.value. Returns the Amalgam object bound to the Symbol.value in the environment. Raises environment.SymbolNotFound if a binding is not found.

class amalgam.amalgams.Function(name: str, fn: Callable[[], amalgam.amalgams.Amalgam], defer: bool = False, contextual: bool = False)[source]

An Amalgam that wraps around functions.

name

The name of the function.

Type

str

fn

The function being wrapped. Must have the signature: (env, amalgams…) -> amalgam.

Type

Callable[..., Amalgam]

defer

If set to True, arguments are wrapped in Quoted before being passed to Function.fn.

Type

bool

contextual

If set to True, disallows function calls when Function.in_context is set to False.

Type

bool

env

The environment.Environment instance bound to the function. Overrides the environment parameter passed to the Function.call() method.

Type

environment.Environment

in_context

Predicate that disallows functions to be called outside of specific contexts. Makes Function.call() raise DisallowedContextError when set to False and Function.contextual is set to True.

Type

bool

bind(environment: amalgam.environment.Environment)amalgam.amalgams.Function[source]

Sets the Function.env attribute and returns the same Function reference.

call(environment: amalgam.environment.Environment, *arguments: amalgam.amalgams.Amalgam)amalgam.amalgams.Amalgam[source]

Performs the call to the Function.fn attribute.

Performs pre-processing depending on the values of Function.defer, Function.contextual, and Function.in_context,

evaluate(_environment: amalgam.environment.Environment)amalgam.amalgams.Function[source]

Evaluates to the same Function reference.

with_name(name: str)amalgam.amalgams.Function[source]

Sets the Function.name attribute and returns the same Function reference.

class amalgam.amalgams.SExpression(*vals: amalgam.amalgams.Amalgam)[source]

An Amalgam that wraps around S-Expressions.

vals

Entities contained by the S-Expression.

Type

Tuple[Amalgam, ...]

evaluate(environment: amalgam.environment.Environment)amalgam.amalgams.Amalgam[source]

Evaluates func using environment before invoking the call() method with environment and SExpression.args.

property args

The rest of the SExpression.vals.

property func

The head of the SExpression.vals.

class amalgam.amalgams.Vector(*vals: T)[source]

An Amalgam that wraps around a homogenous vector.

Parameterized as a Generic by: T = TypeVar("T", bound=Amalgam)

vals

Entities contained by the vector

Type

Tuple[T, ...]

mapping

Mapping representing vectors with Atom s for odd indices and Amalgam s for even indices.

Type

Mapping[str, Amalgam]

_as_mapping() → Mapping[str, amalgam.amalgams.Amalgam][source]

Attemps to create a Mapping[str, Amalgam] from Vector.vals.

Odd indices must be Atom s and even indices must be Amalgam s. Returns an empty mapping if this form is not met.

evaluate(environment: amalgam.environment.Environment)amalgam.amalgams.Vector[source]

Creates a new Vector by evaluating every value in Vector.vals.

class amalgam.amalgams.Quoted(value: T)[source]

An Amalgam that defers evaluation of other Amalgam s.

Parameterized as a Generic by: T = TypeVar("T", bound=Amalgam)

value

The Amalgam being deferred.

Type

T

evaluate(_environment: amalgam.environment.Environment)amalgam.amalgams.Quoted[source]

Evaluates to the same Quoted reference.

class amalgam.amalgams.Internal(value: P)[source]

An Amalgam that holds Python object s.

Parameterized as a Generic by: P = TypeVar("P", bound=object)

value

The Python object being wrapped.

Type

P

evaluate(_environment: amalgam.environment.Environment)amalgam.amalgams.Internal[source]

Evaluates to the same Internal reference.

class amalgam.amalgams.DisallowedContextError[source]

Raised on functions outside of their intended contexts.

Engine

Internal documentation for the amalgam.engine module.

class amalgam.engine.Engine[source]

Class that serves as the frontend for parsing and running programs.

parser

A parser.Parser instance.

Type

parser.Parser

environment

An environment.Environment instance containing the built-in functions and a reference to the engine.Engine instance wrapped within a amalgams.Internal, accessible through the ~engine~ key.

Type

environment.Environment

parse_and_run(text: str)amalgam.amalgams.Amalgam[source]

Parses and runs the given text string.

repl(*, prompt: str = '> ', prompt_cont: str = '| ') → None[source]

Runs a REPL session that supports multi-line input.

Parameters
  • prompt (str) – The style of the prompt on regular lines.

  • prompt_cont (str) – The style of the prompt on continued lines.

Environment

Internal documentation for the amalgam.environment module.

class amalgam.environment.Environment(bindings: Bindings = None, parent: Environment = None)[source]

Class that manages and represents nested execution environments.

bindings

A mapping of str keys to amalgams.Amalgam values.

Type

Dict[str, Amalgam]

parent

The parent Environment instance to search into, forming a linked list.

Type

Optional[Environment]

level

The current length of the Environment linked list. If a parent is provided, sets the current value to the parent’s level + 1.

Type

int

search_depth

The search depth when traversing the Environment linked list in the __contains__(), __delitem__(), __getitem__(), and __setitem__() methods.

Type

int

__contains__(item: str) → bool[source]

Recursively checks whether an item exists.

Searches with respect to the current search_depth of the calling Environment instance. If the target item is encountered at a certain depth less than the target depth, immediately returns True, otherwise, returns False.

__delitem__(item: str) → None[source]

Attempts to recursively delete the provided item.

Searches with respect to the current search_depth of the calling Environment instance. If an existing item is encountered at a certain depth less than the target depth, deletes that item instead.

__getitem__(item: str) → Amalgam[source]

Attempts to recursively obtain the provided item.

Searches with respect to the current search_depth of the calling Environment instance. If an existing item is encountered at a certain depth less than the target depth, returns that item, otherwise, raises SymbolNotFound.

__setitem__(item: str, value: Amalgam) → None[source]

Attempts to recursively set the provided value to an item.

Searches with respect to the current search_depth of the calling Environment instance. If an existing item is encountered at a certain depth less than the target depth, overrides that item instead.

env_pop()amalgam.environment.Environment[source]

Discards the current Environment and returns the parent Environment.

env_push(bindings: Bindings = None)Environment[source]

Creates a new Environment and binds the calling instance as its parent environment.

search_at(*, depth=0)[source]

Context manager for temporarily setting the lookup depth.

The provided depth argument must not exceed the level of the calling Environment instance, and will raise a ValueError if done so.

>>> env = Environment(FUNCTIONS)
>>>
>>> with env.search_at(depth=42):
...     env["+"]  # Raises ValueError

Any negative integer can be passed as a depth to signify an infinite lookup until the top-most environment.

>>> env = Environment(FUNCTIONS)
>>> cl_env = env.env_push({...})
>>>
>>> with cl_env.search_at(depth=-1):
...    cl_env["+"]  # Searches `env`
class amalgam.environment.SymbolNotFound[source]

Synonym for KeyError.

class amalgam.environment.TopLevelPop[source]

Raised at Environment.env_pop().

Parser

Internal documentation for the amalgam.parser module.

class amalgam.parser.Parser[source]

Class that serves as the frontend for parsing text.

parse_buffer

The text buffer used within Parser.repl_parse().

Type

StringIO

parse(text: str)amalgam.amalgams.Amalgam[source]

Facilitates regular parsing that can fail.

repl_parse(text: str) → Optional[amalgam.amalgams.Amalgam][source]

Facilitates multi-line parsing for the REPL.

Writes the given text string to the parse_buffer and attempts to parse text.

If MissingClosing is raised, returns None to allow for parsing to continue.

If another subclass of ParsingError is raised, clears the parse_buffer and re-raises the exception.

Otherwise, if parsing succeeds, clears the parse_buffer and returns the parsed expression.

class amalgam.parser.Expression(visit_tokens=True)[source]

Transforms expressions in text into their respective amalgams.Amalgam representations.

atom(identifier: lark.lexer.Token)amalgam.amalgams.Atom[source]
floating(number: lark.lexer.Token)amalgam.amalgams.Numeric[source]
fraction(number: lark.lexer.Token)amalgam.amalgams.Numeric[source]
integral(number: lark.lexer.Token)amalgam.amalgams.Numeric[source]
quoted(expression: amalgam.amalgams.Amalgam)amalgam.amalgams.Quoted[source]
s_expression(*expressions: amalgam.amalgams.Amalgam)amalgam.amalgams.SExpression[source]
string(*values: lark.lexer.Token) → amalgam.amalgams.String[source]
symbol(identifier: lark.lexer.Token)amalgam.amalgams.Symbol[source]
vector(*expressions: amalgam.amalgams.Amalgam)amalgam.amalgams.Vector[source]
class amalgam.parser.ParsingError(line: int, column: int)[source]

Base exception for errors during parsing.

line

the line number nearest to the error

Type

int

column

the column number nearest to the error

Type

int

class amalgam.parser.ExpectedEOF(line: int, column: int)[source]

Raised when multiple expressions are found.

class amalgam.parser.ExpectedExpression(line: int, column: int)[source]

Raised when no expressions are found.

class amalgam.parser.MissingClosing(line: int, column: int)[source]

Raised on missing closing parentheses or brackets.

class amalgam.parser.MissingOpening(line: int, column: int)[source]

Raised on missing opening parentheses or brackets.

Primordials

amalgam.primordials._add(_env: amalgam.environment.Environment, *nums: amalgam.amalgams.Numeric)amalgam.amalgams.Numeric[source]

Returns the sum of nums.

amalgam.primordials._and(env: amalgam.environment.Environment, *qexprs: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Atom[source]

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

amalgam.primordials._at(_env: amalgam.environment.Environment, index: amalgam.amalgams.Numeric, vector: amalgam.amalgams.Vector)amalgam.amalgams.Amalgam[source]

Indexes vector with index.

amalgam.primordials._bool(_env: amalgam.environment.Environment, expr: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Checks for the truthiness of an expr.

amalgam.primordials._break(env: amalgam.environment.Environment)amalgam.amalgams.Internal[source]

Exits a loop with :NIL.

amalgam.primordials._concat(_env: amalgam.environment.Environment, *strings: amalgam.amalgams.String) → amalgam.amalgams.String[source]

Concatenates the given strings.

amalgam.primordials._cond(env: amalgam.environment.Environment, *qpairs: amalgam.amalgams.Quoted[amalgam.amalgams.Vector[amalgam.amalgams.Amalgam]])amalgam.amalgams.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._cons(_env: amalgam.environment.Environment, amalgam: amalgam.amalgams.Amalgam, vector: amalgam.amalgams.Vector)amalgam.amalgams.Vector[source]

Preprends an amalgam to vector.

amalgam.primordials._div(_env: amalgam.environment.Environment, *nums: amalgam.amalgams.Numeric)amalgam.amalgams.Numeric[source]

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

amalgam.primordials._do(env: amalgam.environment.Environment, *qexprs: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

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

amalgam.primordials._eq(_env: amalgam.environment.Environment, x: amalgam.amalgams.Amalgam, y: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Performs an equals comparison.

amalgam.primordials._eval(env: amalgam.environment.Environment, amalgam: amalgam.amalgams.Amalgam)amalgam.amalgams.Amalgam[source]

Evaluates a given amalgam.

amalgam.primordials._exit(env: amalgam.environment.Environment, exit_code: amalgam.amalgams.Numeric = <Numeric '0' @ 0x7f713fb619d0>)amalgam.amalgams.Amalgam[source]

Exits the program with the given exit_code.

amalgam.primordials._fn(env: amalgam.environment.Environment, args: amalgam.amalgams.Quoted[amalgam.amalgams.Vector[amalgam.amalgams.Symbol]], body: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Function[source]

Creates an anonymous function using the provided arguments.

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

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

Performs a greater than or equal comparison.

amalgam.primordials._gt(_env: amalgam.environment.Environment, x: amalgam.amalgams.Amalgam, y: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Performs a greater than comparison.

amalgam.primordials._if(env: amalgam.environment.Environment, qcond: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam], qthen: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam], qelse: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

Checks the truthiness of the evaluated qcond, evaluates and returns qthen if :TRUE, otherwise, evaluates and returns qelse.

amalgam.primordials._is_map(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector)amalgam.amalgams.Atom[source]

Verifies whether vector is a mapping.

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

Performs a less than or equal comparison.

amalgam.primordials._len(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector)amalgam.amalgams.Numeric[source]

Returns the length of a vector.

amalgam.primordials._let(env: amalgam.environment.Environment, qpairs: amalgam.amalgams.Quoted[amalgam.amalgams.Vector[amalgam.amalgams.Vector]], body: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

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

amalgam.primordials._loop(env: amalgam.environment.Environment, *qexprs: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

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

amalgam.primordials._lt(_env: amalgam.environment.Environment, x: amalgam.amalgams.Amalgam, y: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Performs a less than comparison.

amalgam.primordials._macro(env: amalgam.environment.Environment, name: amalgam.amalgams.Quoted[amalgam.amalgams.Symbol], args: amalgam.amalgams.Quoted[amalgam.amalgams.Vector[amalgam.amalgams.Symbol]], body: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

Creates a named macro using the provided arguments.

amalgam.primordials._make_function(name: str, func: Callable[[], T] = None, defer: bool = False, contextual: bool = False, allows: Sequence[str] = None) → Union[functools.partial, Callable[[], T]][source]

Transforms a given function func into a Function and stores it inside of the FUNCTIONS mapping.

amalgam.primordials._map_at(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector, atom: amalgam.amalgams.Atom)amalgam.amalgams.Amalgam[source]

Obtains the value bound to atom in vector.

amalgam.primordials._map_in(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector, atom: amalgam.amalgams.Atom)amalgam.amalgams.Atom[source]

Checks whether atom is a member of vector.

amalgam.primordials._map_up(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector, atom: amalgam.amalgams.Atom, amalgam: amalgam.amalgams.Amalgam)amalgam.amalgams.Vector[source]

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

amalgam.primordials._merge(_env: amalgam.environment.Environment, *vectors: amalgam.amalgams.Vector)amalgam.amalgams.Vector[source]

Merges the given vectors.

amalgam.primordials._mkfn(env: amalgam.environment.Environment, name: amalgam.amalgams.Quoted[amalgam.amalgams.Symbol], args: amalgam.amalgams.Quoted[amalgam.amalgams.Vector[amalgam.amalgams.Symbol]], body: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

Creates a named function using the provided arguments.

Composes _fn() and _setn().

amalgam.primordials._mul(_env: amalgam.environment.Environment, *nums: amalgam.amalgams.Numeric)amalgam.amalgams.Numeric[source]

Returns the product of nums.

amalgam.primordials._ne(_env: amalgam.environment.Environment, x: amalgam.amalgams.Amalgam, y: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Performs a not equals comparison.

amalgam.primordials._not(_env: amalgam.environment.Environment, expr: amalgam.amalgams.Amalgam)amalgam.amalgams.Atom[source]

Checks and negates the truthiness of expr.

amalgam.primordials._or(env: amalgam.environment.Environment, *qexprs: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Atom[source]

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

amalgam.primordials._print(_env: amalgam.environment.Environment, amalgam: amalgam.amalgams.Amalgam)amalgam.amalgams.Amalgam[source]

Prints the provided amalgam and returns it.

amalgam.primordials._provide(env: amalgam.environment.Environment, *qsymbols: amalgam.amalgams.Quoted[amalgam.amalgams.Symbol])amalgam.amalgams.Atom[source]

Sets the ~provides~ key to be used in _require().

amalgam.primordials._putstrln(_env: amalgam.environment.Environment, string: amalgam.amalgams.String) → amalgam.amalgams.String[source]

Prints the provided string and returns it.

amalgam.primordials._remove(_env: amalgam.environment.Environment, index: amalgam.amalgams.Numeric, vector: amalgam.amalgams.Vector)amalgam.amalgams.Vector[source]

Removes an item in vector using index.

amalgam.primordials._require(env: amalgam.environment.Environment, module_name: amalgam.amalgams.String)amalgam.amalgams.Atom[source]

Runs a given module_name and imports the exposed symbols to the current env with respect to the ~provides~ key created in _provide().

amalgam.primordials._return(env: amalgam.environment.Environment, result: amalgam.amalgams.Amalgam)amalgam.amalgams.Internal[source]

Exits a context with a result.

amalgam.primordials._setn(env: amalgam.environment.Environment, name: amalgam.amalgams.Quoted[amalgam.amalgams.Symbol], amalgam: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

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

amalgam.primordials._setr(env: amalgam.environment.Environment, qrname: amalgam.amalgams.Quoted[amalgam.amalgams.Symbol], qamalgam: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

Attemps to resolve qrname to a amalgams.Symbol and binds it to the evaluated qamalgam in the immediate env.

amalgam.primordials._slice(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector, start: amalgam.amalgams.Numeric, stop: amalgam.amalgams.Numeric, step: amalgam.amalgams.Numeric = <Numeric '1' @ 0x7f713fb61fd0>)amalgam.amalgams.Vector[source]

Returns a slice of the given vector.

amalgam.primordials._snoc(_env: amalgam.environment.Environment, vector: amalgam.amalgams.Vector, amalgam: amalgam.amalgams.Amalgam)amalgam.amalgams.Vector[source]

Appends an amalgam to vector.

amalgam.primordials._sub(_env: amalgam.environment.Environment, *nums: amalgam.amalgams.Numeric)amalgam.amalgams.Numeric[source]

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

amalgam.primordials._unquote(_env: amalgam.environment.Environment, qamalgam: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

Unquotes a given qamalgam.

amalgam.primordials._when(env: amalgam.environment.Environment, qcond: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam], qbody: amalgam.amalgams.Quoted[amalgam.amalgams.Amalgam])amalgam.amalgams.Amalgam[source]

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