Kipple programming language
|
Kipple is a minimalistic, but Turing-complete programming language which consists of a set of stacks, four operators and a control structure.
Contents |
Overview
The stacks are named a-z and contain 32-bit signed integers. The operators are > or < (push), + (add), - (subtract) and ? (clear). The program's input is pushed onto stack i before execution, and the contents of stack o is popped to standard output when the program is complete. There is also a special stack @ which makes outputting numbers more convenient. When a program tries to push a value onto stack @, the ASCII values of each of the value's digits are pushed onto it instead.
Operators
a>b will pop stack a, and push the value onto stack b. b<a will do exactly the same.
42>a will push the number 42 onto stack a.
a+2 will take the topmost value of stack a, add 2 to it, and push the result onto stack a.
a-5 will take the topmost value of stack a, subtract 5 from it, and push the result onto stack a.
a? will clear stack a if the topmost value of stack a is 0.
The control structure
(a [code]) will repeat the code inside the parentheses as long as stack a is not empty. Loops may be nested.
Examples
Hello World
Prints "Hello World!":
33>o 100>o 108>o 114>o 111>o 87>o 32>o 111>o 108>o 108>o 101>o 72>o
Input/Output
A program that simply outputs its input (i.e. the linux command cat):
(i>o)
Fibonacci numbers
A program that outputs the first 25 Fibonacci numbers:
24>n 0>t 1>a (n-1 a+0 t<a>b+a c<b>a<c n? ) (t>@ (@>o) 32>o )
See also
External links
- The Kipple home page (http://rune.krokodille.com/lang/kipple). Contains full specification, sample programs, and an online interpreter.ko:Kipple (프로그래밍 언어)