law foldl_map

bend-mathlib@0.8.1.0 · list.bend:1321

import bend-mathlib@0.8.1.0/list.bend as List
import Base

1321# A left fold over a map folds with the mapped function: foldl g z (map f xs) = foldl (fun acc x => g acc (f x)) z xs.
1322law foldl_map:
1323  for ~A: Type
1324  for ~B: Type
1325  for ~C: Type
1326  for ~f: A -> B
1327  for ~g: C -> B -> C
1328  for xs: List<A>
1329  for -z: C
1330  {List.foldl(~&1, ~B, ~C, ~g, List.map(~A, ~B, ~f, xs), z) == List.foldl(~&1, ~A, ~C, ~(x => y => g(x, f(y))), xs, z) : C}

Uses (3)

Used by (1)