diff options
Diffstat (limited to 'calc.go')
| -rw-r--r-- | calc.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -40,6 +40,17 @@ func (c *Calculator) swap() { } } +// dup duplicates the value at the bottom of the stack. +func (c *Calculator) dup() { + v, err := c.stack.pop() + if err != nil { + // empty + return + } + c.stack.push(v) + c.stack.push(v) +} + // negate negates the number in the buffer, if any; or the bottom number on the // stack, if any. func (c *Calculator) negate() { |