Hi,
Is it possible to write grammar for If-else in Prolog?
If yes, Please can some one give me a rough idea of the grammar.
Thanks,
SUDHA
IF-Else in Prolog
Started by navred, Feb 10 2005 10:32 PM
5 replies to this topic
#1
Posted 10 February 2005 - 10:32 PM
#2
Posted 11 February 2005 - 10:16 AM
i'm not entirely sure what you mean... do you just want to know how conditionals in prolog work ?
If Prolog is the answer, what is the question ?
#3
Posted 13 February 2005 - 12:35 AM
Thanks for the reply, I am sorry as the question I framed was really not clear. Let me be a bit detailed:
I want to write a function in prolog for the if-else statement.
For ex,
if-instantiated( X,X) else if-instantiated (Y,Y) else if-instantiated( X^Y, concat(X,Y):-
If the attribute X is instantiated( holds some value) then write X, else if the attribute Y holds some value then write Y, else if both the attributes X and Y hold some values, then append X and Y and write them.
I know how to write the concat function. But I am unaware of writing the function for the above if-else rule. please help me.
Thanks in advance,
SUDHA.P
I want to write a function in prolog for the if-else statement.
For ex,
if-instantiated( X,X) else if-instantiated (Y,Y) else if-instantiated( X^Y, concat(X,Y):-
If the attribute X is instantiated( holds some value) then write X, else if the attribute Y holds some value then write Y, else if both the attributes X and Y hold some values, then append X and Y and write them.
I know how to write the concat function. But I am unaware of writing the function for the above if-else rule. please help me.
Thanks in advance,
SUDHA.P
#4
Posted 13 February 2005 - 11:14 AM
why do you open a new thread with exactly the same message you posted as a reply to this one ?
If Prolog is the answer, what is the question ?
#5
Posted 13 February 2005 - 11:58 AM
Oh Iam sorry. I need the soln very urgently n thought that a new thread wud serve the purpose...
PLease could you help me in writing the function for the above rule in prolog
PLease could you help me in writing the function for the above rule in prolog
#6
Posted 13 February 2005 - 03:42 PM
i'm not very good with prolog... almost never touched it but the following should work
test(X, Y) :-
( /* test value in X */ , /* test value in Y */ ->
// do something
; /* test value in X */ ->
// do something else
; /* test value in Y */ ->
// do something different
).
If Prolog is the answer, what is the question ?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











