Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Created July 8, 2025 04:25
Show Gist options
  • Select an option

  • Save ingydotnet/76662926bc811eecdf6c0d09089a737f to your computer and use it in GitHub Desktop.

Select an option

Save ingydotnet/76662926bc811eecdf6c0d09089a737f to your computer and use it in GitHub Desktop.
!YS-v0
ns: to-roman
numeral-pairs =::
1000 M 900 CM 500 D 400 CD
100 C 90 XC 50 L 40 XL
10 X 9 IX 5 V 4 IV
1 I
numeral-pairs =:
numeral-pairs.words().partition(2)
.map(fn([[n s]] [n:I s]))
defn to-roman(n):
when n >= 1:
val rom =: !:first
filter _ numeral-pairs:
\(_.0 <= n)
str: rom to-roman(n - val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment