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 [
in vim will go through the whole file, joining multiple consecutive empty lines into one. Not only it is fork-bomb-level cryptic, but also showcases how you can use addresses to do advanced stuff.
Somewhat more readable version:
:vglobal /./ .,/./- join
which is: go to every line that doesn't match (vglobal) /./ (is empty) and join lines from that line (.) to the line before (-) the next line that is not empty (/./ again).
Comments (380) 116 threads
Earlier commentsThe 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 [
Somewhat more readable version:
which is: go to every line that doesn't match (vglobal) /./ (is empty) and join lines from that line (.) to the line before (-) the next line that is not empty (/./ again).All comments shown.
Couldn't load more comments. Check your connection and try again.