Phitrafunck
Phitrafunck is an esolang designed by User:cleverxia and User:yayimhere, based on the Phi combinator, Utral, the functional paradigm, and brainfuck.
Commands
Phitrafunck works on a infinite tape with functions, starting with the identity function λx.x. Beta-reduction will not happen automatically.
| command | meaning | Notes |
|---|---|---|
+ |
apply current cell to the φ combinator λa.λb.λc.λd.a(b d)(c d) |
|
- |
remove the first parameter of current cell (like the () in Utral) | eg. applying - on λa.λb.λc.a(c b a)c(a c(a b)) returns λb.λc.(c b)c(c(b))=λb.λc.c b c(c b)when this operation would make the lambda body empty, the cell will be reset to the identity function. eg. applying - on λa.λb.λc.a(a a) would return λb.λc.[empty], so the cell is reset to the identity function.
|
< |
Move the pointer to the left | moving out-of-bounds is an error |
> |
Move the pointer to the right | |
[...] |
loop while cell is not exactly the identity function | λa.λb.a bacts same as the identity function, but it isn't the exact function.also, (λa.λb.λc.(a c)(b c))(λa.λb.a)(λa.λb.a) beta-reduces to the identity function, but beta-reduction isn't automatic here, so this isn't exactly the identity function.
|
, |
input a character as a church numeral, increment it, and store in current cell. unchange on EOF | |
. |
if current cell is a church numeral then output the value of it minus 1 as a character, otherwise outputs the expression in cell as is. |
(λa.λb.λc.(a c)(b c))(λa.λb.a)(λa.λb.a) still counts as a church numeral for 1, although its'nt beta-reducednote that without wimpmodes, we can't get a K, so we can't have the church numeral for 0. |
β |
beta-reduce current cell | beta-reduction isn't automatic here |
Wimpmode(s)
Phitrafunck has 3 wimpmodes that make it easier to use as a functional language. These aren't a "part of the language", but they are still there. The first wimpmode is order-1, the second is order-2, and the 3rd is order-3. Order-(x+1) is a superset of order-x.
| command | meaning | Notes |
|---|---|---|
K (wimpmode only) |
apply current cell to K combinator | |
S (wimpmode only) |
apply current cell to S combinator | |
A ((2+)-wimpmode only) |
apply current cell to next cell | |
L ((2+)-order wimpmode only) |
loads the library. | Why not use unlambda if you need 2-order wimpmodes? |
the library is made up of the following shorthands
≮X|Y≯ means X runs Y times _ --> -β / --> [_] (x) --> +[x] B --> [β] =n; --> /≮+|n≯ (here, n is any integer) =1`n; --> /≮+-β|n≯ =2`n; --> /≮+--β|n≯ ≈ --> (_<+>)<_
and the following commands
# Starts a comment
$ swaps current cell with register(initially the identity function)
{x} applies current cell with the combinator named x
☾x|abcd...☽ defines a shorthand x=abcd...
ㅑx|a|b|c|...ㅕ defines a combinator called x, taking arguments a,b,c, and evaluated to the "...". (for order-3 only)
(eg. ㅑx|a|b|c|a c(b c)ㅕ defines the S combinator; ㅑx|a|b|aㅕ defines the K combinator)
╞a|b|c|...╡ same as ㅑx|a|b|c|...ㅕ, but the combinator has no name (this is an inline combinator),
current cell is directly applied to it, and arguments starts straight at the 1st section. (for order-3 only)
(eg. ╞a|b|c|a c(b c)╡ is the S combinator; ╞a|b|a╡ is the K combinator)
Computational class
Turing-complete. Brainfuck minus - is turing complete, and since you don't need I/O, and you can just use "+" for "+" as is, thus phitrafunck is turing-complete.
Examples
outputs null byte
.
Cat program
+[>,.<]