better implementation leveraging CHS and INV

This commit is contained in:
Gwenhael Le Moine 2021-12-08 16:07:16 +01:00
parent 6b57d03627
commit dd8edd627d
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -99,7 +99,7 @@ module Rpl
# negate a variable. ex: 'name' sneg # negate a variable. ex: 'name' sneg
def sto_negate( stack, dictionary ) def sto_negate( stack, dictionary )
stack << { value: '« dup rcl -1 * swap sto »', stack << { value: '« dup rcl chs swap sto »',
type: :program } type: :program }
Rpl::Lang::Core.eval( stack, dictionary ) Rpl::Lang::Core.eval( stack, dictionary )
@ -107,7 +107,7 @@ module Rpl
# inverse a variable. ex: 1 'name' sinv # inverse a variable. ex: 1 'name' sinv
def sto_inverse( stack, dictionary ) def sto_inverse( stack, dictionary )
stack << { value: '« dup rcl 1 swap / swap sto »', stack << { value: '« dup rcl inv swap sto »',
type: :program } type: :program }
Rpl::Lang::Core.eval( stack, dictionary ) Rpl::Lang::Core.eval( stack, dictionary )