1

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?

false
  • 10,264
  • 13
  • 101
  • 209
Gavin
  • 2,784
  • 6
  • 41
  • 78

2 Answers2

2

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

false
  • 10,264
  • 13
  • 101
  • 209
0

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.

Akshay Arora
  • 1,953
  • 1
  • 14
  • 30
  • That's a little weird. I have watched multiple tutorials and they seems to return a list of answers with just `human(Who).` – Gavin Mar 20 '16 at 06:16
  • 1
    This is an excellent website : http://www.learnprolognow.org/lpnpage.php?pagetype=html&pageid=lpn-htmlse49 – Akshay Arora Mar 20 '16 at 06:18