diff options
author | dan <[email protected]> | 2023-05-19 22:49:11 -0400 |
---|---|---|
committer | dan <[email protected]> | 2023-05-19 22:49:11 -0400 |
commit | 84b064f65e25d6e6e3a8c8cfe8a10062a2da66a0 (patch) | |
tree | 78c3b437a1b15faf507b5eeb92c38f78960b776d /forth.js | |
parent | 22d08709d53d16b32e6a9ee8b4b45ebf19bde685 (diff) | |
download | forth-84b064f65e25d6e6e3a8c8cfe8a10062a2da66a0.tar.gz forth-84b064f65e25d6e6e3a8c8cfe8a10062a2da66a0.tar.bz2 forth-84b064f65e25d6e6e3a8c8cfe8a10062a2da66a0.zip |
feat: dup command
Diffstat (limited to 'forth.js')
-rw-r--r-- | forth.js | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -18,8 +18,9 @@ function forth(print = console.log) { }, '+' : () => { s.push(popNum() + popNum()) }, '*' : () => { s.push(popNum() * popNum()) }, - '.' : () => print(s.pop()), - 'peek' : () => print(s[s.length - 1]), + '.' : () => { print(s.pop()) }, + 'peek' : () => { print(s[s.length - 1]) }, + 'dup' : () => { s.push(s[s.length - 1]) }, ':' : (initialIdx, tokens) => { let localIdx = initialIdx + 1; const fname = tokens[localIdx++]; |