Zulip Chat Archive
Stream: lean4
Topic: repeatList
Igor Shimanogov (Apr 30 2025 at 12:29):
In my commit to mathlib I need function
def repeatList.{u} {α : Type u} (n : Nat) (l : List α) : List α :=
(List.replicate n l).flatten
It seems to be missing both in lean4 and mathlib, but there are several lemmas including this construction;
In Init:
- List.flatten_replicate_nil
- List.flatten_replicate_singleton
- List.flatMap_replicate
- List.flatten_replicate_replicate
And Mathlib:
- List.getLast?_flatten_replicate
- List.head?_flatten_replicate
- List.ofFn_fin_repeat
- FreeAddGroup.nsmul_mk
- FreeGroup.pow_mk
Is it a good idea to make it a separate function and rewrite mentioned lemmas using new definition to get rid of repetitiveness?
Kim Morrison (Apr 30 2025 at 12:34):
Probably not? We don't want separate names for every combination of basic functions. This needlessly expands the API surface area.
Eric Wieser (Apr 30 2025 at 13:24):
Note that we do have docs#Fin.repeat
Last updated: May 02 2025 at 03:31 UTC