Skip to content

foldl1 looks flat-out wrong #86

@treeowl

Description

@treeowl

I'm working on a patch that will replace the folds anyway, but the current code,

  foldl1 f a | sz == 0   = die "foldl1" "empty array"
             | otherwise = go $ sz-1
   where sz = sizeofArray a
         z = indexArray a 0
         go i | i < 1     = f (go $ i-1) (indexArray a i)
              | otherwise = z

doesn't look remotely right. The i < 1 should be i > 0 or (probably better) i /= 0, or the branches should be swapped, or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions