users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

representing 'OR' condition in Prolog..


From: Abhinav-Bhardwaj
Subject: representing 'OR' condition in Prolog..
Date: Thu, 31 Oct 2002 12:07:14 +0530 (IST)

Hi,
I want to know something in general about prolog . I want to know that how do I 
represent an 'OR' condition in prolog.
For eg:- I want to define a leave rule saying that an employee can be granted a 
leave if - employee is a Permanent employee, OR
          -  employee's performance is satisfactory.

leave_granted(Emp) :- employee_status(Emp, permanent).
leave_granted(Emp) :- performance(Emp, satisfactory).

employee_status( raman, permanent).
employee_status( abhinav, temporary).

performance( raman, satisfactory).
performance( abhinav, satisfactory).

leave_report :-
        nl, write('leave may be granted to following employees:-'), nl,
        leave_granted(Emp),
        write('-'), write(Emp), nl,
        fail.

Here is a sample output:
=================
?- leave_granted(raman).

yes
?- leave_granted(abhinav).

yes
?- leave_report.

leave may be granted to following employees:-
-raman
-raman
-abhinav
no
==================
Now my question is:
1) Is this a correct way to represent the rule ?
2) The 'leave_report' displays the name 'raman' twice , and what I want is a 
list of unique names of employees that can be granted leave.

thanks and regards,
Abhinav







reply via email to

[Prev in Thread] Current Thread [Next in Thread]