Do while true

From Esolang
Jump to navigation Jump to search

Do while true is an esolang, where every line is an expression.

Syntax

There is a stack.

Every line is an expression in postfix notation (1$2$- equals -1) and evaluated from left to right ($72$o$105$o-No prints Hi! and equals -33).

The intepreter first does that line and get the evaluated value, and then runs it until the evaluated value is 0.

Every negative or 0 value is treated as 0, else they're treates as 1.

Notes:

  • the syntax sugar $abc$ means the number abc.
  • #x means argument x.
  • EOF returns -1, and the integers are unbounded.
Caption text
Command Descriprion
i gets input, evaluates to input.
N change the sign of #1
o output #1 and returns it
1 returns a 1
> returns 1 if #1>#2 else 0
~ returns 1, discards #1
: duplicate and return top of stack
< push #1 onto the stack and returns #1
- returns #1 - #2
! returns and discards top of the stack
@ anything beyond that is a comment
S swaps top two stack elements, returns 0
^ rotate the stack up, returns a 0
= pop a list of numbers ending with 0 off-stack. convert them to strings. defines function number #1 to be the converted string as DWT code. returns #1
Z run function #1. returns #1.
h halt. "returns" 0.

Examples

Hello, World!

$72$o$101$o$108$o$108$o$111$o$44$o$32$o$87$o$111$o$114$o$108$o$100$o$33$o------------~1-

Truth-machine

i<~1-
:o$48$-

Cat program

io

Self intepreter

i<:-^-|1-~
1=1Z-h-

Prime checker

requires integer input.

TBD