on master help sign in
Merge pull request #4603 from kjekac/patch-1

Use last element instead of first to seed foldr1

commit011db5fa7a68dc564d41e8e5933a821dba4d6bae authorNiklas Larsson <metaniklas@gmail.com> dateFri 7 Dec 2018, 16:12 (8 years ago) parent5ce5a36960a6a6
1 file changed+2−1
libs/base/Data/Vect.idr+2−1
libs/base/Data/Vect.idr+2−1
@@ -315,7 +315,8 @@ concat (v::vs) = v ++ concat vs
315315
316316||| Foldr without seeding the accumulator
317317foldr1 : (t -> t -> t) -> Vect (S n) t -> t
318−foldr1 f (x::xs) = foldr f x xs
318+foldr1 f [x] = x
319+foldr1 f (x::y::xs) = f x (foldr1 f (y::xs))
319320
320321||| Foldl without seeding the accumulator
321322foldl1 : (t -> t -> t) -> Vect (S n) t -> t