Flatten a list using only the forms in “The Little Schemer”
I'm going through The LIttle Schemer to learn Scheme (as an old C programmer) and as an exercise I tried to write a procedure to flatten a list using only the forms in The Little Schemer; I.e., define , lambda , cond , car , cdr , and , or , etc., but not append . I thought it would be easy but I haven't been able to come up with a solution. How can I do this ? I have a version that uses only "first-principles" operations and is efficient (does not require more than one pass through any of the lists, unlike append -based solutions). :-) It does this by defining two simple building blocks (