aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math/logic/continuous.lux
blob: c81f5e5264657fdd2abda83d5927a5d5ec994a3b (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
(;module:
  lux
  (lux (data [number "Deg/" Interval<Deg>])))

(def: #export TRUE Deg Deg/top)
(def: #export FALSE Deg Deg/bottom)

(do-template [<name> <chooser>]
  [(def: #export <name>
     (-> Deg Deg Deg)
     <chooser>)]

  [and~ d.min]
  [or~  d.max]
  )

(def: #export (not~ input)
  (-> Deg Deg)
  (d.- input TRUE))

(def: #export (implies~ consequent antecedent)
  (-> Deg Deg Deg)
  (or~ (not~ antecedent)
       consequent))

(def: #export (includes~ sub super)
  (-> Deg Deg Deg)
  (let [-sub (not~ sub)
        sum (d.+ -sub super)
        no-overflow? (and (d.>= -sub sum)
                          (d.>= super sum))]
    (if no-overflow?
      sum
      TRUE)))

(def: #export (=~ left right)
  (-> Deg Deg Deg)
  (and~ (or~ (not~ left) right)
        (or~ left (not~ right))))