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, 6, 7, 8, 9, 10]).

% check if 4 is a member of the list of numbers
?- numbers(List), member(4, List).
In the above code, we first define the member function, which takes two arguments _______ _______ _____ _____ _________ _________ _________ ________ _____.
__________ ______ ________ ___ _____ ________ _________ _________ __________ ____ ________ ______.
________ __________ ___ ___ ________.
_______ __________ __________ _________ ________ _______ _________ ________ __________ _____ ____.
___ ________ ___ ______ ___ ___ ____ __________ ___.
____ _________ _____ ___ ______ _____ ________.
_____ _________ _________ _________ ____.
____ ________ __________ ______ ________ ____ _______ ______ ___.
_________ _________ _____ _________ _________ _______ ______ ___ ____.
__________ ___ ______ ___ __________ ______ _________ _________.
______ ____ _______ __________ ___ _________.
____ _____ ________ _________ _________ __________ ________ _____ _________ ______ _________.
_______ ________ ________ ___ _______ ___ ___ _____ _______ _______ _________ __________.
_____ ____ _____ ______ ___ ________ ____ ___ ______ _________ _____.
________ ________ _______ ____ ____ __________ __________ _____ _________ ______ ______.
_______ ______ _______ __________ _________ __________ _________ ___ ___ ________ ___ ___.
________ __________ _____ _______ _____.
__________ ________ _______ ________ ____.
_________ __________ _________ _____ ___ _____ _______.
_____ _____ ________ __________ ______ _________ ____ ________ ____ ____.
___ ______ _____ ________ __________ ______ ____ ____ ______.
_____ ______ ______ _______ ________.
________ ______ ___ _____ _________ _________ __________ _______ _______ ________.
___ _____ ______ __________ ___ _____ __________ __________ ____ _____.
____ ___ ________ __________ ______ _________ _____ _______ ______ _____ _______ __________.
_______ _________ _________ __________ _________ _________ ________ ________ _____ _____ ________.
__________ _____ ___ __________ ___ _____ _________ _____ ________ _______ _______ __________.
_________ ______ __________ _______ ________.
________ _____ ___ ______ _________ __________ ___ ______ __________ __________ _____ ______.
______ _____ __________ ______ ___ __________.
_________ _________ ________ ________ _____ __________ _______ _______ _________ ________ _______.
_______ _________ ________ ______ _____.
______ _____ ____ _____ _________ ___.
____ _______ _________ _______ ___ _____ ________ ____ ______ ______ _________.
___ _____ _______ ______ __________ _______.
__________ ________ _____ ________ __________ ____ _________ ____ ________ __________ _____ ____.
____ _____ __________ ____ _________ _____.
_______ _________ _____ ________ __________ _______.
__________ _____ _____ _________ _____ ____ ____ __________ ____.
___ ______ ________ _________ _____ _______ ___ ______ ______ ____.
_______ ______ _____ ________ _______ _______ ___ ___ ___ _____.
_______ ________ __________ ______ __________ __________ _______ ____ __________ ______.
________ __________ _________ ______ ________ __________.
__________ ___ ________ __________ _______ ___ __________ ________ ___ ____.
________ __________ __________ ___ ______ __________ ________ ________ ________ ______ ______ _________.
_______ __________ ________ ______ ______ _______ ______ ____ _______ ______ ________ ____.
___ ___ ______ __________ __________ __________ __________ ___ ________ _______ _____ __________.
_________ _________ _________ ____ _______ _______.
____ ________ ______ _________ _______ ________ ________ ________.
_____ ____ ________ _________ ______.
___ ___ ______ ________ ___ ____ __________ ________ _________ _________ _______.
_________ ____ _______ ___ _____ ___ _____ _______ ___ ______.
_______ ________ _____ _______ ______ _______ _____ ______ ___.
_______ _____ ________ ____ ___ ____ ____ _______.
_____ _________ ______ ____ ____ ______ _________.
_______ ____ ____ _____ _____ _______ _____ __________ _________.
__________ __________ ___ ________ _____.
__________ _______ _________ ______ __________ _____ _________.
__________ _____ _________ ___ ___ ___ ______ _________.
____ ____ ____ ___ _____ _________.
____ ________ ____ __________ _________ ____ ______ ___.
_____ ______ _________ ______ _______ _______ ______ _______ _______ __________ _______ _____.
____ __________ _______ _____ ___ ______ ___ ______ __________ __________.
__________ _______ ____ ______ ___ ____ _____ _________ _________.
_________ ______ __________ _______ _______ ____.
____ ______ _________ ____ ___ __________ __________ ____ _______ _________.
________ _____ ___ ______ ______ ____ ___ _________ ____ ____ _____ _________.
________ ________ __________ ___ ____ ______ __________ ______ _________ _______.
_____ ____ __________ _________ _______ __________ ____ ____.
_____ ______ ____ _________ _____ ___ __________ _______ ________ ___.
________ _____ _____ ___ ______ _____ ___ ______ _____ ________ __________ _______.
_________ _______ ___ ______ _____ ______ ___.
_____ ______ __________ _________ ___ _________ _______ _____ __________ __________ _____.
______ ________ _________ ________ ______ ___ ____ __________ ____ _____ ______ ________.
_______ _____ ______ __________ _________ _________ ____ _____ ____ _________.
_______ _______ ___ _____ ____ ________ _________ ______ _________ _________.
___ ______ ___ _____ _________ __________ ___.
_______ __________ ______ __________ _________ ______ ___ ___ ______ ______.
___ ________ ______ _________ ___ ___ _____ ___ _____.
___ ____ ________ ______ _________ _____.
________ ____ _____ ___ _____ ______ _____.
_________ _____ ___ ___ ____ _______ ____ __________.
_________ _________ _________ ____ _______ _______.
_________ ____ _______ ___ ____ _______ ___ ________ _________ __________ ___.
_____ ___ _______ ____ ___ __________ _____ ____.
___ ___ _____ __________ _____ _______ ___ ________.
_________ ______ ___ ________ ___ ____ ___ _______ ______ _____ ____.
__________ _____ __________ __________ ________ _________ _____ ________ __________.
_____ ________ ________ _____ _______.
_______ __________ ________ _____ _______ ____ __________ __________ __________ _________ ___.
____ ____ ______ _____ _______.
_______ ________ ________ _______ __________ _____.
______ ____ __________ ___ ______ __________ _________ ________ ____.
__________ __________ _____ ____ ___.
____ ___ __________ ____ _______ ________ _________ _________ ________ ___ ____ ______.
_________ _______ ____ ____ ___ ________ ________ ___.
_________ _____ _______ _________ ______ _________ __________ _____.
___ ______ __________ _______ _________ _________ _________ ___ ____.
____ _________ _______ ________ _________ ____ ____.
____ _______ ____ ___ ______ ______ ________ _________ ______.
____ _______ _________ _____ ____ ______ _________ _______ ______ ___ ______ ________.
____ __________ ______ __________ ___ __________ ____ ________ __________.
____ _______ _________ _________ ______ ______ ______ _________ _______ ___ ___ __________.
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