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:
- X Any type
- Y Any type
Return-type: Number
Use: Checks if two values are equal, returns 1 if they are or 0 if they are not.
!=
Arguments:
- X Any type
- Y Any type
Return-type: Number
Use: Same as == but with the return value reversed.
<
Arguments:
- X Number
- Y Number
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:
- X Number
- Y Number
Return-type: Number
Use: Same as < but with the return value reversed.
<=
Arguments:
- X Number
- Y Number
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:
- X Number
- Y Number
Return-type: Number
Use: Same as <= but with the return value reversed.
Flow control and program structure functions
if
Arguments:
- Condition Number
- True clause Q-Expression
- False clause Q-Expression
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:
- Status Number
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:
- Path String
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:
- Names Q-Expression of Symbols
- Value 1 Any type
- ... Any type (optional additional 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:
- Names Q-Expression of Symbols
- Value 1 Any type
- ... Any type (optional additional arguments)
Return-type: Empty S-Expression
Use: Same as = except that the variables / functions are assigned to the global namespace.
error
Arguments:
- Message String
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:
- ... Any type (optional)
Use: Returns a Q-Expression containing the arguments that have been passed to it.
\x
Arguments:
- Parameters Q-Expression of symbols
- Body Q-Expression of S-Expressions
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:
- Value Any type
Return-type: Number
Use: Check if a value is of the symbol type.
isNumber
Arguments:
- Value Any type
Return-type: Number
Use: Check if a value is of the number type.
isSExp
Arguments:
- Value Any type
Return-type: Number
Use: Check if a value is of the Symbolic-Expression type.
isQExp
Arguments:
- Value Any type
Return-type: Number
Use: Check if a value is of the Quoted-Expression type.
isFunc
Arguments:
- Value Any type
Return-type: Number
Use: Check if a value is of the Function type (either a built-in of a lambda-value).
isString
Arguments:
- Value Any type
Return-type: Number
Use: Check if a value is of the string type.
isError
Arguments:
- Value Any type
Return-type: Error
Use: Check if a value is of the error type.
Arithmetic functions
+
Arguments:
- First argument Number
- ... Number Optional additional 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:
- First argument Number
- ... Number Optional additional 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:
- First argument Number
- ... Number Optional additional 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:
- First argument Number
- ... Number Optional additional 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:
- s String
Return-type: Number
Use: Returns the length of a given string
Input/Output functions
display
Arguments:
- ... Any type
Return-type: Empty S-Expression
Use: Prints one or more values separated by ' ' characters followed by a new line.
gets
Arguments:
- count Number
Return-type: String
Use: Returns a string of up to count characters from stdin.
getenv
Arguments:
- name String
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:
- name String
- value String
- overwrite Number
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:
- name String
Return-type: Empty S-Expression
Use: Removes name from the script's available environment variables.