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
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!
Comments (380) 116 threads
Earlier commentsconst 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
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!
All comments shown.
Couldn't load more comments. Check your connection and try again.