Does Haskell have an effective fixed-size list library? I think the IArray interface is a bit more complicated when you need only arrays indexed by natural numbers [including zero]. I want to write code like
zeroToTwenty :: Int -> FixedList Int zeroToTwenty 0 = createFixedList 21 [] zeroToTwenty n = zeroToTwenty (n-1) `append` n
my naive solution is below.
Edit : Sorry for the lack of context; I want the data structure to be allocated once to avoid excessive garbage collection. This was in the context of the merge sort routine, which takes two sorted sublists and creates one sorted list.
source share