How do I convert an array of floats to array of ints?. I've tried
    
    
    import math
    from sequtils import map
    
    proc toInt(x: float64): int =
        return int(x)
    
    let xx = @[42.3, 48.5, 43.4]
    var x = xx.map(toInt)
    echo x
    
    Run

and I got
    
    
    Error: type mismatch: got <seq[float64], proc (x: float64): 
int{.noSideEffect, gcsafe, locks: 0.} | proc (f: float): int{.noSideEffect, 
gcsafe, locks: 0.}>
    but expected one of:
    proc map[T, S](s: openArray[T]; op: proc (x: T): S {.closure.}): seq[S]
      first type mismatch at position: 2
      required type for op: proc (x: T): S{.closure.}
      but expression 'toInt' is of type: None
    
    expression: map(xx, toInt)
    
    
    Run

Reply via email to