I think one could import memchr() to nim and do the same as in the C version. 
Besides that there is the naive implementation:
    
    
    proc translate(c: char): char =
      const
        a = "abc"
        b = "123"
      
      let o = a.find(c)
      if o >= 0:
        return b[o]
      else:
        return c
    
    echo translate('a')
    echo translate('x')
    

[Run It](https://glot.io/snippets/ej02bwj2nl)

Beware of UTF-8 thought. Your example and system.find() only works if the 
encoding translates every letter to one char.

Reply via email to