{.experimental.} import strutils,sequtils,macros,osproc const p = @[ "echo 'threads:on' > nim.cfg", "echo 'threads:on' > ../nim.cfg", ] const str = p.mapIt(gorge(it)) echo str template hoge() = import math,threadpool proc term(k: float): float = 4 * math.pow(-1, k) / (2*k + 1) proc pi(n: int): float = var ch = newSeq[float](n+1) parallel: for k in 0..ch.high: ch[k] = spawn term(float(k)) for k in 0..ch.high: result += ch[k] let f = formatFloat(pi(5000)) echo f hoge()