@phoe @ksaj
I swear I saw this somewhere else, and please do not consider it my original work ;p :
CL-USER>
(defun worst-roman-reader (s c n) (declare (ignore c n))
`(loop :with num := (symbol-name ',(read s t t t))
:for x :from 1
:below most-positive-fixnum
:for rom := (format nil "~@r" x)
:when (string= num rom) :return x)
)
WORST-ROMAN-READER
CL-USER> (set-dispatch-macro-character #\# #\r #'worst-roman-reader)
T
CL-USER> #RCCLV
255
Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Thursday, 23-Jan-2025 08:26:19 JST screwlisp