Imperative

From Esolang
Jump to navigation Jump to search

Imperative is a minimalist language invented by User:A designed to fit into the definition of an imperative language.

Definition

1.Imperative programming

Most imperative languages support the following instructions: (1)Arithmetic commands (2)Looping commands (3)Conditional statements (4)Unconditional branches

Examples

Demonstration of conditional statements, unconditional branches, and arithmetic commands.

a=1-1
go a*3--3

Execution:

1/0
3/0
6/3

So this jumps to either line 3(when 1 equals 1) or line 6(when 1 does not equal 1).

Looping

b=1
do {
    a=1
} while(b==1)

Implementation:

b=1
a=1
go(b-1)*2--1

A boring attempt on simplification

A simple repeat loop covers all 4 features:

repeat 3 {
  // (1) This decrements registers internally in each iteration.
  // (2) This is a loop.
  // (3) If value = 3 quit loop.
  // (4) branch back to beginning of block.
}

So programs can simply be

repeat 3

or simply a number

3