I'm really new to Nim and started playing around with 0.17.0 on Linux.
I went to Rosetta Code: https://rosettacode.org/wiki/Category:Nim to get code examples to run.
The following code examples wouldn't compile with: $ nim -d:release c <file.nim>
import math randomize() proc pi(nthrows): float = var inside = 0 for i in 1..int64(nthrows): if hypot(random(1.0), random(1.0)) < 1: inc inside return float(4 * inside) / nthrows for n in [10e4, 10e6, 10e7, 10e8]: echo pi(n)
import complex, math proc rect(r, phi: float): Complex = (r * cos(phi), sin(phi)) proc croots(n): seq[Complex] = result = @ if n <= 0: return for k in 0 .. < n: result.add rect(1, 2 * k.float * Pi / n.float) for nr in 2..10: echo nr, " ", croots(nr)
How do you make these examples work with 0.17?
I keep them updated in https://github.com/def-/nim-unsorted but I'm too lazy to update all of those Rosetta Code entries manually.