aboutsummaryrefslogtreecommitdiffstats
path: root/stack.go
diff options
context:
space:
mode:
Diffstat (limited to 'stack.go')
-rw-r--r--stack.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/stack.go b/stack.go
new file mode 100644
index 0000000..182d418
--- /dev/null
+++ b/stack.go
@@ -0,0 +1,16 @@
+package main
+
+type Stack []float64
+
+func (s *Stack) push(v float64) {
+ *s = append(*s, v)
+}
+
+func (s *Stack) pop() *float64 {
+ if len(*s) > 0 {
+ v := (*s)[len(*s)-1]
+ *s = (*s)[:len(*s)-1]
+ return &v
+ }
+ return nil
+}