Skip to content

Instantly share code, notes, and snippets.

@asvny
Last active April 8, 2018 10:17
Show Gist options
  • Save asvny/bfe628539c48259130b1087b7d068c00 to your computer and use it in GitHub Desktop.
Save asvny/bfe628539c48259130b1087b7d068c00 to your computer and use it in GitHub Desktop.
Semver check
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