-
Notifications
You must be signed in to change notification settings - Fork 1
/
degree-gpe.rkt
36 lines (30 loc) · 895 Bytes
/
degree-gpe.rkt
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
#lang racket/base
;;;; This file has been changed from its original dharmatech/mpl version.
(provide degree-gpe)
(require (only-in srfi/1 every)
"misc.rkt"
"contains.rkt"
)
(define (degree-monomial-gpe u v)
(cond ( (every (is-free? u) v) 0 )
( (member u v) 1 )
( (and (power? u)
(let ((n (list-ref u 2)))
(integer? n)
(> n 1)))
(list-ref u 2) )
( (product? u)
(apply +
(map
(lambda (elt)
(degree-monomial-gpe elt v))
(cdr u))) )
( else 0 )))
(define (degree-gpe u v)
(cond ( (sum? u)
(apply max
(map
(lambda (elt)
(degree-monomial-gpe elt v))
(cdr u))) )
( else (degree-monomial-gpe u v) )))