Suppose that spread(x) takes a list x and yields another list that contains all members of x with a 1 after it. For example,
Write a definition of spread(x) that only computes as much of the result list as is needed by the program.
A basic definition of spread is
Define
case spread [] = []
case spread (x::xs) = x::1::spread(xs)
%Define
To make it lazy, just wrap smiles around the body.
You only need to do that for a nontrivial body.
Define
case spread [] = []
case spread (x::xs) = (: x::1::spread(xs) :)
%Define