I want to create a list with many repeated entries. The input consists of lists of index numbers and the value to be placed at the corresponding index. Thus, this input:
[([0,1,3,6], "ant"), ([2], "bee"), ([4,5], "cat")]
would produce this output:
["ant", "ant", "bee", "ant", "cat", "cat", "ant"]
The pragmatist in me says to make the output an array and use Js.Array.spliceInPlace, which makes the task fairly simple. The idealist in me says it is more “morally pure” to use lists and and a more purely functional approach (fold, etc.), but the task becomes much more difficult.
I’m wondering what you all think.