aboutsummaryrefslogtreecommitdiff
path: root/src/std/bool.gleam
blob: 985f0d613dd59f926fb90ff4d26e6775b2415239 (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
import std/order

pub fn negate(bool) {
  case bool {
  | True -> False
  | False -> True
  }
}

pub fn compare(a, b) {
  case {a, b} {
  | {True, True} -> order:Eq
  | {True, False} -> order:Gt
  | {False, False} -> order:Eq
  | {False, True} -> order:Lt
  }
}

pub fn max(a, b) {
  case a {
  | True -> True
  | False -> b
  }
}

pub fn min(a, b) {
  case a {
  | False -> False
  | True -> b
  }
}

pub fn to_int(bool) {
  case bool {
  | False -> 0
  | True -> 1
  }
}