From c3d2073b2b941b8dfc35a4922895bb47dac74850 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Tue, 25 Aug 2020 21:06:33 -0800 Subject: [PATCH] Fix bug due to redefining Stack --- djpianalto.com/goff/utils/rpnParser.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/djpianalto.com/goff/utils/rpnParser.go b/djpianalto.com/goff/utils/rpnParser.go index 778a5e7..7f9dff9 100644 --- a/djpianalto.com/goff/utils/rpnParser.go +++ b/djpianalto.com/goff/utils/rpnParser.go @@ -7,17 +7,17 @@ import ( "strconv" ) -type Stack []float64 +type FStack []float64 -func (s *Stack) IsEmpty() bool { +func (s *FStack) IsEmpty() bool { return len(*s) == 0 } -func (s *Stack) Push(op float64) { +func (s *FStack) Push(op float64) { *s = append(*s, op) } -func (s *Stack) Pop() (float64, bool) { +func (s *FStack) Pop() (float64, bool) { if s.IsEmpty() { return 0, false } @@ -27,7 +27,7 @@ func (s *Stack) Pop() (float64, bool) { return element, true } -func (s *Stack) PopTwo() (float64, float64, bool) { +func (s *FStack) PopTwo() (float64, float64, bool) { if s.IsEmpty() || len(*s) < 2 { return 0, 0, false } @@ -39,7 +39,7 @@ func (s *Stack) PopTwo() (float64, float64, bool) { } -func (s *Stack) Top() float64 { +func (s *FStack) Top() float64 { if s.IsEmpty() { return 0 } @@ -47,7 +47,7 @@ func (s *Stack) Top() float64 { } func ParseRPN(args []string) (float64, error) { - s := Stack{} + s := FStack{} for _, token := range args { switch token { case "+":