Ampell

From Esolang
Jump to navigation Jump to search

Description

Ampell is a small stack-based programming language.

Syntax

Ampell Syntax Commands
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

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 because the (future) interpreter will only count the very first and last quotes

Whitespaces will be ignored by the (future) interpreter

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]->>nf%%%&[f]hi:]]hi:

Simple fork bomb

@;[;:;:];:

Interpreters

As of now, there are no available interpreters for Ampell, but one may be available sometime later