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

Comments (380) 116 threads

Earlier comments
wiineeth1 reply#
C++ STL algorithms written by Alexander Stepanov.
ddtaylor#
Any specific ones that standout?
whateveracct#

  fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
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 [

urxvtcd#
Created an account to post this:

  :v/./,/./-j
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).

Load more comments