Christian Maeder wrote:
Colin Runciman wrote:
buffer xs = foldl const xs xs
I don't find it this easy nor a good programming practise.
My interaction depends on the (subtle order of) evaluation of a pure and
total function?
I would not think so much about the operational evaluation order, but
about the denotational value of functions. In a non-strict language
functions always also accept partially defined arguments (including
bottom _|_). What a function returns for partially defined arguments
tells you how it can be used in an interactive program.
So:
buffer _|_ = _|_
buffer (a1:_|_) = _|_
buffer (a1:a2:_|_) = _|_
...
buffer (a1:a2:...:an:[]) = a1:a2:...:an:[]
Ciao,
Olaf
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell