Linisp

Functions
Login

As a dialect of Lisp, Linisp uses builtin functions where other languages would use key-words and operators. However the specific set of functions are designed to feel more familiar to someone coming from a background of C and Unix shell.

Comparison functions

==

Arguments:

Return-type: Number

Use: Checks if two values are equal, returns 1 if they are or 0 if they are not.

!=

Arguments:

Return-type: Number

Use: Same as == but with the return value reversed.

<

Arguments:

Return-type: Number

Use: Checks if X is a smaller number than Y, returns 1 if it is or 0 if it is not

>

Arguments:

Return-type: Number

Use: Same as < but with the return value reversed.

<=

Arguments:

Return-type: Number

Use: Checks if X is a smaller than or equal number to Y, returns 1 if it is or 0 if it is not

>=

Arguments:

Return-type: Number

Use: Same as <= but with the return value reversed.

Flow control and program structure functions

if

Arguments:

Return-type: Any type

Use: Branching. If the Condition argument is non-zero the True clause argument is converted to an S-Expression and evaluated. Else, if the Condition argument does equal zero the False clause is evaluated. The return value of if is the result of the evaluated Q-Expression.

exit

Arguments:

Return-type: Not applicable

Use: Terminates the program with a given exit status. A status of 0 indicates that the program finished successfully, any other value is considered an error code.

include

Arguments:

Return-type: Empty S-Expression

Use: Import functions and variables from other files.

NOTE: At present paths are either absolute or relative to the user's current working-directory. In future a default search path will be implemented.

Declaration functions

=

Arguments:

Return-type: Empty S-Expression

Use: Declaring variables and functions in the local namespace. Names for them are provided by the values in the Names argument. Multiple variables / functions can be declared at one time.

export

Arguments:

Return-type: Empty S-Expression

Use: Same as = except that the variables / functions are assigned to the global namespace.

error

Arguments:

Use: Creates a string that represents an error condition. Such strings are not equal to regular strings regardless of their content.

Note: At present simply creating an error string will force a program to exit. This is likely to change in future versions.

list

Arguments:

Use: Returns a Q-Expression containing the arguments that have been passed to it.

\x

Arguments:

Use: Creates a new, unnamed, function. Use function from stdlib instead to create a named function or use \x in conjunction with either = or export.

NOTE: The name of this function is chosen to resemble the Greek letter Lambda (λ) in honour of the mathematical field Lambda-Calculus which inspired Lisp.

Type-checking functions

isSymbol

Arguments:

Return-type: Number

Use: Check if a value is of the symbol type.

isNumber

Arguments:

Return-type: Number

Use: Check if a value is of the number type.

isSExp

Arguments:

Return-type: Number

Use: Check if a value is of the Symbolic-Expression type.

isQExp

Arguments:

Return-type: Number

Use: Check if a value is of the Quoted-Expression type.

isFunc

Arguments:

Return-type: Number

Use: Check if a value is of the Function type (either a built-in of a lambda-value).

isString

Arguments:

Return-type: Number

Use: Check if a value is of the string type.

isError

Arguments:

Return-type: Error

Use: Check if a value is of the error type.

Arithmetic functions

+

Arguments:

Return-type: Number

Use: Adds together two or more numbers. If given only one number as an argument that number is returned, unaltered.

-

Arguments:

Return-type: Number

Use: Sequentially subtracts numbers from each other. If only given one number as an argument it returns that number with the sign inverted.

*

Arguments:

Return-type: Number

Use: Multiplies together two or more numbers. If given only one number as an argument that number is returned, unaltered.

*

Arguments:

Return-type: Number

Use: Sequentially divides numbers by each other. If given only one number as an argument that number is returned, unaltered.

String manipulation functions

strlen

Arguments:

Return-type: Number

Use: Returns the length of a given string

Input/Output functions

display

Arguments:

Return-type: Empty S-Expression

Use: Prints one or more values separated by ' ' characters followed by a new line.

gets

Arguments:

Return-type: String

Use: Returns a string of up to count characters from stdin.

getenv

Arguments:

Return-type: Either String or Empty S-Expression

Use: Returns the textual value of an environment variable named name or an empty S-Expression if it has not been set.

setenv

Arguments:

Return-type: Empty S-Expression

Use: Sets the environment variable name to equal value. Note that the third argument overwrite must be set to a non-zero value in order to change an already defined environment variable.

unsetenv

Arguments:

Return-type: Empty S-Expression

Use: Removes name from the script's available environment variables.