Triangle: Tests and example solution enforce type equality

Hello there,

During a code review with bomber34, as I’m quite new to Prolog, he pointed out the following(from my solution):

?- triangle(1.0, 1, 1).
false

This happens, because my solution which was similar to the example enforces type equality, and it shouldn’t or should it?
I took the liberty to submit this patch, in case it’s to be considered a bug.
I wasn’t aware of the use of the forum here.

1 Like

cc @ErikSchierboom

1 Like

This test values come from the problem spec. We probably want to keep them the same.

1 Like

I understand.
Appears to be a situation that either the specification adapts to reality or reality to the specification.

In conformance with such rational, only an explicit requirement of type equality appears to be more reasonable, as such wouldn’t invalidate currently valid solutions.

From my point of view, the question about having it as a requirement appears to make little sense either.

Thus in either situation we must either accept current spec with a note on the type equality requirement,
or redesign the spec for this problem.

Can just say, I’m happy not to be making the call, as it appears as a greeks and trojan situation XD

I think this is an interesting addition as it helps make students aware of how to compare values for equality in Prolog (which is a common gotcha). As such, I’m happy to merge this, pending one suggestion made in the PR being applied.