🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3316

Re: Ranges of values in Cprolog

#3316
From: Hamid Bacha
Date: Thu, 05 May 1988 19:14
44 lines
1130 bytes
Try the following:


%---------------

:- op(500, xfx, in).
:- op(802, xfx, '..').  % precedence higher than that of '-' to allow 
			% for negative numbers

X in [S .. L] :- S < L, X = S.
X in [S .. L] :- S < L, N is S + 1, X in [N .. L].
X in [X .. X].

%---------------

| ?- X in [-1 .. 2].

X = -1 ;
 
X = 0 ;
 
X = 1 ;
 
X = 2 ;
 
no
| ?- X in [2 .. 1].
 
no
| ?- X in [1 .. 1]. 
 
X = 1 ;
 
no
| ?- X in [1 .. +1].
 
no

Note: The last two examples give different results because 1 is different
from +1 in some Prolog systems (including CProlog 1.5).

H. Bacha 
Logic Programming Research Group
Syracuse University
Technical Details
Message-ID: <451@cmx.npac.syr.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!cornell!batcomputer!itsgw!nysernic!cmx!hilbert!hamid
References: <242@yetti.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!cornell!batcomputer!itsgw!nysernic!cmx!hilbert!hamid
From: hamid@hilbert.uucp (Hamid Bacha)
Newsgroups: comp.lang.prolog
Subject: Re: Ranges of values in Cprolog
Message-ID: <451@cmx.npac.syr.edu>
Date: 5 May 88 19:14:45 GMT
References: <242@yetti.UUCP>
Sender: usenet@cmx.npac.syr.edu
Reply-To: hamid@top.cis.syr.edu (Hamid Bacha)
Organization: CIS Dept., Syracuse University
Lines: 44