🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4317

Re: Newbie question

#4317
From: 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
Technical Details
Message-ID: <38DD1C85.F9F64373@acadiau.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8bi0ni$f3b$1@news.netvision.net.il>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f907c,d3a4947773cf8781
X-Google-Attributes: gidf907c,public
X-Google-Thread: f8272,d3a4947773cf8781
X-Google-Attributes: gidf8272,public
From: Alex MacAskill <026759m@acadiau.ca>
Subject: Re: Newbie question
Date: 2000/03/25
Message-ID: <38DD1C85.F9F64373@acadiau.ca>
X-Deja-AN: 602336008
Content-Transfer-Encoding: 7bit
References: <8bi0ni$f3b$1@news.netvision.net.il>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: marc.fournier@acadiau.ca
X-Trace: poseidon.acadiau.ca 954014858 2470 142.177.64.10 (25 Mar 2000 20:07:38 GMT)
Organization: Acadia University
Mime-Version: 1.0
Newsgroups: comp.lang.prolog,ed.prolog