Re: ADTs
From: Robert STRANDH (strandh_at_labri.fr)
Date: 03/05/04
- Previous message: Arthur J. O'Dwyer: "Re: ADTs"
- In reply to: Michael Mendelsohn: "Re: ADTs"
- Next in thread: Michael Mendelsohn: "Re: ADTs"
- Reply: Michael Mendelsohn: "Re: ADTs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 05 Mar 2004 07:46:17 +0100
Michael Mendelsohn <keine.Werbung.1300@michael.mendelsohn.de> writes:
> The ADT List
> ------------------
>
> 1. Constructors
>
> Empty() : List;
> constructs an empty list.
> Cons(I : InfoType ; L : List) : List;
> inserts item I at the head of the list L.
>
> 2. Predicates
>
> IsEmpty(L : List) : Boolean;
> checks the list to determine whether it is empty
>
> 3. Selectors
>
> Head (L : List) : Infotype;
> returns the item at the head of the list
> Tail (L : List) : List;
> returns the list which results from removing the head
It is interesting to observe as well that this set of operations is
identical to that defining a stack :
1. Constructors
Empty() : Stack;
constructs an empty stack.
Push(I : InfoType ; S : Stack) : Stack;
inserts item I at the top of the stack S.
2. Predicates
IsEmpty(S : Stack) : Boolean;
checks the stack to determine whether it is empty
3. Selectors
Top (S : Stack) : Infotype;
returns the item at the top of the stack
Pop (S : Stack) : Stack;
returns the stack which results from removing the top
-- Robert Strandh --------------------------------------------------------------------- Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp. ---------------------------------------------------------------------
- Previous message: Arthur J. O'Dwyer: "Re: ADTs"
- In reply to: Michael Mendelsohn: "Re: ADTs"
- Next in thread: Michael Mendelsohn: "Re: ADTs"
- Reply: Michael Mendelsohn: "Re: ADTs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|