Zulip Chat Archive
Stream: new members
Topic: list reduce
Daan van Gent (Dec 04 2022 at 14:49):
I am looking for a function on lists that does the following:
def list.reduce {α β : Type*} (f : β → α → α) : list β → α → list α
| [] a := [a]
| (b :: l) a := a :: list.reduce l (f b a)
example {α : Type*} (l : list (set α)) : list (set α) :=
list.reduce (λ s t, s ∪ t) l ∅
It should produce from the list [s,t,u]
the list [∅,s,s ∪ t,s ∪ t ∪ u]
. I feel like it should be in mathlib, but it is apparently not called what I would expect it to.
Mauricio Collares (Dec 04 2022 at 15:04):
Let's try docs#scanl
Mauricio Collares (Dec 04 2022 at 15:05):
docs#list.scanl seems to exist
Last updated: Dec 20 2023 at 11:08 UTC