Can't compile with data declared as fact.

Discussions related to Visual Prolog
Posts: 12
Joined: 8 Sep 2019 15:59

Can't compile with data declared as fact.

Unread post by jeangil » 1 Jan 2020 18:24


As you see I'm new with Prolog and POO.
I enconter many difficulties with VP, but I'm persevering...
Today I can't run program I wrote with data declared as class facts.
it give me a compile error on Clause Run:

e631 The predicate 'main::run/0', which is declared as 'procedure', is actually 'nondeterm'

The error seems to be on the line : "male(X).." in Run Clause.
But I don't know why..?
Could you help ? :?

Thanks :-)

NB(Forgot my last topic 2 days ago..)

see my listing below:

Code: Select all

implement main     open core   domains     person = symbol.     subject = symbol.     age_year = integer.     college_year = integer.   class facts     male : (person) nondeterm.     female : (person) nondeterm.     year : (person, college_year) nondeterm.     studies : (person, subject) nondeterm.     age : (person, age_year) nondeterm.   clauses     male("tim").     male("marc").     male("simon").       female("louise").     female("hazel").     female("marie").       year("tim", 4).     year("marc", 1).     year("simon", 2).     year("louise", 3).     year("hazel", 1).     year("marie", 4).       studies("tim", "history").     studies("marc", "philosophy").     studies("simon", "mathematic").     studies("louise", "computer_science").     studies("hazel", "chemistry").     studies("marie", "art").       age("tim", 24).     age("marc", 18).     age("simon", 25).     age("louise", 21).     age("hazel", 22).     age("marie", 32).   clauses     run() :-         console::init(),         male(X),         stdio::writef("% is a male \n", X).   end implement main   goal     console::runUtf8(main::run).

User avatar
Thomas Linder Puls
VIP Member
Posts: 1632
Joined: 28 Feb 2000 0:01

Re: Can't compile with data declared as fact.

Unread post by Thomas Linder Puls » 1 Jan 2020 22:57

Your male fact is nondeterm, and therefore run becomes nondeterm. But run is declared to be a procedure.

You can solve the problem using foreach like this:

Code: Select all

clauses     run() :-         foreach male(X) do             stdio::writef("% is a male \n", X)         end foreach.
I suggest you work through these lessons.
Regards Thomas Linder Puls

Post Reply