Thanks a lot mratsim, works like a charm!

FYI, see below my end result, calculating the primes up to a certain number 
with the 'sieve of Eratosthenes', is quite fast (already 70 times faster as the 
scripting language I used first). 
    
    
    func sieve* (n:int):tuple[p:ptr int, len: int] {.cdecl, exportc: 
"sievenim", dynlib.}=
      var a : seq[int]
      a.add(2)
      #let a_ptr =a[0].unsafeAddr
      var arr = newSeq[bool](n+1)
      for x in countup(3,n,2):
         if not(arr[x]):
          a.add(x)
          for y in countup(x*x,n,x):
            arr[y] = true
      result = (a[0].addr, a.len)
    
    
    Run

Reply via email to