Last active
April 8, 2018 10:17
-
-
Save asvny/bfe628539c48259130b1087b7d068c00 to your computer and use it in GitHub Desktop.
Semver check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Semver = { | |
let checkVersion = (a, b) => { | |
let x = String.index(a, '.'); | |
let y = String.index(b, '.'); | |
let _b = x > y ? String.concat(String.make(x - y, '0'), [b]) : b; | |
let _a = y > x ? String.concat(String.make(y - x, '0'), [a]) : a; | |
let cmp = String.compare(_a, _b); | |
if (cmp == 0) { | |
0; | |
} else if (cmp > 0) { | |
1; | |
} else { | |
(-1); | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment