www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - A brainf... implementation using D templates

Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

For those who haven't heard of it, brainf.... (BF) is a minimal 
turing-complete "programming language" with eight commands.

For more information, see http://en.wikipedia.org/wiki/Brainfuck .


For fun I tried doing a template implementation that would "compile" the 
BF code at compile time.
For obvious reasons it only works with small BF programs.
The BF code in the source is the multiplication example from the 
wikipedia article.
Compile the code, run it, and type (e.g.) 23<enter>. The output should be 6.


Source code attached (if the attachment doesn't work: 
http://home.chello.no/~jskogtv/bf.d )
Nov 07 2006