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

Comments (380) 116 threads

Earlier comments
globuous#
Here’s one i’m really proud of, i crafted it when learning js a while back. Its a one liner that flattens arbitrarily nested array. Its recursive though, so i guess it has its limits. I remember commenting something along the lines of “dark magic functional prog” (thats how i found it a second ago in GH actually):

const flatten = arr => ((flat = [].concat(...arr)) => flat.some(Array.isArray) ? flatten(flat) : flat)()
Its simple, but i was - and still am - way to proud of it ;p

yzh#
Lots of ioccc code are beautifully done. Especially the best self documenting ones.
candu#
From [1], a terse one-liner that outperformed many longer and more complicated entries in The Second International RoShamBo Programming Competition:

    int henny() {
      return((*opp_history?opp_history[random()%*opp_history+1]+1:random())%3);
    }
[1] https://webdocs.cs.ualberta.ca/~darse/rsbpc.html
eb0la#
I always enjoyed reading Charles Petzold code on Microsoft Systems Journal.

When I discovered the Magazine (back un the 90's) I wasn't ready to code for windows nor win32 because I was a broke student with a 1MB 80286; but I am pretty sure reading and rereading that code and articles made me learn more C/C++ than most books or courses I took later.
Mr. Petzold: If we meet someday, the beers are on me!

Load more comments