Sunday, February 1, 2009

Ch4, Ex14

This is iterative even without dataflow variables due to the lazy nature and hence incremental computation of successive elements of append result.
fun lazy {LAppend Xs Ys}
case Xs of nil then Ys
[] X|Xr then X|{LAppend Xr Ys}

When first element is needed it returns X|<promised next elems> and it calculates the next elements on the need basis.

No comments:

Post a Comment