Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (p= a b)
- (cond
- ((and (number? a)(number? b)) (= a b))
- ((and (list? a)(list? b)) (equal? a b))
- (#t #f)))
- (define (variable-less? a b)
- (let ((avar (list-ref a 1))
- (aexp (list-ref a 2))
- (bvar (list-ref b 1))
- (bexp (list-ref b 2)))
- (cond
- ((< aexp bexp) #t)
- ((> aexp bexp) #f) ;; after this it means the exps are equal
- ((string<? (symbol->string avar) (symbol->string bvar)) #t)
- (#t #f))))
- (define (normalise-term t)
- (append (list '* (second t))
- (sort '(cddr t) variable-less?)))
Add Comment
Please, Sign In to add comment