Re:Ask HN: What is the most beautiful piece of code you've e...
by throwaway_n on Monday October 28, 2019 @12:39AM
(#21374324)
This is O(n^2) though
[ Parent
| on HN ]
Re:Ask HN: What is the most beautiful piece of code you've e...
by _bxg1 on Monday October 28, 2019 @12:41AM
(#21374331)
All of JS's list processing functions are pretty inefficient, since at the bare minimum each one creates and copies to a new array (as opposed to, say, Rust iterators). You use them when elegance is more important than performance; N^2 is fine when N is eight.
Re:Ask HN: What is the most beautiful piece of code you've e...
by kadoban on Monday October 28, 2019 @05:14AM
(#21375389)
That's always such a dangerous proposition though. Sure _you_ remember it's only fine when N is 8, but then the next guy comes along, or the input constraints change, or future you forgets because it _is_ fairly elegant looking.
I try not to leave grenades laying around too often, myself.