🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3318

Re: Ranges of values in Cprolog

#3318
From: Nik. Markantonatos
Date: Thu, 05 May 1988 14:24
144 lines
4317 bytes
/* acf5:comp.lang.prolog / asst-jos@yetti.UUCP (Jonathan) /  2:49 pm  May  4, 1988 */

	I am working with C-prolog 1.5, and have implemented the following
predicate for sets. (I use lists to implement sets)

:- op(500, yfx, in).

X in [X|Rest].
X in [Y|Rest] :- X in Rest.

?- 3 in [1,2,3].

yes
?- X in [1,2,3,4].
X = 1;
X = 2;
X = 3;
X = 4;
no
?-

I use this (in conjunction with higher level predicates) to return the 
state of a set of variables, one at a time, (ie. on failure, as in setof/3).
I would to implement the this 'in' operator to allow for the following:
	(The '..' would have the same meaning as it does in Pascal).


?- X in [1 .. 100].
X = 1;
X = 2;
X = 3;
  .
  .
  .
X = 100;
no
?-


Unfortunately, I keep running into problems when attempting this, and I am 
tired of hitting my head against a brick wall. Any suggestions???


Thanks in advance.

-------------------------------------------------------------------------
Jeffrey Klein                 BITNET: PROJ15@YUSOL
York University                 UUCP: ...!utzoo!yunexus!yuyetti!asst-jos
Toronto, Ontario  
-------------------------------------------------------------------------
/* ---------- */
Relay-Version: version nyu B notes v1.5 12/10/84; site acf5.NYU.EDU
From: nxm7669@acf5.NYU.EDU (Nik. Markantonatos)
Date: 5-May-88 10:39 EDT
Date-Received: 5-May-88 10:39 EDT
Subject: Re: Ranges of values in Cprolog
Message-ID: <1840002@acf5.NYU.EDU>
Path: acf5!nxm7669
Newsgroups: comp.lang.prolog
Posting-Version: version nyu B notes v1.5 12/10/84; site acf5.NYU.EDU
Organization: New York University
References: <242@yetti.UUCP>



Sorry for the previous null posting.

The following program seems to be solving your problem with ranges in sets:

:- op(500,yfx,in).
:- op(400,xfx,..).

X in [Y..Z|Rest] :- !, range(Y,Z,Range), append(Range,Rest,Set), X in Set.
X in [X|Rest].
X in [Y|Rest] :- X in Rest.

range(X,Y,[X|Xs]) :- X =< Y, X1 is X + 1, range(X1,Y,Xs).
range(X,Y,[]) :- X > Y.

append([X|Xs],Ys,[X|Zs]) :- append(Xs,Ys,Zs).
append([],Ys,Ys).

?- X in [1..2,6,7,8..8,9,10..9,10].

X = 1;
X = 2;
X = 6;
X = 7;
X = 8;
X = 9;
X = 10;
no


Nick Markantonatos


Relay-Version: version nyu B notes v1.5 12/10/84; site acf5.NYU.EDU
From: gxp7658@acf5.NYU.EDU (Georgios Papadopoulos)
Date: 5-May-88 13:45 EDT
Date-Received: 5-May-88 13:45 EDT
Subject: Re: Shutterberg ( Was Re: Want Camera Bag Recommendation)
Message-ID: <1250001@acf5.NYU.EDU>
Path: acf5!gxp7658
Newsgroups: rec.photo
Posting-Version: version nyu B notes v1.5 12/10/84; site acf5.NYU.EDU
Organization: New York University
References: <1238@sbcs.sunysb.edu>

    In response to your search for Shutterbug, the address is:

			SHUTTERBUG
			Dept S067
			5211 S. Washington Ave,
			Titusville, FL 32780

You will also find subscription forms inside the `Outdoor Photographer'
magazine at 42% off ($13.97 for 12 monthly issues).


	-- Georgios Papadopoulos

Relay-Version: version nyu B notes v1.5 12/10/84; site acf5.NYU.EDU
From: efj0712@acf5.NYU.EDU (Roach)
Date: 5-May-88 21:03 EDT
Date-Received: 5-May-88 21:03 EDT
Subject: Re: First time jump; Skydive East
Message-ID: <579@acf5.NYU.EDU>
Path: acf5!efj0712
Newsgroups: rec.skydiving
Organization: New York University
References: <1372@lznv.ATT.COM> <576@acf5.NYU.EDU> <2149@mipos3.intel.com> <578@acf5.NYU.EDU> <16786@cornell.UUCP>
Reply-To: efj0712@acf5.UUCP (Roach)
Lines: 10

Please don't get me wrong, in no way am I blaming what happened to me on
any of the jump masters at SDE.  Wind conditions can vary very quickly,
and the mis-calculation which occured when I jumped may not have been 
that at all.  I think the level of instruction at SDE was very good, as
I have also sat in on a class at SKYDIVE Long Island, and preferred the
training at SDE.  I think, however, that the training at Perris Valley,
CA was superior to both though.

						Roach
Technical Details
Message-ID: <1840001@acf5.NYU.EDU>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!cmcl2!acf5!nxm7669
References: <242@yetti.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!cmcl2!acf5!nxm7669
From: nxm7669@acf5.NYU.EDU (Nik. Markantonatos)
Newsgroups: comp.lang.prolog
Subject: Re: Ranges of values in Cprolog
Message-ID: <1840001@acf5.NYU.EDU>
Date: 5 May 88 14:24:00 GMT
References: <242@yetti.UUCP>
Organization: New York University
Lines: 144