aboutsummaryrefslogtreecommitdiffstats
path: root/calculator.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-07-28 19:51:09 -0230
committerSam Anthony <sam@samanthony.xyz>2023-07-28 19:51:09 -0230
commit04ba853e7b9ad245865b6e9b4387d2efc144fc72 (patch)
tree1a3b337c08e02dd76546377dc72df30882ad0c11 /calculator.go
parente89fd14004291f65998b8fa6b5febc2d2fdc52d6 (diff)
downloadpfc-04ba853e7b9ad245865b6e9b4387d2efc144fc72.zip
rename Calculator.buffer to Calculator.buf
Diffstat (limited to 'calculator.go')
-rw-r--r--calculator.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/calculator.go b/calculator.go
index 30cc7ec..08193b4 100644
--- a/calculator.go
+++ b/calculator.go
@@ -5,8 +5,8 @@ import "strconv"
type Stack []float64
type Calculator struct {
- stack Stack
- buffer string
+ stack Stack
+ buf string
}
// add performs addition when the user inputs the '+' operator.
@@ -14,13 +14,13 @@ func (c *Calculator) add() {
if len(c.stack) < 1 {
return
}
- if con := parseConstant(c.buffer); con != nil {
+ if con := parseConstant(c.buf); con != nil {
c.stack[len(c.stack)-1] += *con
- } else if f, err := strconv.ParseFloat(c.buffer, 64); err == nil {
+ } else if f, err := strconv.ParseFloat(c.buf, 64); err == nil {
c.stack[len(c.stack)-1] += f
} else if len(c.stack) > 1 {
c.stack[len(c.stack)-2] += c.stack[len(c.stack)-1]
c.stack = c.stack[:len(c.stack)-1]
}
- c.buffer = ""
+ c.buf = ""
}