The ALTernative Language
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage


This example shows the implementation of the Fibonacci sequence, that applies a novel iteration scheme that is unique to ALT.

Note that ALT deliberately eschews loops but does allow a limited form of bounded recursion via the use of iota and (domain) scopes. So how would one implement the Fibonacci sequence in ALT? Here is an explicit version of Fibonacci up until 6:

Fib (1)

Unfortunately, there is a lot of repetitive code, but luckily that code can be removed by applying domain scope @ references. Remember, a domain scope reference points to the nearest key that is left to the value of a pair.

Fib (2)

Finally, redundancy can be further removed by using concatenate +, the iota n! operator, and map :: :

Fib (3)

Code golf?

The above code may look like code golf (or line noise) to some, but is pretty concise otherwise. Of course it is a matter of taste whether you agree with that statement or not.