@@ -8,31 +8,25 @@ struct Variable <: Function
8
8
end
9
9
(x:: Variable )(args... ) = Operation (x, collect (Expression, args))
10
10
11
+ Base. isequal (x:: Variable , y:: Variable ) = (x. name, x. known) == (y. name, y. known)
12
+ Base. show (io:: IO , x:: Variable ) = print (io, x. name)
13
+
11
14
12
15
struct Constant <: Expression
13
16
value:: Number
14
17
end
15
18
Base. get (c:: Constant ) = c. value
16
19
17
-
18
20
Base. iszero (ex:: Expression ) = isa (ex, Constant) && iszero (ex. value)
19
21
Base. isone (ex:: Expression ) = isa (ex, Constant) && isone (ex. value)
20
22
21
-
22
23
# Variables use isequal for equality since == is an Operation
23
- Base. isequal (x:: Variable , y:: Variable ) = (x. name, x. known) == (y. name, y. known)
24
- Base. isequal (:: Variable , :: Number ) = false
25
- Base. isequal (:: Number , :: Variable ) = false
26
- Base. isequal (:: Variable , :: Constant ) = false
27
- Base. isequal (:: Constant , :: Variable ) = false
28
24
Base. isequal (c:: Constant , n:: Number ) = c. value == n
29
25
Base. isequal (n:: Number , c:: Constant ) = c. value == n
30
26
Base. isequal (a:: Constant , b:: Constant ) = a. value == b. value
31
27
32
- Base. convert (:: Type{Expr} , x:: Variable ) = x
33
28
Base. convert (:: Type{Expr} , c:: Constant ) = c. value
34
29
35
- Base. show (io:: IO , x:: Variable ) = print (io, x. name)
36
30
37
31
# Build variables more easily
38
32
function _parse_vars (macroname, known, x)
0 commit comments