JL Function Reference

The following functions are predefined within JL.

FunctionDescription
+ Sum a list of numbers. This function takes zero or more arguments. With zero arguments it returns 0.
- Subtract. This function takes one or more arguments. The first argument is the value from which to subtract, and the remaining values are subtracted from the first value.
* Multiply. This function takes zero or more arguments and returns the product. With zero arguments it returns 1.
/ Divide. This function takes two arguments and returns the value of the first argument divided by the second.
= Test for equality. This function takes two arguments of any type and returns 1 if (structurally) equal, otherwise it returns nil.
!= Test if not equal. This function takes two arguments of any type and returns nil if (structurally) equal, otherwise it returns 1.
> Test if greater than. This function takes two arguments of any type and returns 1 if the first argument is greater than the second, otherwise it returns nil.
>= Test if greater than or equal. This function takes two arguments of any type and returns 1 if the first argument is greater than or equal to the second, otherwise it returns nil.
< Test if less than. This function takes two arguments of any type and returns 1 if the first argument is less than the second, otherwise it returns nil.
<= Test if less than or equal. This function takes two arguments of any type and returns 1 if the first argument is less than or equal to the second, otherwise it returns nil.
and Logical AND. This function returns 1 if all of its arguments return a true value. Otherwise it returns nil. If no arguments are supplied, it returns 1. Arguments are evaluated from left to right and evaluation stops as soon as a false value is encountered.
begin Evaluate a sequence of expressions in a new scope and return the result of the last expression. If no expressions are supplied, this function returns nil.
concat Concatenate strings. This function takes one or more strings and concatenates them.
cons Construct a list. This function two arguments and prepends the first argument to the list in the second argument. The second argument must be either a list or nil.
define Insert a binding into the current scope. This function takes two arguments: the first argument is the name of the binding and the second argument is the value. Note that new scopes are created using begin and lambda. If a binding has the same name as an existing binding, the existing binding is replaced in the current scope.
head Return the first item of a list. This function takes a list as its argument.
if Conditional. This function will evaluate its first parameter. If the result is true, it returns the result of evaluating its second parameter, otherwise it returns the results of evaluating its third parameter.
lambda Create an anonymous function. The first argument to this function is a list of parameters to the function. The remaining arguments are expressions to be evaluated when this lambda is evaulated.
list Create a list. This function takes zero or more arguments and returns a list containing them.
list? Determine if a value is a list. This function takes one argument and returns 1 if it is a list, otherwise it returns nil.
mod Modulus. This function takes two number arguments and returns the remainder after integer division of the first argument divided by the second argument.
not Logical NOT. This function takes one argument and returns nil if it is true, otherwise it returns 1.
null? Determine if a value is nil. This function takes one argument and returns 1 if it is nil, otherwise it returns nil.
number? Determine if a value is a number. This function takes one argument and returns 1 if it is a number, otherwise it returns nil.
or Logical OR. This function returns 1 if any of its arguments return a true value. Otherwise it returns nil. If no arguments are supplied, it returns nil. Arguments are evaluated from left to right and evaluation stops as soon as a true value is encountered.
rest Return the rest of the list. This function takes one list argument and returns all but the first item.
string? Determine if a value is a string. This function takes one argument and returns 1 if it is a string, otherwise it returns nil.
substr Substring. This function takes a string parameter, an optional second (number) parameter, and an optional third (number) parameter. If a second parameter is provided, the second parameter is the start of the string to be returned (zero-based). If a third parameter is provided, the third parameter provides the maximum length of the string to be returned.