🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1691

Re: Abstract Type in Prolog ?

#1691
From: Lee Naish
Date: Fri, 04 Jan 1991 03:16
32 lines
1512 bytes
In article <2493@sparko.gwu.edu> kilian@seas.gwu.edu (Jens Kilian) writes:
>Sure, you can represent abstract data types in Prolog. The main problem is
>that axiomatic specifications of abstract data types are functional, so you
>have to add an output argument to each of the functions to get the
>corresponding Prolog predicates.

This can be done automatically quite easily.  There is a preprocessor
for NU-Prolog which enables you to write the following:

	top(push(I,S)) = I.
	isemptystack(createstack).
	pop(push(I,S)) = S.

	test :- write(top(pop(push(3, push(2, pop(push(1, createstack))))))).

This is translated into the following (plus some goals/declarations):

	top(push(A9, B9), A9).
	isemptystack(createstack).
	pop(push(A9, B9), B9).

	test :-
		pop(push(1, createstack), A),
		pop(push(3, push(2, A)), B),
		top(B, C),
		write(C).

The preprocessor is ftp-able from mullauna.cs.mu.OZ.AU in
pub/nue_prolog.tar.Z.  If anyone has the time to make it more
portable, let me know...

	lee
Technical Details
Message-ID: <6371@munnari.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!lee
References: <1991Jan3.154717.27057@watserv1.waterloo.edu> <2493@sparko.gwu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!lee
From: lee@munnari.oz.au (Lee Naish)
Newsgroups: comp.lang.prolog
Subject: Re: Abstract Type in Prolog ?
Message-ID: <6371@munnari.oz.au>
Date: 4 Jan 91 03:16:51 GMT
References: <1991Jan3.154717.27057@watserv1.waterloo.edu> <2493@sparko.gwu.edu>
Sender: news@cs.mu.oz.au
Reply-To: lee@munmurra.UUCP (Lee Naish)
Organization: Comp Sci, University of Melbourne
Lines: 32