Freu
Freu is an interpreter for the Rejoice programming language by Devine Lu Linvega, written in OCaml. Its name comes from the German expression "sich freuen", meaning "to rejoice".
You can find the source code in my Git forge.
Rejoice is a concatenative programming language where state is represented as a multiset of elements, and computation happens by transforming that multiset using fractions.
The program's entire state lives in a multiset (or bag), an unordered collection that can hold integers and named symbols. Symbols are internally mapped to prime numbers in order of appearance.
Transformations are represented by fractions where the denominator determines what to consume from the bag, and the numerator what to add to the bag. An expression like owl/[cat^2] can be read as "if the bag contains at least two of cat, remove them and add one owl."
( Put a marble in the bag )
marble
( Put three more marbles in the bag )
marble^3
( Trade each marble for a coin )
'coin/marble
( Discard two coins )
[]/coin^2
Variable exponents can also be used: x^y in a fraction means "as many xs as there are ys in the bag right now", with the exponent resolved at runtime.
Labels can be created with the syntax @Label. Fractions that add a label's name to the bag will jump to the program counter at that label after the computation happens.
Anonymous labels can be created by prefixing a fraction with a comma. These will loop while the computation of the fraction is allowed to happen.
@Gcd ( x y -- x )
'z/[x y]
[y^x x^z]/[x^x z^z]
[Gcd y]/y