[Haskell-cafe] foldt fix proposal (HaskellWiki)

Michael V. Antosha michael.antosha at gmail.com
Wed May 27 22:05:27 UTC 2015


hi ALL,

I think I've found a mistake in foldt
implementation on the Fold page[1] of the
HaskellWiki.

foldt :: (a -> a -> a) -> a -> [a] -> a
foldt f z [] = z
foldt f z [x] = x    -- mistake?
-- foldt f z [x] = f x z  -- fix proposal
foldt f z xs = foldt f z (pairs f xs)

pairs :: (a -> a -> a) -> [a] -> [a]
pairs f (x:y:t) = f x y : pairs f t
pairs f t = t


Without the fix, foldt just ignores z value in
all cases except for the case of empty input
list.  (Which is an inconsistent behaviour I
suppose.)


The Examples page[2] also needs corresponding
fix.


Is this mail list a right place to ask for the
HaskellWiki page fix?

Thanks!

Michael.


[1] Tree-like folds @ Fold @ HaskellWiki
https://wiki.haskell.org/Fold#Tree-like_folds

[2] Examples @ Fold @ HaskellWiki
https://wiki.haskell.org/Fold#Examples


-- 
Michael V. Antosha
http://mivael.in.ua
xmpp:m at mivael.in.ua   (Jabber ID)


More information about the Haskell-Cafe mailing list