From Esolang
Jump to: navigation, search

Lambdastack is stack based esolang created by User:EzoLang.

Commands and syntax


?              (a,b,x)->(a/b)          Pop a, b and x. Then execute If (x) { Push a } Else { Push b }
0-F            ()->(n)                 Push hexadecimal digit to stack
(00)-(FF)      ()->(n)                 Push a byte to stack
('c)           ()->(n)                 Push ascii value of char c
(var), var     ()->(a)                 Push content of variable var to stack. If var is not defined it pushes nothing.
[vars:code]    ()->(f)                 Define lambda with input
[code]         ()->(f)                 Define lambda with no input
'              (f)->(),(n)->()         Pop and execute lambda f or Pop number and use it as bitwise operator (with lambdas "' has the same effect as ')
"              (f)->(f), (n)->(f)      Convert lambda with input or number to lambda with no input (5[x;0Fx?]"->[0F5?]) (5"->[5]). If it is used with lambda with no input it does nothing.
`var           (a)->()                 Pop a and store it to global variable var
I              ()->(n)                 Input a byte
O              (n)->()                 Pop and output a byte

If variable name is not inside parentrheses it can only be one ascii char but if it is it can be as long as you want. Variable can't have name ?,(,),[,],:,',",I,O or numbers 0-F or 00-FF and can't start with '. Lambdas with input work by popping as many values from stack as needed and storing them to local variables. Variables are not separated by any symbols. New stack will be created for lambda when it is executed. When lambda definition has variable % rest of stack will be stored to it(012345[%a:%]'->01234, 012345[a%b:%]'->1234, 12[a%b:%]->). For example:

Code: 012345[xy(foo)(bar)a:(foo)(bar)xa]'

Stack: 0,1,2,3,4,5
Code: [xy(foo)(bar)a:(foo)(bar)xa]'

Stack: 0,1,2,3,4,5,[xy(foo)(bar)a:(foo)(bar)xa]
Code: '

Stack: 0
Code: 3415

Stack 0,3,4,1,5

Local variables can only be used on the lambda that had them on it's definition. Other lambdas even inside other lambdas can use local variables with same name. For example:

Code: 123[xy:xy0[z:xyz]"']'

Stack: 1,2,3,[xy:xy0[z:xyz]"']
Code: '

Stack: 1|
Code: 230[z:xyz]"'

Stack: 1|2,3,0
Code: [z:xyz]"'

Stack: 1|2,3,0,[z:xyz]
Code: "'

Stack: 1|2,3,[0]
Code: '

Stack: 1,2,3,0


Code: 1[x:x0[ax:x]']"'

Stack: 1
Code: [x:x0[ax:x]']"'

Stack: 1,[x:x0[ax:x]']
Code: "'

Stack: [10[ax:x]']
Code: '

Code: 10[ax:x]

Stack: 1,0
Code: [ax:x]'

Stack: 1,0,[ax:x]
Code: '

Code: 0

Stack: 0

Lambdas can also be used as parameters for other lambdas:

Code: [f:ff"'][f:ff"']"'

Stack: [f:ff"'],[f:ff"']
Code: "'

Stack: [[f:ff"'][f:ff"']"']
Code: '

Code: [f:ff"'][f:ff"']"'

When hexadecimal digit or byte is executed it is used as a bitwise operator. When bitwise operator is used on lambdas it does nothing. Byte is split to two hexadecimal digits and execute so abc(66)'=abc6'6'

hexadecimal digits (two inputs named a and b. Operation is applied to every bit of the input)

0 False
1 !a&!b
2 !a&b
3 !a
4 a&!b
5 !b
6 a xor b, !a xor !b
7 !a|!b
8 a&b
9 !a xor b, a xor !b
A b
B !a|b
C a
D a|!b
E a|b
F True


Y combinator




While loop







Append to end:




First element:




List without first element:




Computational class

Lambdastack is Turing-complete because all Underload commands other than * and S can be translated to it ( :!()^ is a turing complete subset):

Underload Lambdastack

See also