Tcl/Brainfuck

Brainfuck is a simple language which mainly manages to confuse the programmer. Still, it can solve any solvable mathematical problem (like all programming languages) so it's surprising that it hasn't become more popular than it is. It takes a minute to learn and forever to master.

Tcl/Brainfuck allows you to type Brainfuck code directly into a Tcl shell. I have not yet worked out why anyone would ever want to do this. It works by using the useful Tcl unknown mechanism as well as overriding the history command to do Brainfuck pre-parsing. The reason for the latter is that Brainfuck uses brackets for while loops which conflict with Tcl's use. Yes, this is a hack and I am quite proud of it.

Tcl/Brainfuck supports the complete Brainfuck language and the # command for printing debug info. It has been coded in pure Tcl so if you have Tcl installed, no compilation is required.

Examples

Lines beginning with > are user input. Lines beginning with % are commands to the shell.
    % +++
    3
    % ---
    0
    % set a [+++]
    3
    % puts $a
    3
    % bfInit  ;# Reinitialise the Brainfuck environment
    % +[->,----------]<[+++++++++++.<]
    > Brainfuck rules
    selur kcufniarB% 
    % bfInit
    

Download

Tcl/Brainfuck

More information

Programming in Brainfuck
Kristoffer Lawson
Last modified: Thu Jun 14 21:31:40 EEST 2001