Self-test 8 Solutions

Correcting min/3

     /* ************************************************ */      /*                                                  */      /*   min/3                                          */      /*      Arg 1:  number                              */      /*      Arg 2:  number                              */      /*      Arg 3:  number                              */      /*   Summary: Arg3 is the minimum of Arg 1 and      */      /*            Arg 2.                                */      /*   Author: P J Hancox                             */      /*   Date:   26 October 1994                        */      /*                                                  */      /* ************************************************ */      min(Min, Max, Min) :-           Min < Max.      min(Max, Min, Min) :-           Min < Max.
This is easily corrected by the addition of one test. Note that this solution doesn't have recourse to extra-logical extensions of Prolog, such as the cut.