【发布时间】:2017-08-23 16:03:22
【问题描述】:
我想将几个数字打印为罗马数字,但是
(format t "~@R~%" 4000)
在 SBCL 1.3.20 和使用 ccl 的类似错误中导致以下错误:
Number too large to print in Roman numerals: 4,000
[Condition of type SIMPLE-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {100503D2B3}>)
我在Hyperspec 中没有找到有关此限制的任何信息,也不知道罗马人的数字只有 3,999。
是否有现成的解决方案可以将大于 3,999 的数字打印为罗马数字?
【问题讨论】:
-
其实这不是 Common Lisp 的限制,而是罗马数字固有的东西。对于超过 3999 的数字,罗马人在一个数字上添加一条线以将其乘以 1000。
标签: format common-lisp roman-numerals