# sicp-ex-2.89

meteorgan

``` ;; all we should change are procedure first-term and adjoin-term

(define (first-term term-list)
(list (car term-list) (- (length term-list) 1)))
(let ((exponent (order term))
(len (length term-list)))
(cond ((=zero? (coeff term))
terms))
((= exponent times)
(cons (coeff term) terms))
(cons 0 terms))))
```

hattivat

``` ;; an even shorter solution to achieve the same result

(define (first-term term-list)
(make-term (- (len term-list) 1) (car term-list)))

(cond ((=zero? term) term-list)
((=equ? (order term) (length term-list)) (cons (coeff term) term-list))
(else (adjoin-term term (cons 0 term-list)))))
```

Marisa

We don't need to change much. Also, since adjoin-term is properly used in add-term and mul-term, I don't think we have to change it drastically like some people did.

```
;; List the term, and find the order
(define (first-term term-list)
(list
(car term-list) ; first term
(- 1 (length term-list)))) ; order is length-1 (we index polynomials from 0)

;; Slightly modified to cons the coeff instead of the actual term
(let ((coeff-of-term (coeff term)))
(if (=zero? coeff-of-term)
term-list
(cons coeff-of-term term-list))))

```

felixm

It is probably me, but none of the solution above worked for me.

meteorgan's solution has bracketing errors and even after fixing them there seems to be logical errors.

hattivat uses =zero? directly on term which does not work because add-terms calls adjoin-term on regular terms, i.e. one that have coeff and order.

Finally, Marisa's solution runs, but creates false results for my tests.

The following code worked for me when I added it to the poly-package from the book. Note that not considering zero terms would yield invalid results for multiplication.

```   (define (first-term term-list)
(make-term (- (length term-list) 1)
(car term-list)))