Open tangjm opened 1 year ago
I'm not confident that this works as expected.
function can_coerce_to(type_tags, target_type) {
return accumulate((type_tag, result) =>
result && type_tag === target_type,
true,
type_tags)
? false
should this not be
... ? true
?
The implementation of the solution doesn't terminate in the case when we try to call a generic operator that is undefined with respect to arguments of the same type.
Consider this example.
I think we can make a slight modification to handle this.
The nub of the issue is that we need to account for when the types are the same but there is no method for them. In terms of the
apply_generic
function presented on p.171 of sicpjs (see below), I think the solution just needs to handle the part I have commented on below.