# SICP Solutions

### Section - 2.5 - Systems with Generic Operations

#### Exercise 2.82

Well, this is an interesting procedure and took me some type to get it working. Mainly I got stuck with calling apply-generic which I was assuming will work like Java(sorry :)), i.e. it can take list also for the variable number of arguments. It turns out that it was not accepting list for variable number of parameters/arguments(turning the list into list of list - causing it difficult to debug). The solution is to use apply.

I also created an auxillary procedure map-until which works like map but returns when it first encounters a given until-val(after applying the proc).

Another thing to note is - I have added check so that procedure apply-generic wont go into infinite recursion - which can happen if all the arguments are of same type and there is no operation op is available in the op-table.

The last part of the problem - Consider the case that we have an operation defined say pow for rational numbers, now if we pass two numbers - then ideally we would expect that both numbers are coerce into rational numbers and then pow is applied but our implementation does not support this.

Output: