Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programming Pushups part II

Name: Anonymous 2015-01-05 12:04

Write a program to compare two version strings.

Example comparisons:
1.05.00.0156 > 1.0.221.9289
1 < 1.0.1
1.0.1 < 1.0.2
1.0.2 < 1.0.3
1.0.3 < 1.1
1.1 < 1.1.1
1.1.1 < 1.1.2
1.1.2 < 1.2

Name: Anonymous 2015-01-07 9:03

v :: String -> [Integer]
v = map read . words . map sub

sub '.' = ' '
sub c = c

tests =
[ v "1.05.00.0156" > v "1.0.221.9289"
, v "1" < v "1.0.1"
, v "1.0.1" < v "1.0.2"
, v "1.0.2" < v "1.0.3"
, v "1.0.3" < v "1.1"
, v "1.1" < v "1.1.1"
, v "1.1.1" < v "1.1.2"
, v "1.1.2" < v "1.2"
]

-- *Main> tests
-- [True,True,True,True,True,True,True,True]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List