-
Notifications
You must be signed in to change notification settings - Fork 5
/
expand-main-op.sls
59 lines (33 loc) · 957 Bytes
/
expand-main-op.sls
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!r6rs
(library (mpl expand-main-op)
(export expand-main-op)
(import (mpl rnrs-sans)
(mpl match)
(mpl arithmetic)
(mpl misc)
(mpl expand-product)
(mpl expand-power))
;; (define (expand-main-op u)
;; (cond ( (product? u)
;; (expand-product (list-ref u 1)
;; (list-ref u 2)) )
;; ( (power? u)
;; (expand-power (list-ref u 1)
;; (list-ref u 2)) )
;; ( else u )))
;; (define (expand-main-op u)
;; (match u
;; ( ('* a . rest)
;; (expand-product a (apply * rest)) )
;; ( ('^ a b)
;; (expand-power a b) )
;; ( else u )))
(define (expand-main-op u)
(match u
( ('* a . rest)
(expand-product a
(expand-main-op (apply * rest))) )
( ('^ a b)
(expand-power a b) )
( else u )))
)