@all, thanks a lot.
Here is how you can do it with premature optimization:
import unicode, strutils
proc translationTable(src, dest: string): array[0x1f00, char]
{.compileTime.} =
for i in 0..<0x1f00: result[i] = '\0'
var
srcIndex = 0
destIndex = 0
while srcInd
As I said.. this and your original c-code will not work with UTF-8 at all.
To make it work for UTF-8 you can use the
[unicode.nim](http://forum.nim-lang.org///nim-lang.org/docs/unicode.html)
module. But switching to UTF-8 and therefor Unicode will make all of that much
more complex.
For exampl
OderWat, I guess there is something wrong with the UTF or so. I made the
following test...
proc translate(c: char): char =
const
a = "ÁÀÃÂÇáàãâçÉÊéêÍíÑÓÔÕñóôõÚÜúü"
b = "CcEEeeIiNOOOnoooUUuu"
let o = a.find(c)
if o >= 0:
return
Well it could work like this:
proc translate(c: char): char =
const
a = "abcdef"
b = "123456"
let o = a.find(c)
if o >= 0:
return b[o]
else:
return c
proc main() =
var s = "that is the abc"
for c in s.
Yeap, I know. What's the best way to implement your proc translate ?
Say I have an input string like "Cédille Français". How can I use the proc with
it ?
Sorry my basic questions, but I am a pretty new with Nim... Cheers
You guys might want to double check that. The docs.zip file was missing from
the server so it's likely it only started working for you after it was
uploaded, not due to a change in install path or the addition of admin
privileges. But I guess that's possible too :)
Thank you all for testing.
I have just fixed position values for knight vs bishop, so total value of these
two is really equal in average. And I scaled the total position values, so
computer may in very rare cases give away a pawn for a very good position.
@dom
So what is your advice concernin
Your compilation instructions would probably be nicer if, instead of depending
on absolute paths and symlinks, there would be a Makefile like this:
board: board.nim engine.nim
nim c -p:../nim-gio/src -p:../nim-atk/src -p:../nim-glib/src
-p:../nim-gdk3/src -p:../nim-gtk3/src
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
Good job, but why are you inlining _every_ **single** procedure?
11 matches
Mail list logo