Re:Why it’s hard for programmers to write a program to flatt...
by kazinator on Saturday February 25, 2017 @12:01AM
(#13730158)
A somewhat more interesting challenge is: write code to lazily flatten a list. It must instantly return, and access the original structure lazily. Each atom is fetched from the original list when the lazy list is accessed. No continuations allowed; at most lexical closures.
My C solution is in this file:
http://www.kylheku.com/cgit/txr/tree/lib.c
functions lazy_flatten_scan, lazy_flatten_func and lazy_flatten.