Here's an extension in Swift that converts a Roman numeral string to an Int value:
main.swift598 chars20 lines
This function uses a dictionary to map each Roman numeral character to an integer value. It then iterates through the string, comparing adjacent characters to determine whether to add or subtract from the result, based on whether the current character is smaller or larger than the next character.
Here's an example usage of the extension:
main.swift89 chars3 lines
gistlibby LogSnag