From 727e3c59346da4f91284b34b4c18f2e0ba155e53 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 9 Aug 2025 16:03:28 +0200 Subject: Initial commit --- stack/src/stack.ads | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 stack/src/stack.ads (limited to 'stack/src/stack.ads') diff --git a/stack/src/stack.ads b/stack/src/stack.ads new file mode 100644 index 0000000..4f390e3 --- /dev/null +++ b/stack/src/stack.ads @@ -0,0 +1,26 @@ +generic + type T is private; +package Stack is + type Stack is private; + + -- Push a value into the stack. + procedure Push (S : in out Stack; Val : T); + + -- Pop a value from the stack. + function Pop (S : in out Stack; Val : out T) return Boolean; + + -- Return true if the stack is empty, false otherwise. + function Empty (S : Stack) return Boolean; +private + type Node; + type Node_Access is access Node; + + type Node is record + Val : T; + Bottom : Node_Access; + end record; + + type Stack is record + Top : Node_Access; + end record; +end Stack; -- cgit v1.2.3