2 ms·
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
by kazinator 10y ago
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 http://www.kylheku.com/cgit/txr/tree/lib.c
functions lazy_flatten_scan, lazy_flatten_func and lazy_flatten.