first attempt to a more general solution, i'm considering rayon rust module
parallel implementation which contains parallel iterators, maps, etc.
proc par_apply*[T](v:var seq[T], fnc:proc(i:int):T)=
proc chunk_range(size, i, nth: int): Slice[int] =
let
chunk_sz = size div nth
rfrom = i * chunk_sz
rto = if (i+1) * chunk_sz > size: size else: (i+1) * chunk_sz
rfrom..<rto
proc chunk_apply(fnc:proc(i:int):T, i, n : int, v:var seq[T]) =
for i in chunk_range(size=v.len, i, n):
v[i] = fnc(i)
let nth = countProcessors()
parallel:
for i in 0..nth:
spawn chunk_apply(fnc, i, nth, v)
Run