[Haskell-cafe] how to break foldl' ?
garyng2000 at yahoo.com
Fri Sep 30 10:22:59 EDT 2005
Thanks. But how would I think about using scanl
instead of foldl(or foldl') when I want is the sum,
but not the progressive result. Once again show me
that I need to throw away all imperative stuff.
Oh, BTW, the reason I asked is that I was playing with
python which has a reduce function that looks like
foldl, and I tried to practice some FP style
programming and came up with this issue. There is no
scanl though, better use for loop and break.
> This should work as expected:
> takeWhile (<maxX) (scanl (+) 0 xs)
Yahoo! Mail - PC Magazine Editors' Choice 2005
More information about the Haskell-Cafe