esolang

Trigbf improved

Trigbf with one change. A loop runs while its cell is above 0, so the sign of a number picks a branch.

None1, 2026 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

None1 made Trigbf improved in 2026 from Trigbf, the brainfuck whose only arithmetic is sine, cosine and tangent. In Trigbf a loop runs while its cell is not 0. In this language it runs while its cell is above 0, and the specification says that lets a program take different branches for different cell values. The truth machine below picks its branch by the sign of a cosine.

The machine

CommandDoes
s c tThe cell becomes its sine, cosine, tangent
> <Move on the tape, unbounded both ways
[ ]Loop while the cell is above 0
. ,Print the rounded cell as a character; read a byte

The original Python reads the program from standard input, which leaves no input for ,. In this implementation the program and its input are kept apart. The Python computes with 100 digits; this implementation uses ordinary 64-bit numbers, which print the same.

Example

The truth machine reads a digit and takes its cosine.

The truth machine reads a digit and takes its cosine. For 0, which is 48, the cosine is about minus 0.64. The loop is skipped, and the cell after it is taken from 0 to about 47.76 by 12 commands, which prints 0.

For 1, which is 49, the cosine is about 0.30. The loop runs, and each turn steps to a fresh cell and builds about 49.42 there, which prints 1. That cell is above 0, so the loop never ends.

Programs without loops run as they do in Trigbf, and so does the cat, as a byte is never below 0.

Expected: HI!
Expected: trig

Further

Ideas it shows

Also in Turing tarpits

Write your own in Run Convert a program from Trigbf improved

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: trigbf-improved.

Command line

shib run trigbf-improved -e ',c[>cscscsstttt.]>cscccscttstt.' --input '0'
shib manual trigbf-improved

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/trigbf-improved.js

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

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