You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
733 B
Plaintext
30 lines
733 B
Plaintext
15 years ago
|
namespace eval ::iwidgets {
|
||
|
variable romand
|
||
|
set romand(val) {1000 900 500 400 100 90 50 40 10 9 5 4 1}
|
||
|
set romand(upper) { M CM D CD C XC L XL X IX V IV I}
|
||
|
set romand(lower) { m cm d cd c xc l xl x ix v iv i}
|
||
|
|
||
|
proc roman2 {n {case upper}} {
|
||
|
variable romand
|
||
|
set r ""
|
||
|
foreach val $romand(val) sym $romand($case) {
|
||
|
while {$n >= $val} {
|
||
|
set r "$r$sym"
|
||
|
incr n -$val
|
||
|
}
|
||
|
}
|
||
|
return $r
|
||
|
}
|
||
|
|
||
|
proc roman {n {case upper}} {
|
||
|
variable romand
|
||
|
set r ""
|
||
|
foreach val $romand(val) sym $romand($case) {
|
||
|
for {} {$n >= $val} {incr n -$val} {
|
||
|
set r "$r$sym"
|
||
|
}
|
||
|
}
|
||
|
return $r
|
||
|
}
|
||
|
}
|