Brainfuck interpreter in 160 bytes of C
j.mearie.org
j.mearie.org
// with whitespace:
s[999], *r=s, *d, c;
main(a, b)
{
char *v=1[d=b];
for(;c = *v++ % 93;)
for(b = c%7 ?
a &&
(c & 17 ?
c & 1 ?
(*r -= c - 44)
:(r += c - 61)
:c & 2 ?
putchar(*r)
:(*r = getchar())
,0)
:v;
b&&c | a * *r;
v=d)
main(!c,&b-1);
d = v;
}I have been programming in C for a while, and can't recall ever seeing main called recursively. Neat.
For the Brainfuck interpreter, I was also motivated by this StackOverflow question: http://stackoverflow.com/questions/1053931/code-golf-shortes... In this sense it does have a practical implication to gauge the minimal possible Turing-complete language implementation.