continue to prepare implementation

This commit is contained in:
Gwenhael Le Moine 2022-02-11 16:30:49 +01:00
parent a704d57a4f
commit 8f1f871904
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 76 additions and 28 deletions

View file

@ -208,7 +208,6 @@ module RplLang
value: value }
end )
# Operations on reals
@dictionary.add_word( ['%'],
'Operations on reals',
@ -295,14 +294,18 @@ module RplLang
end )
# @dictionary.add_word( ['mant'],
# 'Operations on reals',
# '',
# proc { __todo } ) # mantissa of a real number
# 'Operations on reals',
# 'mantissa of a real number',
# proc do
# end )
# @dictionary.add_word( ['xpon'],
# 'Operations on reals',
# '',
# proc { __todo } ) # exponant of a real number
# 'Operations on reals',
# 'exponant of a real number',
# proc do
# end )
@dictionary.add_word( ['ip'],
'Operations on reals',
@ -323,31 +326,63 @@ module RplLang
end )
# OPERATIONS ON COMPLEXES
# Operations on complexes
# @dictionary.add_word( ['re'],
# proc { __todo } ) # complex real part
# 'Operations on complexes',
# 'complex real part',
# proc do
# end )
# @dictionary.add_word( 'im',
# proc { __todo } ) # complex imaginary part
# 'Operations on complexes',
# 'complex imaginary part',
# proc do
# end )
# @dictionary.add_word( ['conj'],
# proc { __todo } ) # complex conjugate
# 'Operations on complexes',
# 'complex conjugate',
# proc do
# end )
# @dictionary.add_word( 'arg',
# proc { __todo } ) # complex argument in radians
# @dictionary.add_word( ['c->r'],
# proc { __todo } ) # transform a complex in 2 reals
# @dictionary.add_word( 'c→r',
# proc { __todo } )
# @dictionary.add_word( ['r->c'],
# proc { __todo } ) # transform 2 reals in a complex
# @dictionary.add_word( 'r→c',
# proc { __todo } )
# @dictionary.add_word( ['p->r'],
# proc { __todo } ) # cartesian to polar
# @dictionary.add_word( 'p→r',
# proc { __todo } )
# @dictionary.add_word( ['r->p'],
# proc { __todo } ) # polar to cartesian
# @dictionary.add_word( 'r→p',
# proc { __todo } )
# 'Operations on complexes',
# 'complex argument in radians',
# proc do
# end )
# @dictionary.add_word( ['c→r', 'c->r'],
# 'Operations on complexes',
# 'transform a complex in 2 reals',
# proc do
# end )
# @dictionary.add_word( ['r→c', 'r->c'],
# 'Operations on complexes',
# 'transform 2 reals in a complex',
# proc do
# end )
# @dictionary.add_word( ['p→r', 'p->r'],
# 'Operations on complexes',
# 'cartesian to polar',
# proc do
# end )
# @dictionary.add_word( ['r→p', 'r->p'],
# 'Operations on complexes',
# 'polar to cartesian',
# proc do
# end )
end
end
end

View file

@ -14,18 +14,21 @@ module RplLang
@stack << args[0] << args[1]
end )
@dictionary.add_word( ['drop'],
'Stack',
'( a -- ) drop first stack element',
proc do
run( '1 dropn' )
end )
@dictionary.add_word( ['drop2'],
'Stack',
'( a b -- ) drop first two stack elements',
proc do
run( '2 dropn' )
end )
@dictionary.add_word( ['dropn'],
'Stack',
'( a b … n -- ) drop first n stack elements',
@ -34,12 +37,14 @@ module RplLang
_args = stack_extract( %i[any] * args[0][:value] )
end )
@dictionary.add_word( ['del'],
'Stack',
'( a b … -- ) drop all stack elements',
proc do
@stack = []
end)
@dictionary.add_word( ['rot'],
'Stack',
'( a b c -- b c a ) rotate 3 first stack elements',
@ -48,18 +53,21 @@ module RplLang
@stack << args[1] << args[0] << args[2]
end )
@dictionary.add_word( ['dup'],
'Stack',
'( a -- a a ) duplicate first stack element',
proc do
run( '1 dupn' )
end )
@dictionary.add_word( ['dup2'],
'Stack',
'( a b -- a b a b ) duplicate first two stack elements',
proc do
run( '2 dupn' )
end )
@dictionary.add_word( ['dupn'],
'Stack',
'( a b … n -- a b … a b … ) duplicate first n stack elements',
@ -76,6 +84,7 @@ module RplLang
end
end
end )
@dictionary.add_word( ['pick'],
'Stack',
'( … b … n -- … b … b ) push a copy of the given stack level onto the stack',
@ -92,12 +101,14 @@ module RplLang
@stack << args[0]
end )
@dictionary.add_word( ['depth'],
'Stack',
'( … -- … n ) push stack depth onto the stack',
proc do
@stack << { type: :numeric, base: 10, value: BigDecimal( stack.size ) }
end )
@dictionary.add_word( ['roll'],
'Stack',
'( … a -- a … ) move a stack element to the top of the stack',
@ -115,6 +126,7 @@ module RplLang
@stack << args[0]
end )
@dictionary.add_word( ['rolld'],
'Stack',
'( a … -- … a ) move the element on top of the stack to a higher stack position',
@ -131,6 +143,7 @@ module RplLang
@stack << args[ i ]
end
end )
@dictionary.add_word( ['over'],
'Stack',
'( a b -- a b a ) push a copy of the element in stack level 2 onto the stack',