List Member Function using Prolog Source Code
The following code checks if an element is a member of a given list
CODE
member(X, [X|Y]).
member(X, [H|L]) :- member(X, L).
RESULT
?- member(b, [a,b,c]).
Yes
Related Articles
- Appends Two Lists using Prolog Source Code
- Delete all occurrences of an Element from a List using Prolog Source Code
- Delete the Nth Element from the List using Prolog Source Code
- List Length Function using Prolog Source Code
- List Merge Function using Prolog Source Code
- MergeSort Function using Prolog Source Code
- Powersort Function using Prolog Source Code
- QuickSort Function using Prolog Source Code
