Combinators

Concatenative Combinators

Concatenative combinators provide an alternate means of stack manipulation from using as, which is analogous to the lambda in FP. Concatenative combinators excel in writing point-free code, and are useful as a terse means for gluing together functions, particularly higher-order ones. All concatenative combinators are RPN, by definition.

While languages like Joy implement and give names to many of these operators (See Theory of concatenative Combinators), we use a streamlined, terse, reduced set for these operations.

There are 4 main categories of concatenative combinators, which form a sufficiently expressive basis:

  • ^ (Dup), placing a copy of the top value on top of the stack.
  • _ (Zap), destroying the top value of the stack.
  • % (Swap), swapping the first and second values on the stack.
  • $ (Call), running the top value of the stack, unwrapping quotations { ... }.

In addition to these 4, we have generalized forms for each of them. The numbers that follow the operators must be an actual sequence of digits. The top of the stack is element 1, the second is element 2, and so on.

  • ^N Copy the Nth element of the stack, and put it on top.
  • _N Delete the Nth element of the stack.
  • %3 Rotate, putting the 3rd element on top.
  • $N Call the Nth element of the stack.

Recursive Combinators

Prowl imports ideas from Joy, including more complex combinators to express complicated ideas shortly and succintly.

None of these are implemented at this time - this section will be written after they are.