Self-test 5, Task 1, Solutions

Adding to memb_count/2

The requirement for zero to be output can be satisfied by adding a rule to the memb_count/2 procedure:
     /* ************************************************ */
     /*                                                  */
     /*   memb_count/2                                   */
     /*      Arg 1:  Elem to be found                    */
     /*      Arg 2:  List with Elem in                   */
     /*   Summary: calls demo_memb_count/3.              */
     /*   Author: P J Hancox                             */
     /*   Date:   19 October 1994                        */
     /*                                                  */
     /* ************************************************ */

     % 1
     memb_count(Elem, List) :-
          memb(Elem, List, 1).
     % 2
     memb_count(_, []) :-
          write(0),
          nl.