Triski

From Esolang
Jump to navigation Jump to search

Triski is a language inspired by SKI calculus, along with the I/O system from Hot.

Combinators

s x y z = x z (y z) # only in first row
k x y   = x         # only in second row
i x     = x         # only in third row
d x     = x
p x y   = x | y     # if next input bit = 0, remove y, otherwise, remove x
z x     = x         # add '0' to output string
o x     = x         # add '1' to output string
v x     =           # set x as this row's value
a x     =           # set x = the value of the (the number of variables/combinators in this row mod 3 + 1)-th row
                    # if the row isn't assigned a value, x = x

Once a row is empty or doesn't have enough variables, the initial copy is added to that row. Example:

s (s s) s s s
d d d
o z o o o z
  ->
s s s (s s) s
d d
z o o o z
  ->
s (s s) (s (s s)) s
d d d d
o o o z
  ->
s s s (s (s s) s)
d d d
o o z
  etc.

If multiple z and o are executed at the same time on different lines, the execution order is 1st line -> 2nd line -> 3rd line.
The output string is cut into crumbs (groups of 2 bits). If a crumb starts with 1, the final bit is outputted. If it starts with a 0, outputting is halted.


Example programs

Truth-machine

p (v z) (v o) a i v (s i i) s i i (s i i)
d d d d d d d d o z
v i a l o l l o d d a m m m

Hello, world!

o
z o z z o z z z z o o z z o z o z o o z o o z z z o o z o o z z z o o z o o o o z z o z o o z z z z o z z z z z z o o o z o o o z o o z o o o o z o o o z z o z z o o z o o z z z o o z z o z z z z o z z z z o 
d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d z

SKI Translation

d a k a i ...
v k
v i

... is any SKI formula padded with ds. The formula has to be a multiple of 3 long, so S(SKI)(SKS) would become d d s (s k i) (s k s).