README.md

December 4, 2022 ยท View on GitHub

implementation of a stack in Object Pascal

Description

A stack coded in Object Pascal. Works with FreePascal and Delphi.

More Info

Submitted On
ByPatrick B.^
LevelBeginner
User Rating4.1 (29 globes from 7 users)
CompatibilityDelphi 5
CategoryData Structures
WorldDelphi
Archive File

Source Code

{ implementation of a stack in Object Pascal
  written by Jared Bruni
  www.LostSideDead.com
}
program stack;
{$APPTYPE CONSOLE}
uses
 SysUtils;
var
array_stack: array [0..255] of string;
pos: integer = 0;
s: string;
i: integer;
procedure push(str: string);
begin
array_stack[pos] := str;
inc(pos);
end;
function pop(): string ;
begin
dec(pos);
result := array_stack[pos];
end;
function get(at: integer): string;
begin
result := array_stack[at];
end;
function size(): integer;
begin
result := pos;
end;
begin
push('hello');
push('world');
push('stack');
push('in pascal');
push(':)');
for i := 0 to size() do begin
writeln(get(i));
end;
read(s);
end.