Guest User

Untitled

a guest
May 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.50 KB | None | 0 0
  1. ;;; Make a new term where the coeffecient is x
  2. ;;; and the power to which its being raised is y
  3. (define (make-term x y)
  4.   (list x y))
  5.  
  6. ;;; Gives the coefficient of a term
  7. (define (coefficient t)
  8.   (list-ref t 0))
  9.  
  10. ;;; Gives the power to which the term is being raised
  11. (define (power t)
  12.   (list-ref t 1))
  13.  
  14. ;;; Prints the term in the form:
  15. ;;; coefficient x variable ^ power
  16. (define (print-term t)
  17.   (begin
  18.     (display (coefficient t))
  19.     (display "x")
  20.     (display "^")
  21.     (display (power t))))
Add Comment
Please, Sign In to add comment