0% found this document useful (0 votes)
60 views1 page

Output:-: Program:6 Aim:-Write A Prolog Predicate To Check Whether Given Number Is Member of List or Not Coding

This document contains a Prolog program to check if a given number is a member of a list. The program defines a member/2 predicate that takes a list and integer as arguments. It uses base cases to check if the list is empty or if the head of the list is equal to the integer. It recursively checks if the integer is equal to the head or calls member on the tail to see if the integer is in the rest of the list.

Uploaded by

Rohtash Sethi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views1 page

Output:-: Program:6 Aim:-Write A Prolog Predicate To Check Whether Given Number Is Member of List or Not Coding

This document contains a Prolog program to check if a given number is a member of a list. The program defines a member/2 predicate that takes a list and integer as arguments. It uses base cases to check if the list is empty or if the head of the list is equal to the integer. It recursively checks if the integer is equal to the head or calls member on the tail to see if the integer is in the rest of the list.

Uploaded by

Rohtash Sethi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

IS PRACTICLE LAB FILE(GROUP2)

PROGRAM:6 Aim:-Write a prolog predicate to check whether given number is member of list or not Coding:domains list=Integer*. X=Integer. predicates member(list,Integer). clauses member([],X):-write("list is empty"). member([H],X):-H=X,write(X,"is in list"). member([H],X):-H<>X,write(X,"is not in list"). member([H|T],X):-X=H,write(X,"in list"). member([H|T],X):-X<>H,member(T,X).

Output:-

RASHMI SAPRA

11CSE42

You might also like