1
\$\begingroup\$

I've been playing with some ideas for a challenge to poke fun at java virtual machines and was pondering a brainfuck virtual machine (three bit bus!) and I got to wondering if there are any brainfuck variants that support closures, function calls, and function references.

\$\endgroup\$
0

1 Answer 1

3
\$\begingroup\$

You could be interested in Brainfuct. It's Brainfuck, but with lambdas, and great functional programming features. For example, in Brainfuct, the cat program looks like this.

>,.<@/+@

In this program, two functions are declared, main function (+@), and first function (>,.<@). @ calls the function under pointer. As you can see, there is lambda (functions can read state - i.e. tape), function calls (@), and function references (every function (with exception for main function) is a number).

\$\endgroup\$
2
  • \$\begingroup\$ So we have two out of three, function calls and function references, but not closures. \$\endgroup\$
    – hildred
    Commented Dec 30, 2013 at 20:25
  • 2
    \$\begingroup\$ @hildred: What is your definition of closure? This is Brainfuck, not language with local variables. There is just tape - and you can access it. \$\endgroup\$
    – null
    Commented Dec 30, 2013 at 20:27

Not the answer you're looking for? Browse other questions tagged .