Sha256: 5f0cc2df5ded3e9bab403f21b5d4f609247fa1f2b16a3b1779a1705cf5362c06
Contents?: true
Size: 936 Bytes
Versions: 262
Compression:
Stored size: 936 Bytes
Contents
module RomanNumeral let numeralThresholds = [(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")] let rec toRomanLoop remainder acc thresholds = match thresholds with | [] -> acc | (threshold, numeral)::xs -> if threshold <= remainder then toRomanLoop (remainder - threshold) (acc + numeral) thresholds else toRomanLoop remainder acc xs let toRoman (arabicNumeral: int) = toRomanLoop arabicNumeral "" numeralThresholds
Version data entries
262 entries across 262 versions & 1 rubygems