Ampell
Jump to navigation
Jump to search
Description
Ampell is a small stack-based programming language I made
Syntax
Ampell code | Meaning |
---|---|
&[value] | Push value onto stack (can be number, text, or var) |
^"question"~var | Input from user, assign response to variable var |
% | Remove (pop) top of stack |
$ | Print top of stack (without removing it) |
>>var | Store top of stack value in variable var |
+ | Peek top 2 values, add them, push result |
− | Peek top 2 values, subtract (2nd - top), push result |
× | Peek top 2 values, multiply, push result |
÷ | Peek top 2 values, divide (2nd / top), push result |
=[logic] | Peek top 2 values, if 2nd equals top, execute logic block |
![logic] | Peek top 2 values, if 2nd not equals top, execute logic block |
<[logic] | Peek top 2 values, if 2nd less than top, execute logic block |
>[logic] | Peek top 2 values, if 2nd greater than top, execute logic block |
@functionName[logic] | Start function definition named functionName |
functionName: | Call function named functionName |
\[stack name] | Change to or create stack (default stack is "main") |
Note that for &["string"] and ^"question"~var, if the string in question has a quote " inside of it, you do not need to specify that it is literal
Whitespaces will be ignored by the interpreter except for strings
Example programs
Hello, world!
&[Hello, world!]$
Truth machine
^"i need number"~a&[a]&[0]@loop[$loop:]=[$]![%loop:]
Basic adder
^"a="~a^"b="~b&[a]&[b]+$
Prints "hi" how many times you want
^"how many times would you like to print "hi"?"~f&[0]&[f]@hi[![&["hi"]$%&[1]->>f%%%&[f]hi:]]hi:
Simple fork bomb
@f[f:f:]f:
Cat
@cat[^""~a&[a]$cat:]cat:
Interpreters
You can find the Python interpreter for Ampell here.