esolang

Foobar and Foobaz and Barbaz, oh my!

Every line is the same sentence. The only thing that changes is who gets ANDed with whom.

Ihope127, 2005 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hi

The idea

Ihope127 made this language in 2005, and said its purpose was to find out what the original phrase was. Every statement has the same form, A and B and C, oh myD. It works out (A and B) or (C and D), bit by bit, and stores the result in D.

Read the story

There are only four variables, and three of them are special. Reading ? reads input. Writing to . prints. ... is the number of the statement running, so writing to it is a jump. Only ! is an ordinary variable. With no arithmetic and no way to grow, a program is a finite state machine.

The machine

NameReading itWriting it
!Its valueStores
?A byte of input, -1 at the endLost
.Its valueStores and prints a byte
...The number of this statement, from 0Jumps to that statement

A number outside the program ends the run, as running past the last statement does.

Example

A number ANDed with itself is the number, and 0 ANDed with anything is 0, so each line of the first…
Expected: A

A number ANDed with itself is the number, and 0 ANDed with anything is 0, so each line of the first program prints one character.

The second is the first line of the cat. Its second line, 0 and 0 and 0, oh my..., jumps back to the start forever. The other cat stops at the end of input. It stores the character in !, prints it, and jumps to the statement with that number, where 249 more lines all jump back to the start. At the end of input ! holds 255, which is past the last line, so the run ends there. It prints that 255 too before it stops.

Patterns it teaches

  • One instruction: one statement form does arithmetic, input, output and jumps.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Foobar and Foobaz and Barbaz, oh my!

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: foobar-and-foobaz-and-barbaz-oh-my.

Command line

shib run foobar-and-foobaz-and-barbaz-oh-my program.txt --input 'hi'

The program is long; save it as program.txt first.

shib manual foobar-and-foobaz-and-barbaz-oh-my

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/foobar-and-foobaz-and-barbaz-oh-my.js

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

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