Added the conditional expression If
This commit is contained in:
parent
db41d6d1b7
commit
ab9dca4cd9
|
@ -820,6 +820,7 @@
|
||||||
Variables
|
Variables
|
||||||
Map
|
Map
|
||||||
Apply
|
Apply
|
||||||
|
If
|
||||||
Append
|
Append
|
||||||
AppendStar
|
AppendStar
|
||||||
Sin Cos Tan Sqrt
|
Sin Cos Tan Sqrt
|
||||||
|
@ -850,6 +851,11 @@
|
||||||
|
|
||||||
(define Hold 'Hold)
|
(define Hold 'Hold)
|
||||||
|
|
||||||
|
(define (If t c a)
|
||||||
|
(if (atomic-expression? t)
|
||||||
|
(if t c a)
|
||||||
|
(construct 'If (list t c a))))
|
||||||
|
|
||||||
(define (Plus . expressions)
|
(define (Plus . expressions)
|
||||||
(simplify-plus expressions))
|
(simplify-plus expressions))
|
||||||
|
|
||||||
|
@ -1331,7 +1337,12 @@
|
||||||
(check-equal? (Expand (Power (Plus a b) 2))
|
(check-equal? (Expand (Power (Plus a b) 2))
|
||||||
(Plus (Power a 2) (Times 2 a b) (Power b 2)))
|
(Plus (Power a 2) (Times 2 a b) (Power b 2)))
|
||||||
(check-equal? (Expand (Times a (Plus x y)))
|
(check-equal? (Expand (Times a (Plus x y)))
|
||||||
(Plus (Times a x) (Times a y))))
|
(Plus (Times a x) (Times a y)))
|
||||||
|
; If
|
||||||
|
(check-equal? (If (Equal 1 1) 2 3) 2)
|
||||||
|
(check-equal? (If (Equal 1 2) 2 3) 3)
|
||||||
|
(check-equal? (If (Equal 1 x) 2 3) '(If (Equal 1 x) 2 3))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#;(require (submod "." symbolic-application)
|
#;(require (submod "." symbolic-application)
|
||||||
|
|
|
@ -25,3 +25,9 @@ norm(a);
|
||||||
norm(b);
|
norm(b);
|
||||||
proj(a,b);
|
proj(a,b);
|
||||||
line({x0,y0},{z,w});
|
line({x0,y0},{z,w});
|
||||||
|
x:=0;
|
||||||
|
x=0;
|
||||||
|
If(x=0,1,2);
|
||||||
|
If(x=0,1,2);
|
||||||
|
If(x=42,1,2);
|
||||||
|
If(3+z,1,2)
|
Loading…
Reference in New Issue
Block a user