blob: f256d0f4a7bcde6aaade5022cdc6a1216b6928b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
-module(gleam@int).
-compile(no_auto_import).
-export([parse/1, to_string/1, to_base_string/2, compare/2, min/2, max/2, is_even/1, is_odd/1]).
parse(A) ->
gleam_stdlib:parse_int(A).
to_string(A) ->
erlang:integer_to_binary(A).
to_base_string(A, B) ->
erlang:integer_to_binary(A, B).
compare(A, B) ->
case A =:= B of
true ->
eq;
false ->
case A < B of
true ->
lt;
false ->
gt
end
end.
min(A, B) ->
case A < B of
true ->
A;
false ->
B
end.
max(A, B) ->
case A > B of
true ->
A;
false ->
B
end.
is_even(X) ->
X rem 2 =:= 0.
is_odd(X) ->
X rem 2 /= 0.
|