> 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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to