Prolog not showing full list of answer

When I run query human(Who). on the below .pl file

human(ann).
human(george).
human(mike).

I only get back Who = ann .

Instead of

Who = ann ;
Who = george ;
Who = mike.

Am using prolog 6.6.6. How do I get it to show the full list?

2 Answers

  1. Lance- Reply

    2019-11-14

    The answer you got was the following. Do you note the space before the dot?

    Who = ann .
             ^ SPACE!!!
    

    This space means: The query was aborted. Maybe you typed return. Or maybe you have a somewhat illconfigured terminal.

    To better check this, try:

    ?- X = 1 ; X = 2 ; X = 3.
    

    There you should get all three answers, too. If not, it is definitely your terminal

  2. Larry- Reply

    2019-11-14

    What you are seeing is the default behaviour of prolog.

    The query

     ?-  findall(Object,Goal,List).
    

    Should work for you.

    Eg.

    findall(X, human(X), L).
    

    It will populate the list with all possible answers.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>