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.”
Variable exponents can also be used, which gives the language its unusual expressiveness: x^y in a fraction means “as many xs as there are ys in the bag right now”, with the exponent resolved at runtime.