c3d / db48x

RPL runtime for the DM42 calculator, in the spirit of HP48/49/50
http://48calc.org
GNU Lesser General Public License v3.0
80 stars 10 forks source link

Evaluating an equation with `→Num` #1057

Open c3d opened 1 month ago

c3d commented 1 month ago

When evaluating an equation like 'A*A+B*B=C*C' with →Num, we get a True or False result. Would it be preferable to see the left and right results?

Wiljea commented 1 month ago

I think you're right and this should clearly generalize to logical expression as well: 'express1 logical_operator express2' for instance 'AA+BB<CC'. To implement this, 2 possibles scenarios: S1 : invoke →Num (or ASN) two times in a row with the expression values as a first result and the logical value after the second time. OR an interesting possibility S2: A first call shows a tagged result of the form 'AA+BB<CC'ˍ?:True and the second call to →Num (or ASN) would simply remove the tag from any object of the form 'express'ˍ?:Log_Val to finally leave on the stack the logical value alone. (May be, if →Num and ASN are distinct operation, ASN would give directly the logical value). Remark about S2: it may seem strange to use the notation ˍ? as if it was a unit but wouldn't it possible to consider some kind of a logical unit because if express1 and express2 are themselves logical expression (e.g. A>B, C=3) then for instance 'A>B AND C=3'ˍ? would act as an alternate logical operation with a definitive answer. Is it an interesting suggestion ? I wonder ...