Guest User

Untitled

a guest
May 18th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.57 KB | None | 0 0
  1. (define (p= a b)
  2.   (cond
  3.     ((and (number? a)(number? b)) (= a b))
  4.     ((and (list? a)(list? b)) (equal? a b))
  5.     (#t #f)))
  6.  
  7. (define (variable-less? a b)
  8.   (let ((avar (list-ref a 1))
  9.         (aexp (list-ref a 2))
  10.         (bvar (list-ref b 1))
  11.         (bexp (list-ref b 2)))
  12.     (cond
  13.       ((< aexp bexp) #t)
  14.       ((> aexp bexp) #f) ;; after this it means the exps are equal
  15.       ((string<? (symbol->string avar) (symbol->string bvar)) #t)
  16.       (#t #f))))
  17.  
  18. (define (normalise-term t)
  19.   (append (list '* (second t))
  20.           (sort '(cddr t) variable-less?)))
Add Comment
Please, Sign In to add comment