baddc

integer-precision dc(1)
git clone git://bvnf.space/baddc.git
Log | Files | Refs | README

commit ee66407d95019fd431288d0ab9b047c33dfb5dc7
parent d611611a87d9bc3ab71c10d94634e56435aade64
Author: phoebos <ben@bvnf.space>
Date:   Wed, 25 May 2022 13:20:18 +0100

add drop operation

Diffstat:
MREADME | 2++
Mbaddc.1 | 2++
Mbaddc.c | 5+++++
3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -63,6 +63,8 @@ DESCRIPTION v Push the square root of the first value. + r Drop the top value of the stack. + q Quit baddc immediately. EXIT STATUS diff --git a/baddc.1 b/baddc.1 @@ -76,6 +76,8 @@ Push the second value modulus the second Push the second value raised to the first value. .It v Push the square root of the first value. +.It r +Drop the top value of the stack. .It q Quit .Nm diff --git a/baddc.c b/baddc.c @@ -143,6 +143,10 @@ void root(void) { push((int)sqrt((double)a)); } +void drop(void) { + pop(); +} + struct { char op; void (*f)(void); @@ -161,6 +165,7 @@ struct { { '%', mod }, { '^', power }, { 'v', root }, + { 'r', drop }, }; #define NUM_OPS ((sizeof(ops)) / (sizeof(*ops)))