Hacker News new | ask | show | jobs
by zzzcpan 3403 days ago
"Have you ever needed to flatten a list in your career outside exams and interviews?"

I had to write this function to flatten a tree of expressions, so I could sort them by precedence, etc and fold them into a tree. I already had a bunch of higher-order primitives for constructing a parser and that was basically a lazy hack for me to get expressions parsed. I eventually implemented a proper expression parser, that was basically the same thing, but produced a flat list from the beginning.