import random, sugar, math
from sequtils import toSeq
proc test1[I, T, U](a: array[I, T], cdf: array[I, U]): auto =
(() => random.sample(a, cdf.cumsummed))
proc test2[T, U](a: openArray[T], cdf: openArray[U]): auto =
(() => random.sample(a.toSeq, cdf.toSeq.cumsummed))
assert compiles test1([1,2], [1,2])
assert compiles test2([1,2], [1,2])
Run.
