home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
303.lha
/
Icon_v7.5
/
samples
/
roman.icn
< prev
Wrap
Text File
|
1980-12-03
|
589b
|
25 lines
#
# R O M A N N U M E R A L S
#
# This program takes Arabic numerals from standard input and writes
# the corresponding Roman numerals to standard outout.
procedure main()
local n
while n := read() do
write(roman(n) | "cannot convert")
end
procedure roman(n)
local arabic, result
static equiv
initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
integer(n) > 0 | fail
result := ""
every arabic := !n do
result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
if find("*",result) then fail else return result
end