Link Search Menu Expand Document

Version 3.0.0

Numeric tokens

The LatinNumerics object can validate the syntax of a Latin numeric string.

import edu.holycross.shot.latin._

assert(LatinNumerics.valid("ⅩⅣ"))

assert(LatinNumerics.valid("ⅣⅩ") == false)

It can also convert valid values to integers.

assert (LatinNumerics.numericToInt("ⅩⅣ") ==  14)

Note that the numeric characters are drawn from the Unicode code points summarized here. If you try to use non-numeric characters, it is an exception.

// True numeric characters:
assert(LatinNumerics.valid("ⅩⅣ"))

// Similar looking glyphs for alphabetic characters:
try {
  LatinNumerics.valid("XIV")
} catch {
  case t: Throwable => t
}