Article View: comp.lang.prolog
Article #1690Re: Abstract Type in Prolog ?
From: David G. Novick
Date: Thu, 03 Jan 1991 19:26
Date: Thu, 03 Jan 1991 19:26
25 lines
1388 bytes
1388 bytes
Following up yfeng@watnow.waterloo.edu's inquiry about abstract data types in Prolog, here are a couple of definitions I've used. Note that these do *not* create or necessarily reference persistent objects. % define ADT stack with usual operations % s_new([]). s_push(Elt,Stack,[Elt|Stack]). s_pop([_|Stack],Stack). s_top(Elt,[Elt|_]). % define ADT queue with usual operation % q_new([]). q_insert(Elt,Q,Q2) :- append(Q,[Elt],Q2). q_next(Elt,[Elt|_]). q_delete([_|Q],Q). -------------------------------------------------------------------------- David G. Novick | Department of Computer Science and Engineering | Oregon Graduate Institute of Science and Technology novick@cse.ogi.edu | 19600 N.W. Von Neumann Drive (503) 690-1156 | Beaverton, OR 97006-1999 --------------------------------------------------------------------------
Technical Details
Message-ID:
<15580@ogicse.ogi.edu>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!ogicse!novickReferences:
<1991Jan3.154717.27057@watserv1.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!ogicse!novick From: novick@ogicse.ogi.edu (David G. Novick) Newsgroups: comp.lang.prolog Subject: Re: Abstract Type in Prolog ? Message-ID: <15580@ogicse.ogi.edu> Date: 3 Jan 91 19:26:42 GMT References: <1991Jan3.154717.27057@watserv1.waterloo.edu> Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 25 In-reply-to: yfeng@watnow.waterloo.edu's message of 3 Jan 91 15:47:17 GMT