🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.prolog
2 messages
2 total messages Started by Guy Cohen Sat, 25 Mar 2000 00:00
Newbie question
#4316
Author: Guy Cohen
Date: Sat, 25 Mar 2000 00:00
8 lines
854 bytes
Hi there
I want to declare "notin"
Lets say I have a list L1
and a X that is not in the list
notin will say "yes"

TIA
A Newbie Guy
Re: Newbie question
#4317
Author: Alex MacAskill
Date: Sat, 25 Mar 2000 00:00
28 lines
1211 bytes
Guy Cohen wrote:
> 
> Hi there
> I want to declare "notin"
> Lets say I have a list L1
> and a X that is not in the list
> notin will say "yes"
> 
> TIA
> A Newbie Guy

This is very simple if you look at 
member/2

member(X,L1) takes X which is a single
element, and L1 is a list.
It returns yes if X is in the list
and no if not.

so for your problem you could use

notin(X,L1) :- not member(X,L1).

Which will return yes if X is NOT
in the list.


Alex
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads