I realised you don't actually need toSeq here 😔 
    
    
    import random, sugar, math
    
    proc foo[T, U](a: openArray[T], cdf: openArray[U]): auto =
      let (a, cdf) = (@a, @cdf)
      (() => random.sample(a, cdf.cumsummed))
    
    echo foo([1,2], [1,2])()
    
    
    Run

Reply via email to