esolang

Foo

Brainfuck with numbers. Anything between quotes is printed, so the shortest Hello World is the text itself.

Feky, 2008 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 7 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

Feky made Foo in February 2008, inspired by brainfuck. It keeps the tape and the pointer but lets a command take a number. +10 adds ten, &65 sets the cell to 65. Where no number follows, the command takes a value from a stack instead.

Read the story

Text in double quotes is printed as it is. A quote without a partner prints to the end of the program, which is why Foo turns up in polyglots; almost any text is a Foo program that prints part of itself.

The machine

Cells hold 0 to 65535 and wrap. There are 30000 of them, and the pointer wraps at both ends.

CodeDoes
"text"Print the text
&n &Set the cell to n, or to a popped value
@n @Push n, or push the cell
< >Move the pointer
+n -n *n /n %nChange the cell by n, or by a popped value
$i $h $cPrint the cell as a decimal, as hexadecimal, as a character
$c100Print the number instead of the cell: d
(n … )Loop while the cell is not n (not 0 without a number)
#nSleep n seconds; here it does nothing

Popping an empty stack gives 0. Everything else is a comment. There is no input.

Example

The second program is the factorial of 4.
Expected: 24
Expected: 11111111

The second program is the factorial of 4. Cell 0 counts down; each round pushes it, and * in cell 1 multiplies by the popped value. The third turns 255 into binary, one %2 and one /2 per digit.

Further

Ideas it shows

Cell-based

Write your own in Run Convert a program from Foo

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: foo.

Command line

shib run foo -e '&256*2$i'
shib manual foo

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/foo.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org