Equations
- Chapter1.tails [] = [[]]
- Chapter1.tails (x_1 :: xs) = (x_1 :: xs) :: Chapter1.tails xs
Instances For
Equations
Instances For
Equations
- Chapter1.unwrap! [x] = x
- Chapter1.unwrap! x✝ = panicWithPosWithDecl "Fad.«Chapter1-Ex»" "Chapter1.unwrap!" 42 10 "unwrap!: not single list"
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Chapter1.reverse₀.helper [] res = res
- Chapter1.reverse₀.helper (x_1 :: xs) res = Chapter1.reverse₀.helper xs (x_1 :: res)
Instances For
Equations
Instances For
Equations
- Chapter1.map' f xs = List.foldr (fun (x : α) (xs : List β) => f x :: xs) [] xs
Instances For
Equations
- Chapter1.foldr' f e xs = if h : xs.isEmpty = true then e else have this := ⋯; f (xs.head ⋯) (Chapter1.foldr' f e xs.tail)
Instances For
Equations
Instances For
Equations
- Chapter1.foldl' f e xs = if h : xs.isEmpty = true then e else have this := ⋯; have h₂ := ⋯; f (Chapter1.foldl' f e (Chapter1.init₁ xs)) (Chapter1.last₁ xs h₂)
Instances For
Equations
Instances For
Equations
- Chapter1.integer.shiftl n d = 10 * n + d
Instances For
Equations
Instances For
Equations
- Chapter1.fraction.shiftr d n = (d.toFloat + n) / 10
Instances For
Equations
- Chapter1.apply 0 x✝ = id
- Chapter1.apply n.succ x✝ = x✝ ∘ Chapter1.apply n x✝
Instances For
Equations
- Chapter1.apply₁ 0 x✝ = id
- Chapter1.apply₁ n.succ x✝ = Chapter1.apply n x✝ ∘ x✝
Instances For
Equations
- Chapter1.remove x [] = []
- Chapter1.remove x (x_2 :: xs) = if x = x_2 then xs else x_2 :: Chapter1.remove x xs
Instances For
Instances For
Fusion law for foldl.
The intuition mirrors the foldr fusion law: we want to push a
post-processing function h inside a foldl, replacing an accumulator of
type c by an already-transformed accumulator of type b.
The hypothesis h₁ : ∀ y x, h (f y x) = g (h y) x states that h turns one
step of f (taken on the untransformed accumulator) into the corresponding
step of g (taken on the transformed accumulator). In other words, h is a
step-by-step homomorphism between the two accumulators: the diagram commutes
for every element x of the list.
Consequently, applying h to the final result of xs.foldl f e is the same
as running xs.foldl g starting from the transformed accumulator h e.
Note the contrast with foldr fusion: since in foldl the accumulator sits
on the left, the condition relates h (f y x) to g (h y) x, keeping x
on the same side. -
Equations
- Chapter1.steep₀ [] = true
- Chapter1.steep₀ (x :: xs_2) = decide (x > xs_2.sum ∧ Chapter1.steep₀ xs_2 = true)