-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcoeff-var-monomial.sls
46 lines (27 loc) · 1011 Bytes
/
coeff-var-monomial.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
#!r6rs
(library (mpl coeff-var-monomial)
(export coeff-var-monomial)
(import (mpl rnrs-sans)
(mpl arithmetic)
(mpl contains))
;; (define (coeff-var-monomial u v)
;; (let loop ( (coefficient-part u)
;; (variables v) )
;; (if (null? variables)
;; (let ((variable-part (/ u coefficient-part)))
;; (list coefficient-part variable-part))
;; (loop (/ coefficient-part (car variables))
;; (cdr variables)))))
(define (coeff-var-monomial u v)
(let loop ( (coefficient-part u)
(variables v) )
(cond ( (null? variables)
(let ((variable-part (/ u coefficient-part)))
(list coefficient-part variable-part)) )
( (free? u (car variables))
(loop coefficient-part
(cdr variables)) )
( else
(loop (/ coefficient-part (car variables))
(cdr variables)) ))))
)