____ __ __ __
/\ _`\ __ /\ \__ /\ \ /\ \ __
\ \ \L\ \ __ _ __ /\_\ __ \ \ ,_\ __ ___\ \ \___ \ \ \ /\_\ ____ _____
\ \ ,__/'__`\ /\`'__\/\ \ /'__`\\ \ \/ /'__`\ /'___\ \ _ `\ \ \ \ _\/\ \ /',__\/\ '__`\
\ \ \/\ \L\.\\ \ \/ \ \ \/\ \L\.\\ \ \_/\ __//\ \__/\ \ \ \ \ \ \ \L\ \ \ \/\__, `\ \ \L\ \
\ \_\ \__/.\_\ \_\ \ \_\ \__/.\_\ \__\ \____\ \____\\ \_\ \_\ \ \____/\ \_\/\____/\ \ ,__/
\/_/\/__/\/_/\/_/ \/_/\/__/\/_/\/__/\/____/\/____/ \/_/\/_/ \/___/ \/_/\/___/ \ \ \/
\ \_\
\/_/
Takes anything and return T if it's type of this type
Takes anything and return T if it's type is a symbol.
Takes anything and return T if it's type is an integer, double or rational.
Takes anything and return T if it's type is an integer.
Takes anything and return T if it's type is a double.
Takes anything and return T if it's type is a rational.
Takes anything and return T if it's type is a double and the value is NaN.
Takes anything and return T if it's pointer is the same as undefined.
Takes anything and return T if it's type is a character.
Takes anything and return T if it's type is a string.
Takes anything and return T if it's type is a cons.
Takes anything and return T if it's type is a list.
Takes anything and return T if it's type is a function.
Takes anything and return T if it's type is a macro.
Takes anything and return T if it's type is an array.
Takes anything and return T if it's type is an hash-table.
Takes anything and return T if it's type is a stream.
Takes a number and convert it into a double floating-point number.
Takes a number and round it upward.
Takes a number and round it downward.
Takes a number and round it to mathematically closest and if it's in between two integers i.e 0.5, round to closest even (divisible by two) integer
Takes integers, rationals and doubles. If a number is double return a double. Else if a number is rational and the result's denominator is not 1 then return a rational. Else return an integer.
Takes integers, rationals and doubles. If a number is double return a double. Else if a number is rational and the result's denominator is not 1 then return a rational. Else return an integer.
Takes integers, rationals and doubles. If a number is double return a double. Else if a number is rational and the result's denominator is not 1 then return a rational. Else return an integer.
Takes integers, rationals and doubles. If a number is double return a double. Else if a number is rational and the result's denominator is not 1 then return a rational. Else return an integer.
Takes integers, rationals and doubles. If a number is double return a double. Else if a number is rational and the result's denominator is not 1 then return a rational. Else return an integer.
Takes integers and return an integer.
Takes integers and return an integer.
Takes integers and return an integer.
Takes an integer and return an integer.
Takes anything, evaluate left to right and return the first item that eval to NIL or the result of the last eval.
Takes anything, evaluate left to right and return the first item that eval to not NIL or the result of the last eval.
Takes anything.
Evaluate the condition and then evaluate the true or false branch based on the result. I.e: if the condition evaluate to nil, evaluate the false branch.
Takes 2 argument and compare them for equality. If the types are different, return false, unless they're different number types. Compare numbers by value: Integer value to integer value if both integer. If integer and rational than always return false. If one is a double, the other argument is to be converted to double and then compared. Rationals are to be compared numerator to numerator and denominator to denominator.
Compare the first number with the second and return true if it's less than.
Compare the first number with the second and return true if it's greater than.
Compare the first number with the second and return true if it's less than or equal.
Compare the first number with the second and return true if it's greater than or equal.
Takes 2 argument and compare them for inequality. Compare
Return nil if no arguments.
Return an error if more than 2 arguments.
Return an error if not a cons.
Return an error if not a cons.
Takes nothing, NIL, T or a stream, anything else return an error. If nothing, NIL or T use the standard-input stream as the stream. Return the first character without increasing the reading pointer in the stream.
Takes nothing, NIL, T or a stream, anything else return an error. If nothing, NIL or T use the standard-input stream as the stream. Return the first character while increasing the reading pointer in the stream.
Takes a character and a function. The later takes in a character and a stream and return a value.
Takes nothing, NIL, T or a stream, anything else return an error. If nothing, NIL or T use the standard-input stream as the stream. Return the first character while increasing the reading pointer in the stream.
Takes 1 argument of anything and evaluate it and return the result.
Therefore preventing any evaluation of it.
Takes a symbol and anything else. More than 2 arguments result in an error.
It goes from the local environmnet outward trying to find a binding on the symbol and if it doesn't then it bind it in the global env.
If it's a string return it. If it's a symbol, create string from it's text value. If it's a character, create string from it. If it's a number, create the string representation of it. If it's a list or array, concactenate it's content string representation. i.e (string '(\h \e \l \l \o)) => "hello" Return an error on anything else. I.e hash-table, function...
Takes anything or nothing and create an array with the arguments in it. (array 1 2 3 4) => [1 2 3 4]
Takes anything or nothing and create an hash-table with the arguments splitted in pairs. The first element of a pair is the key and the second is the value. Return an error if odd number of arguments.
If the collection is a string, convert the element to string and append it. If the collection is a list, append the element to the end of it. If the collection is an array, append the element to the end of it. Else return an error.
If the collection is a string, reduce it's length by 1 and return the last character. Handle UTF-8 character so that if the last byte of the string is part of an UTF-8 character, reduce the length until you get the header, and return the UTF-8 character. If the collection is a list, set the cdr of second to last pair to nil and return the last element. If the collection is an array, reduce the length by 1 and return the last element. Else return an error.
Let you insert into list, string, array and hash-table. Takes a number position for a list, string, array or anything as key for an hash-table. Takes anything as value to be inserted.
Let you retrieve an element into list, string, array and hash-table. Takes a number position for a list, string, array or anything as key for an hash-table. Return undefined if nothing is found.
Write in a way that the reader could make sense of the result. Useful for writing to a file to be read from later on, or just debugging.
Write a byte into a stream.
Read a byte from a stream.
Useful for user messages.
The last evaluation is to be returned.
If anything but a string, list or array return an error. Accepts only 1 argument.
Takes a list of key value list and a body. Creates a new environment table and insert for the key, the evaluated value. Reuse this new environment table for the next key, value pair. Making it that the key, value of the previous pair can be used to eval the current one. Then eval the body, one expression after the other using the new local environment and return the result of the last expression.
Inline in a list by changing the cdr of the previous pair to result and the cdr of the last cons in result to be the cdr of the previous cons before the change. i.e (quasiquote 1 2 3 (unquote-splicing (list 4 5)) 6) => (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 (cons 6 nil))))))
Create a list by reading elements after elements until a \) is encountered.
Return a error because there shouldn't be a closing bracket without a begining.
Quote the following read. I.e 'hello => (quote hello)
Create an array by reading elements after elements until a \] is encountered.
Return a error because there shouldn't be a closing bracket without a begining.
Create an hash-table by reading elements after elements until a \} is encountered.
Return a error because there shouldn't be a closing bracket without a begining.
Quasiquote the following read. I.e `hello => (quasiquote hello). But also create the \, reader-macro and remove it after the following read.
Is created and removed by \`. Unquote or unquote-splicing the following read. I.e ,hello => (unquote hello) ,@'(1 2) => (unquote-splicing '(1 2))
The idea of the garbage collector is to iterate through the blocks in memory and marking them as free. Then navigate the global environment to mark everything in it as used (not free). And finally reiterate through the blocks again to then actually free them. It's probably a naive implementation, but it's better than nothing. It will run when something is to be allocated and according to a certain interval. Maintain a counter that decrease by an amount relative to the percent of memory used. If the counter goes below zero, run the garbage collector and reset the counter.
This optimisation will be done in the evaluator. The goal is to detect when a function is calling it self in tail position. And to achieve this, on function evaluation on the last item of the body navigate through those constructs if existant: LET, IF, AND, OR and DO. And when we navigate through those construct we're looking for the tail call of them. I.e LET, AND, OR and DO is the last expression, IF is the true or false path. And when after that navigation we end up on call to the function currently being evaluated then we can optimise. The optimisation will consist in updating the environment with the new argument values to be passed to the function and instead of calling eval on it, just execute a jump to the start of the current function evaluation. In the eye of the user nothing will happen, but it will prevent that the stack based host pulls out a stack overflow. There might be a boost in performance, but it's probably minimal.