Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

WAP to search an element in a list.

WAP to search an element in a list.
domains
namelist=name*
name=symbol

predicates
member(name,namelist)
go

clauses
go:-
readln(X),
member(X,[a,s,d,f,g,h,j]).

member(Name,[Name|_]).
member(Name,[_|Tail]) if member(Name,Tail).





Output:-

Goal: member(x,[a,b,c,x,y,z])
Yes
Goal: member(x,[p,q,r,s])

No
Previous
Next Post »