-
Notifications
You must be signed in to change notification settings - Fork 5
/
variables.sls
61 lines (48 loc) · 1.35 KB
/
variables.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
60
61
#!r6rs
(library (mpl variables)
(export variables)
(import (rnrs)
(mpl misc)
(only (surfage s1 lists) lset-union)
)
(define (union . lists)
(apply lset-union (cons equal? lists)))
(define (VAR-1 u)
(and (number? u) '()))
(define (VAR-2 u)
(and (power? u) ;; VAR-2
(let ((n (list-ref u 2)))
(and (integer? n)
(> n 1)))
(list (list-ref u 1))))
(define (VAR-3 u)
(and (sum? u)
(apply union
(map
(lambda (operand)
(or (VAR-1 operand)
(VAR-2 operand)
(VAR-4 operand)
(VAR-5 operand)))
(cdr u)))))
(define (VAR-4 u)
(and (product? u)
(apply union
(map
(lambda (operand)
(or (VAR-1 operand)
(VAR-2 operand)
(and (sum? operand) (list operand))
(VAR-5 operand)))
(cdr u)))))
(define (VAR-5 u)
(list u))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (variables u)
(or (VAR-1 u)
(VAR-2 u)
(VAR-3 u)
(VAR-4 u)
(VAR-5 u)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
)