Lambdastack

Lambdastack is stack based esolang created by User:EzoLang.
==Commands and syntax==
Commands:
 ? (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:
 Stack:
 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
 Code:
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:
 Stack:
 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:
And:
 Stack:
 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: '
 
 Stack:
 Code: 10[ax:x]
 
 Stack: 1,0
 Code: [ax:x]'
 
 Stack: 1,0,[ax:x]
 Code: '
 
 Stack:
 Code: 0
 
 Stack: 0
 Code:
Lambdas can also be used as parameters for other lambdas:
 Stack:
 Code: [f:ff"'][f:ff"']"'
 
 Stack: [f:ff"'],[f:ff"']
 Code: "'
 
 Stack: [[f:ff"'][f:ff"']"']
 Code: '
 
 Stack:
 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
==Examples==
===Y combinator===
 [%f:%ff']`Y
Usage:
 [vars(self):lambda(self)']Y'
===While loop===
 [%f:%f[%f(self):%f'f(self)[x:][xfab:fabx]'?'][%f:%ff']']`(While)
Usage:
 [vars:lambda](While)'
===Lists===
List:
 [12345]
Append to end:
 [lx:l'x[%:%]"]`(Append)
Example:
 [1234]5(Append)'=>[12345]
First element:
 [l:l'[x%:x]']`(car)
Example:
 [12345](car)'=>1
List without first element:
 [l:l'[x%:%]"]`(cdr)
Example:
 [12345](cdr)'=>[2345]
==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
~ 	[xy:yx]'
: 	[x:xx]'
! 	[x:]'
( 	[%:%
) 	]
a 	[x:x]"
^ 	'
==Implementations==
Implementations for this language can be found below
* SPK44's Implementation
==See also==
* Lambda calculus
* Combinatory logic
Category:Languages Category:Stack-based Category:Turing complete Category:Implemented Category:Unknown year