juvix
juvix copied to clipboard
Multiway `if` syntax
Our if is actually not readable, especially with nested ifs. Instead of writing e.g.
if
(y1 == 0)
q
(if
(y2 == 0)
p
(if
(x1 == x2)
(if (y1 == y2) (double p) (mkPoint 0 0))
(let
slope := (y1 - y2) / (x1 - x2);
r_x := slope * slope - x1 - x2;
r_y := slope * (x1 - r_x) - y1;
in mkPoint r_x r_y)));
we should be able to write e.g.
if
| y1 == 0 := q
| y2 == 0 := p
| x1 == x2 :=
if
| y1 == y2 := double p
| else := mkPoint 0 0
| else :=
let
slope := (y1 - y2) / (x1 - x2);
r_x := slope * slope - x1 - x2;
r_y := slope * (x1 - r_x) - y1;
in mkPoint r_x r_y;