aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math/logic/continuous.lux
blob: edc31f2a780bcdcf935063c3e6916907d4183368 (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 (#- false true or and not)
   [data [number ("rev/." Interval<Rev>)]]])

(def: #export true  Rev rev/top)
(def: #export false Rev rev/bottom)

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

  [and r/min]
  [or  r/max]
  )

(def: #export (not input)
  (-> Rev Rev)
  (r/- input ..true))

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

(def: #export (includes sub super)
  (-> Rev Rev Rev)
  (let [-sub (not sub)
        sum (r/+ -sub super)
        no-overflow? (.and (r/>= -sub sum)
                           (r/>= super sum))]
    (if no-overflow?
      sum
      ..true)))

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