
19 Mar
2009
19 Mar
'09
12:34 p.m.
Can you give an example of when CSE would not be the way to go?
if length (replicate 'a' 10000) == 1 then [] else head (replicate 'a' 10000) This program will use O(1) memory. If we perform CSE: if length x == 1 then [] else head x where x = replicate 'a' 10000 Now we use 10000 cells of memory. Thanks Neil