slistp

From Esolang
Jump to navigation Jump to search

slistp is small list processing programming language. Data is only lists and numbers (integers). Lists can contain lists and numbers. Functions are also represented as lists.

All numbers in the syntax are separated by semicolons and lists are delimited by square brackets.

Macros can also be specified by the name and an equal sign and then the definition and a semicolon. Macros can define other macros, but these are processed only during the preprocessor stage. Macros defined inside of a list are local to that list (again, only during the preprocessor stage).

Strings can be specified in quotation marks and they act the same as a list of their ASCII numbers.

"#" mark denotes a comment up to a line break.

The program is given as a list, which is a function. Each function takes one parameter and returns one value, which is the current value. Also each function has one auxiliary value which is initialized to the second element of the function list when the function is started. (The first and second elements is not used as a command.)

Commands:

  • 0 = No operation.
  • 1 = Add together all numbers in the current list (recursively).
  • 2 = Multiply together all numbers in the current list (recursively).
  • 3 = Calculate the average of all numbers in the current list (recursively), rounded down.
  • 4 = Enclose the current value in a list of one element.
  • 5 = Swap the current value with the auxiliary value.
  • 6 = Make the current value into a list with two elements, the first being the old current value and the second being the auxiliary value.
  • 7 = Loop to the beginning of the function outer of this one, using the current value of this function as that function's current value.
  • 8 = Execute the command from the auxiliary value.
  • 9 = Unthrow, or exit this function if the current position in this function is not from a thrown exception. When you unthrow the current value will change to this function's current value.
  • Even numbers greater than 9 = Mark a point to catch thrown exceptions.
  • Odd numbers greater than 9 = Throw an exception to the number one less than this one, this function's current value becomes the result and that function continues from the thrown part.
  • Negative numbers = Add this number to the auxiliary value or all elements of the auxiliary value.
  • List = If the first element of this list is a list not containing any copy of the current value, and the current value is a list, run that function on the elements of the current value, with the parameter being a list containing the list index (zero-based) as its first element and the value of the element being processed as the second element, with the return values which are lists being concatenated together in order to determine what the new current value will become.