# SICP Solutions

### Section - 2.5 - Systems with Generic Operations

#### Exercise 2.90

Apparently I did not find it as difficult as it seemed from the hint. Perhaps I missed something :)

My understanding is problem requires to implement the polynomial system that can be used for both sparse and dense termlists and all operations can be performed between them. It has not asked to implement procedures that for the efficiency - It only asked to implement system which can enable us to later implement a polynomial system which is efficient for both dense and sparse. I believe so because as per my experience with the old problems - the problem generally gives an outline for what it seeks in the solution - here it only gave an outline to build a system which can enable operations on both term-list.

If the case is to implement the system where our polynomial also decides whether to use sparse or dense then it can also be implemented - we just need to think for the strategy - at how much packing is considered good for sparse and inside make-polynomial we can check with this strategy and do conversions(I have not made this change).

• make-term, coeff, and order are owned by the polynomial package(not by the term-list packages implemented) because they are terms not the list themselves and both packages - sparse-termlist and dense-termlist use them from the polynomial package.
• There is an interesting way I worked around with the adjoin-term - this procedure have different implementation for each package and which should be the part of the respective term-list packages. But I can not apply adjoin-term in generic way because it takes two arguments - term, and termlist - where term does not have any type tag in my implementation because I made term to be owned by polynomial package instead of termlist package(which may be debatable). So, I made adjoin-term-proc - a procedure that returns a procedure! And the returned procedure takes an argument - term and adds it to the list. See the implementation for details.
Note that - my integer representation adds tag - integer and drop is dropping to int when ‘add is performed. Thus (int 5) actually means 5.