Smatchcube's website 🌍


Exercise 2.84

For simplicity let’s solve the case where we have only two arguments.

Explanation:\ If the args are not of the same type we call successive-raising. This procedure try to “convert” the first argument to the second argument and vice versa. If one of the two conversion is successful the apply-generic procedure is then called on the converted arguments, if no conversion is successful an error is returned.

Now we can do operations like adding a rational number with a complex number:

During the evaluation the rational number is transformed to a scheme-number and then to a complex number which is the same type of the second argument: the add procedure can be finally applied.