Zulip Chat Archive

Stream: Is there code for X?

Topic: List repeat


Martin Dvořák (Feb 27 2022 at 15:08):

Is there a function that creates a list by concatenating n copies of the same list?
There is list.repeat (a : α) : ℕ → list α that repeats a single element.
Is there a similar function list α → ℕ → list α for repeating lists?

Yury G. Kudryashov (Feb 27 2022 at 15:16):

You can use docs#list.join on docs#list.repeat

Yury G. Kudryashov (Feb 27 2022 at 15:18):

Something like (untested) (list.repeat l n).join


Last updated: Dec 20 2023 at 11:08 UTC