Skip to content

Commit 28ce4ca

Browse files
committed
Refactor dDiv
1 parent f89e9f3 commit 28ce4ca

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Prelude.tel

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ dEqual = \a b -> let equalsOne = \x -> if x then (not (left x)) else 0
6767
in if a then equalsOne (d2c (left a) (\x -> left x) b)
6868
else not b
6969

70-
dDiv = \a b -> { \p -> dMinus (left p) (right p)
71-
, \recur p -> succ (recur (dMinus (left p) (right p), right p))
72-
, \p -> if (dEqual (left p) (right p)) then succ 0 else 0
73-
} (a, b)
70+
dDiv = \a b -> if (dEqual b 0)
71+
then abort "Undefined"
72+
else
73+
{ \p -> dMinus (left p) (right p)
74+
, \recur p -> succ (recur (dMinus (left p) (right p), right p))
75+
, \p -> if (dEqual (left p) (right p)) then succ 0 else 0
76+
} (a, b)
7477

7578
listLength = foldr (\a b -> succ b) 0
7679

0 commit comments

Comments
 (0)