
12 Mar
2009
12 Mar
'09
10:35 p.m.
Hi all, Why does finding the maximum element of a big list cause a stack overflow: In ghci, if I print out a big list: *Main> [1..1000000] it takes a while but it prints. However, looking for the maximum element fails: *Main> maximum [1..1000000] *** Exception: stack overflow It seems to me like maximum should just be going through the list one by one and keeping track on the largest element seen do far. Why does in need to keep the entire list around (I presume), causing the stack overflow? Patrick -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada