We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

CONTAIN

From Esolang
Jump to navigation Jump to search

CONTAIN is an esolang about boxes that contain numbers.

Instructions


Programs end when all containers get deleted.

Boxes:
[number] - Create container at this character position with default number set.

[] - Init container to 0

"text" - Create sequential containers with Unicode values (used cleverly in some example programs to cut down on space, see programs with "_golf" postfixes)

Box Pointer Movement:

Box Pointer movement triggers all queued operations.

> - Move BP to next container (by creation order)

< - Move BP to previous container

$ - Save current BP position

& - Load saved BP position

Instruction Pointer (IP) Control:

( - Save current IP position

) - Load saved IP position

x - Skip next ) or & if current box = 0

Binary Operations (use current & next containers):

Next container in this case refers to the container that you end up on after BP movement (can be same as current!)

+ - Add

- - Subtract

* - Multiply

/ - Divide (deletes container if divide by zero)

% - Modulo (also deletes)

= - Set current = next

@ - Swap current and next

Unary Operations:

! - Print current as number

? - Print current as ASCII

^ - Create new container: position = current+1, val=0

Input:

: - Input number to current container

; - Input ASCII to current container

Special:

# - Comment everything after it out
Anything else - NOP

Example Programs

Hello World

[]"Hello, World!">(?/&>)

Factorial

[1][][1]>:<(*>-><x<)!(/>@<)

Truth machine

[]:!$/&(!)

Fibonacci sequence

[][1](+>!@<)

Interpreters

There is currently only one interpreter: https://github.com/QuantumV2/CONTAIN