Subject: SV: SDL-News: Stacks in SDL
From: Anders Olsen (consult#cinderella.dk)
Date: Sun Feb 25 2001 - 13:27:39 GMT
Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From "Anders Olsen" <consult#cinderella.dk> to sdlnews -----
Dear Garth
Looking at the SDL news list, I just noticed that there were replies saying
that
C code is needed for defining a stack.
Actually, defining a stack in SDL-96 is very easy and requires only a few
lines of PR
as shown below.
Regards Anders
Cinderella ApS
www.cinderella.dk
---------------------------------------
newtype Stack<newtype Elementtype>
String(Elementtype,emptyStack);
adding
operators
Push : Elementtype, Stack -> Stack;
Top : Stack -> Elementtype;
Pop : Stack -> Stack;
operator Push; fpar e Elementtype, s Stack returns Stack;
start;
return Mkstring(e) // s;
endoperator;
operator Top; fpar s Stack returns Elementtype;
start;
return s(1);
endoperator;
operator Pop; fpar s Stack returns Stack;
start;
return Substring(s,2,Length(s)-1);
endoperator;
endnewtype;
> -----Oprindelig meddelelse-----
> Fra: owner-sdlnews#sdl-forum.org [mailto:owner-sdlnews#sdl-forum.org]På
> vegne af Garth Watney
> Sendt: 14. februar 2001 17:51
> Til: sdlnews#sdl-forum.org
> Emne: SDL-news: Stacks in SDL
>
>
> Become an SDL Forum Society member
> <http://www.sdl-forum.org/Society/members.htm>
> The originator of this message is responsible for its content.
> -----From Garth Watney <Garth.J.Watney#jpl.nasa.gov> to sdlnews -----
>
> Hi all,
>
> I have need for a stack class in my SDL application. (with typical
> operations like push and pop). Does anyone know where I may pick
> one up? I
> imagine it has been before, and I don't feel like reinventing the wheel.
>
> Thanks
> Garth
>
>
> --End text from Garth Watney <Garth.J.Watney#jpl.nasa.gov> to sdlnews ---
> For extra SDL Forum Society benefits join at
<http://www.sdl-forum.org/Society/members.htm>
or (iff this does not answer your question) email:
owner-sdlnews#sdl-forum.org
--End text from "Anders Olsen" <consult#cinderella.dk> to sdlnews ---
For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>
This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT