Between

From Esolang
Jump to navigation Jump to search

Between is an esoteric programming language created by User:Saka.
Between has functions which are positioned between arguments, hence the name.

Basics

Between is not stack based nor tape based. It is normal.
An instruction in Between is of the form

<arg1><operation><arg2>

For operations that accept only one argument, the arg2 must be a "None" type (See Data Types)

Data Types

Between has 5 data types:

Representation Name
'x' String
|x| Integer
[x] Variable
(x) Condition (True or False)
. None

Operations

Each operation is a single character and must be on it's own line. Comment lines start with #.

Operation Description Arg 1 Arg 2 Returns
p Print arg1 String, Int, or Var None None
v Declare variable with name arg1 String None None
s Set variable arg1 to arg2 Var String, Int, or Var None
c Toggle string/integer form of arg1 (Arg1 must only consist of numerals) String, Int, or Var None String or Int
+ Add arg1 to arg2 (Or concatenate strings) String, Int or Var String, Int or Var String or Int
* Multiply arg1 by arg2 Int or Var Int or Var Int
= Check if arg1 equals arg2 String, Int, or Var String, Int, or Var Condition
> Check if arg1 is greater than arg2 Int or Var Int or Va Condition
r Check if arg1 or arg2 Condition Condition Condition
n Negate arg1 Condition None Condition
f Go to arg1 if arg2 is true Int or Var Condition or None (If none, acts as a Goto) None
i Set arg1 to user string input Var None None
x Exit program None None None

Examples

Warning: Not tested yet.

Hello World

'Hello, World!'p.
.x.

Truth Machine

'in'v.
[in]i.
|5|f([in]='1')
|0|p.
.x.
|1|p.
|5|f.

CAT Program

'in'v.
[in]i.
[in]p.
.x.

Infinite Fibonacci Sequence

'a'v.
'b'v.
'c'v.
[b]s|0|
[c]s[b]
[b]s|[a]+[b]|
[a]s[c]
[a]p.
|4|f.

Subtract one input from another

'a'v.
[a]i.
[a]s|[a]c.|
'b'v.
[b]i.
[b]s|[b]c.|
|13|f([b]>[a])
'value'v.
|11|f(|[value]+[b]|=[a])
[value]s|[value]+|1||
|8|f.
[value]p.
.x.
'Error: can't subtract bigger number from smaller'p.
.x.