Home

RomanNumerals.jl

Julia package for Roman numerals.

RomanNumeral(num)

A type that represents a Roman numeral.

RomanNumeral objects can be created using Integer or AbstractString objects, or using the @rn_str string macro.

Examples

julia> using RomanNumerals

julia> foreach(i->println(RomanNumeral(i)), 1:5)
I
II
III
IV
V

julia> rand(RomanNumeral, 5)
5-element Array{RomanNumeral,1}:
 LXXI
 CXX
 XCVIII
 XLIX
 VIII

String literal

julia> rn"MMXIX"
MMXIX

Arithmetic

julia> I + I
II

julia> V - I
IV

julia> 3X - 2I
XXVIII

julia> M ÷ X
C

Conversion

julia> RomanNumeral(2019)
MMXIX

julia> Int16(rn"MMXIX")
2019

julia> string(rn"MMXIX")
"MMXIX"

julia> rn"I" == RomanNumeral("I") == RomanNumeral('I') == RomanNumeral(1)
true
source
rn"IVXLCDM"

RomanNumeral string literal.

source
RomanNumerals.IConstant.
I

The Roman numeral for 1.

source
RomanNumerals.VConstant.
V

The Roman numeral for 5.

source
RomanNumerals.XConstant.
X

The Roman numeral for 10.

source
RomanNumerals.LConstant.
L

The Roman numeral for 50.

source
RomanNumerals.CConstant.
C

The Roman numeral for 100.

source
RomanNumerals.DConstant.
D

The Roman numeral for 500.

source
RomanNumerals.MConstant.
M

The Roman numeral for 1000.

source