aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-05-10 14:11:45 +0100
committerLouis Pilfold <louis@lpil.uk>2019-05-10 14:11:45 +0100
commite1f4d26f3ee2e765c87b02c96950c9e0cb1d8bde (patch)
tree3a0000a1d357a6a47e5b9f25cdd552e9e9bd3d5a /src
parent49df300ffe6f020a4df26dede27bef42d000c671 (diff)
downloadgleam_stdlib-e1f4d26f3ee2e765c87b02c96950c9e0cb1d8bde.tar.gz
gleam_stdlib-e1f4d26f3ee2e765c87b02c96950c9e0cb1d8bde.zip
int:compare
Diffstat (limited to 'src')
-rw-r--r--src/int.gleam13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/int.gleam b/src/int.gleam
index 00571de..5eeece4 100644
--- a/src/int.gleam
+++ b/src/int.gleam
@@ -1,3 +1,5 @@
+import order
+
pub enum NotAnInt =
| NotAnInt
@@ -6,3 +8,14 @@ pub external fn parse(String) -> Result(Int, NotAnInt) = "gleam__stdlib" "parse_
pub external fn to_string(Int) -> String = "erlang" "integer_to_binary"
pub external fn to_base_string(Int, Int) -> String = "erlang" "integer_to_binary"
+
+pub fn compare(a, b) {
+ case a == b {
+ | True -> order:Eq
+ | False ->
+ case a < b {
+ | True -> order:Lt
+ | False -> order:Gt
+ }
+ }
+}