From e1f4d26f3ee2e765c87b02c96950c9e0cb1d8bde Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Fri, 10 May 2019 14:11:45 +0100 Subject: int:compare --- src/int.gleam | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') 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 + } + } +} -- cgit v1.2.3