Question

With the help of a suitable example, describe the “member” function of PROLOG. How it can be used for searching of a data in a list, recursively.

16 Sep 2022
Answer :
Word Count : 1128

In PROLOG, the "member" function is a built-in predicate that checks whether an element is a member of a given list or not. The syntax of the member function is as follows:


member(X, [X | _]).
member(X, [_ | T]) :- member(X, T).
The member function takes two arguments. The first argument, X, is the element we want to search for in the list. The second argument is the list that we want to search in. If X is a member of the list, the member function will return true, and if X is not a member of the list, the member function will return false.

Let's take an example to understand the working of the member function in PROLOG. Suppose we have a list of numbers, and we want to check whether a particular number is a member of that list or not. We can use the member function in PROLOG to achieve this.

Consider the following PROLOG code:


member(X, [X | _]).
member(X, [_ | T]) :- member(X, T).

% list of numbers
numbers([1, 2, 3, 4, 5, ____ _____ _________ ___ ______ ___ _______ _________ ____ ____ ___ ________.
_______ _______ ______ ________ _____ _______ ____ ___ ______ ____ ______.
________ __________ ________ _________ ___ ________ _______ ____ _______.
____ ___ ______ ___ _______ ____ ____ ___ _________ ____ ____ _________.
______ _________ ____ _________ ____ ___ ____ ____ __________.
_____ _____ ______ ___ ________ ______ ________ _____ ______ __________ _____.
__________ _____ ___ ______ _______ ___ _________ ______ ________ _____ _________ __________.
__________ _____ ___ ________ ___ ______.
___ ____ ___ ___ ____ ____ ____ ____.
____ ____ ________ ___ _______ ___ ______.
_________ _______ _____ ___ _____ _______ _____ ________ _______ ___ __________.
___ _____ ___ _____ __________ _______ _______ ___ _____ _______ ____ _____.
_______ _______ _____ ___ _______ ________ ___ _____ __________ _______ ___ __________.
__________ __________ _________ _________ ______.
________ ___ _______ _________ _________.
____ __________ _______ ___ ________ ______ ________ ____ ______ ________ _______.
____ _________ __________ ___ ___ ________ ___ ____.
___ __________ _______ ______ _________ ______ ______ ___ ________.
________ _________ ______ ______ ___ _________ _________ _____ ____ _______.
________ _______ _________ ______ __________ ______ __________ _______ ________ _________ __________.
____ ____ _______ _____ ___ ________ _____ ______ ________ ______ _________.
________ _______ __________ _______ ______ __________ ______ ___ _______ __________.
____ _________ __________ ______ ____ __________ _________ _______ _______.
___ ____ _______ _____ ________ _____ ________.
_____ _________ _________ _____ _________ _________ ____ _________ _______ ___ ____ _______.
___ ____ _______ ________ ________ ___ ________ ___ _______ ____.
____ _________ __________ ____ ___ ______ _______ ______ _____ ________ ________.
______ _________ _____ ____ ___ ________ ___ __________.
______ __________ _____ ______ ______ ____ ___ _____ ___ _______ ________ ________.
________ _______ ________ ____ ________ __________ ___ ________ __________ _____.
___ ________ _____ __________ _________ _____ ____ _________ ____ __________.
______ ______ __________ ____ ____ ________ ____ ___ ________ ____ ______ _______.
_____ _________ _________ ______ _______ _____ ___ _______ _______.
_________ _________ _________ ____ _______ _________ ____ _____ __________ ______.
___ _________ ______ ______ _____ ______.
_______ ___ __________ _________ ____ __________.
________ __________ _______ ______ ____ ___.
_______ ___ _______ _____ ________.
__________ _______ ________ ____ ________ ______ ______.
________ __________ __________ __________ _______ ________ _______ _________.
___ ____ _______ ____ __________ ____ _____ ___ _______.
_____ __________ _________ __________ _______ _________ _____ _________.
_____ _________ ___ ________ _________ ______ _____ ___ _______ _____ ________ ________.
_____ _______ ____ ____ _____ __________ ________ ________ ______ ____ __________.
________ ________ _______ __________ ______ ____ _____ ____ ________ ___ _____ ___.
___ ________ ___ ________ ______ ____ ___ _____ ____ _________ __________.
______ ______ _____ _____ __________ __________.
_______ ____ _____ _______ ___ ________.
_________ _____ _______ _________ ________ __________ ________ ____ ___.
_____ _________ _______ _____ _____ ________.
______ _______ ___ _______ _______ _____.
___ ________ _________ _____ _______ ___.
____ ________ ____ ___ ________ __________ ____ _____.
_________ _________ ___ ____ ______ ___.
_____ ________ ___ _________ __________ _________ ______.
______ ___ __________ __________ ______ _________.
______ _____ ________ __________ __________ _________ ________ ______ ______ __________ ____.
_________ _____ ___ _________ ____ ____ _______ __________.
________ ________ _____ _________ ________.
________ ____ _____ ___ ___ _____ ________ _______ _______ ______ _______.
__________ _______ _______ ___ ___ _____ ____ ____ _____.
__________ _______ _____ __________ _____ ____ ______ ____ ________ _________.
_______ __________ ________ ______ _______ ____ _________ __________.
_______ ___ ______ _______ _________ _________ _____ ___ __________ ____.
________ ____ __________ ________ ___ _____ _________.
_____ ______ __________ _____ _______ _______.
___ _____ _______ ________ ____ ________.
__________ ______ ____ ___ ___ ____ ____ _____ __________ _________ ___ __________.
___ _______ ________ _____ _________ _____ ______.
___ ____ ___ __________ __________ ______ _______ ____ ____ __________ _____ ________.
_________ _____ ____ _________ ______ ________ _______ __________ ____ __________.
_____ _________ _____ ________ _______ ________ ________ _______ __________ _________ _________.
__________ ____ __________ _______ _______ ____ ________ __________ ______.
___ _______ ________ __________ _________ ________ ______ _________ ____ ____ ______ ________.
__________ _____ _________ __________ _______.
_______ ___ _____ _______ ____ ____ __________ ____ ______ ________ _____.
_______ ___ ___ ______ _________.
___ _________ ___ ___ ________ ___ _____.
_______ ___ ______ _____ _____.
_______ ______ ___ ____ __________ __________ ______ ___ ______ __________.
_______ ________ ___ _____ _________ ______ _______ _________ ____ _________.
________ ______ ____ ______ __________ ____ ___ ________ ________ _____ ________ ________.
___ _______ _____ __________ _____ _____ ________ ____ _________ ________ __________.
______ _________ ____ _________ ___ ______ _____ __________ _______.
________ ______ _____ ________ ________ _____ _______ ________ ________ ___.
____ ___ ____ ________ ____ ________ _________ _______ ____ ___.
________ _______ ________ ____ ___ ______ ______ _____ _______ ________.
_______ _________ ______ _________ _____ __________ ___ ____ ________.
___ _______ ____ _______ _________ ______ ______ __________ ________ ___ _________ _______.
__________ ______ ________ _____ ____ _________ _______.
______ ____ _____ ________ _______ __________ ____ ____ ___ ____.
______ ______ _________ ____ _____ _______ ____ _____.
___ ______ _________ _______ ___ _____ _______ _________ __________.
_________ _________ _______ ____ _________ ________ _____.
________ ____ ______ ______ ______ _________ ___ _______ ___ _______ _________.
_______ __________ ___ __________ _______.
______ _______ ____ ____ ______ _________.
______ __________ ______ _______ __________ ______ _________ _______ _______ ___ _____.
___ ___ ___ _______ _____ ________ ______ ________ ___ _______ ______.
____ ______ _________ ____ _______.
_________ _________ _______ ________ ____.
_______ ________ ____ ____ ___ ____.
______ ______ _____ _________ _______ ______ ____ ______ __________.
____ ____ ____ _______ ___ ___.
________ ______ _______ __________ ____ _____ __________ _________ __________.
_____ _______ _____ ________ ____ _________ ______ _______ ____.
______ _______ _______ ______ ________ ___ _____.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance With the help of a suitable example, describe the “member”
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→