When I compile the "modified sum" (« _sum_folds.hs ») file :
*--------------------------- [
import Debug.Trace
_sum =
foldl ( \ acc x ->
trace (
show x
++ " - " ++ show acc
)
acc + x
)
0
*--------------------------- ]
[1 of 1] Compiling Main ( _sum_folds .hs, interpreted )
Ok, modules loaded: Main.
... and apply it to '[1..5]', I get :
*Main > _sum ([1..5])
* 1 - 0
* 2 - 1
* 3 - 3
* 4 - 6
* 5 - 10
* 15
* it :: Integer
(order for a 'foldl' process is OK ...)
If I remove the < ++ " - " ++ show acc > , I get :
( we have only < trace (show x) > )
*Main > _sum ([1..5])
* 5
* 4
* 3
* 2
* 1
* 15
* it :: Integer
... : the order of processing of the elements inside < [1..5] > (the 'x's) seems have been inverted (it is a 'foldl')...!?
What does it mean ?