furo-hp-35 #
@furo/util v2.1.19
import '@furo/util/src/furo-hp-35.js';
exports FuroHp35 js
exports <furo-hp-35>
custom-element-definition
extends /src/furo-forth-stack.js
superclass FuroForthStack
summary calculator component
hp-35
is a declarative rpn calculator component.
see https://hansklav.home.xs4all.nl/rpn/
http://h10032.www1.hp.com/ctg/Manual/c01579350
Attributes and Properties #
radMode #
radMode
boolean
default: false
Set to true to use rad, default is deg
x #
x
Number
current x
y #
y
Number
current y
z #
z
Number
current z
t #
t
Number
current t
stack #
stack
Array
the stack.
size #
default: 0
Current size of the stack
Events #
stackchange #
at-stackchange
→ void
Fired when something in stack changes
stack-size-changed #
at-stack-size-changed
→ Number
Fired when the stack size changes with Integer with the current size of the stack.
rotated #
at-rotated
→ the top element
Fired when stack was rotated
stack-changed #
at-stack-changed
→ the top element
Fired when the stack contents changes after put, drop,…
swapped #
at-swapped
→ void
Fired when stack was swapped
empty #
at-empty
→ void
Fired when stack gets empty
Methods #
enter #
enter(n Number
) ⟹ void
Number
→
fn-enter
Enter a number
- n
updateXYZT #
updateXYZT() ⟹ void
*
→
fn-update-xyzt
swap #
swap() ⟹ void
*
→
fn-swap
swap ( n1 n2 – n2 n1 )
swap, as you may have guessed, swaps the top two elements of the stack. For example:
1 2 3 4 swap will give you:
1 2 4 3 <- Top
rot #
rot() ⟹ void
*
→
fn-rot
rot ( n1 n2 n3 – n2 n3 n1 )
Finally, rot “rotates” the top three elements of the stack. The third element from the top of the stack gets moved to the top of the stack, pushing the other two elements down.
1 2 3 rot gives you:
2 3 1 <- Top
roll #
roll() ⟹ void
*
→
fn-roll
rot ( n1 n2 n3 – n2 n3 n1 )
Finally, rot “rotates” the top three elements of the stack. The third element from the top of the stack gets moved to the top of the stack, pushing the other two elements down.
1 2 3 rot gives you:
2 3 1 <- Top
add #
add(n Number
) ⟹ number
Number
→
fn-add
Process an addition
- n
substract #
substract(n Number
) ⟹ number
Number
→
fn-substract
Process a substraction
- n
sqrt #
sqrt(n Number
) ⟹ number
Number
→
fn-sqrt
Perform square root operation
- n
ln #
ln(n Number
) ⟹ number
Number
→
fn-ln
Perform log operation
- n
cos #
cos(n Number
) ⟹ number
Number
→
fn-cos
Perform cos operation
- n
sin #
sin(n Number
) ⟹ number
Number
→
fn-sin
Perform sin operation
- n
tan #
tan(n Number
) ⟹ number
Number
→
fn-tan
Perform tan operation
- n
abs #
abs(n Number
) ⟹ number
Number
→
fn-abs
Perform abs operation
- n
reciprocal #
reciprocal(n Number
) ⟹ number
Number
→
fn-reciprocal
Perform reciprocal operation
- n
exp #
exp(n Number
) ⟹ number
Number
→
fn-exp
Perform exp operation
returns e^x, where x is the argument, and e is Euler’s number (also known as Napier’s constant), the base of the natural logarithms.
- n
xroot #
xroot(n `` ) ⟹ void
`` → fn-xroot
- n
multiply #
multiply(n Number
) ⟹ number
Number
→
fn-multiply
Process a multiplication
- n
pow #
pow(n Number
) ⟹ number
Number
→
fn-pow
Process power
- n
divide #
divide(n Number
) ⟹ number
Number
→
fn-divide
Process a division
- n
clear #
clear() ⟹ void
*
→
fn-clear
clear the stack
clearStack #
clearStack() ⟹ void
*
→
fn-clear-stack
Empties the stack and set the stack-size to 0
put #
put(e `` ) ⟹ void
`` → fn-put
Add an element to the stack
- e
drop #
drop() ⟹ void
*
→
fn-drop
drop ( n – )
drop simply drops the top element of the stack. Running:
1 2 3 drop gives you a stack of:
1 2 <- Top
dup #
dup() ⟹ void
*
→
fn-dup
dup ( n – n n )
dup is short for “duplicate” – it duplicates the top element of the stack. For example, try this out:
1 2 3 dup
You should end up with the following stack:
1 2 3 3 <- Top
over #
over() ⟹ void
*
→
fn-over
over ( n1 n2 – n1 n2 n1 )
over is a bit less obvious: it takes the second element from the top of the stack and duplicates it to the top of the stack. Running this:
1 2 3 over will result in this:
1 2 3 2 <- Top
rrot #
rrot() ⟹ void
*
→
fn-rrot
rrot ( n1 n2 n3 – n3 n1 n2 )
Reverse rotation or right rotation rrot “rotates” the elements of the stack inverse to rot. The top elemen the stack gets moved to the bottom of the stack.
1 2 3 rot gives you:
3 1 2 <- Top