Lurker News
Preferably an elegant snippet rather than an entire (well engineered) codebase.

Comments (380) 116 threads

Show all comments

Showing thread 47 of 116

svendahlstrand#

  ,[.,]
When it comes to the weird and wonderful world of esoteric programming languages, the above Brainfuck program is pretty elegant. It's a basic implementation of the echo program: printing back what the user inputs.

The complete language consists of eight single-character commands. The four used in the echo program is:
, – accept one byte of input and store it at the current memory cell
. – output the byte at the current memory cell
[ – if the value of the current memory cell is zero, jump forward to the command after the matching ]
] – if the value of the current memory is nonzero, jump back to the command after the matching [