Lacc
Jump to navigation
Jump to search
Lacc, originally inspired by a chat with User:Waffelz, is a stack based language, and as such imperative language, with only one way of doing control flow: a version of the call/cc operator, normally only used in functional programming languages. it was devised by User:Yayimhere
Command set
Lacc uses a few, very basic, commands:
cc: push the current state of the program to the stack, including the stack *at that point* çç: run the top of the stack, replacing the current program AND stack with the new one pp: pop the second to top element of the stack, and push the the top of the top of the stacks stack rr: move bottom of stack to the top bb: push the second to top of the stacks stack content to the the stack of the top elements stack dd: duplicate the top of the stack [x: do command x until x has been ran number of elements on stack-1 times
So an example of a very simple loop could be:
ccçç
because of the fact that cc is at the start of the code, the thing being ran is just the program at its starting state. A looping counter (which technically does powers/multiples of 2) could be:
ccdd[pçç
heres what happens:
cc: push program with current state(empty stack) to the stack. lets call this element 1. dd: duplicate 1. [p: push to 1's stack all elements but 1(remember the -1) çç: run 1 with stack state: 1,1 cc: push 1 to stack again, so the stack is 1,1,1 dd: duplicate, becomes 1,1,1,1 [p: put all the 1's but a singular one into 1's stack çç: run that, now with stack 1,1,1,1
which goes on forever.