04-19-2019, 01:11 PM

Hello

I do not know if the following was already discussed: Optional Arguments

The RPN commands of the hp48 / 50 interpret a number of fixed arguments, while in the functional standard notation some languages the number of call arguments can be variable

if a function is defined as f1 (arg1, [arg2], [arg3], ...)

The following three calling options can be made.

f1(arg1) [enter]

f1(arg1, arg2) [enter]

f1(arg1, arg2, arg3) [enter]

for example Xcas syntax python

legendre_(2), legendre_(2,y), legendre_(2,"list"), legendre_(2,10), legendre_(2,cos(t)) [enter]

1/8*(12*x^2-4), 1/8*(12*y^2-4), poly1[3/2,0,-1/2],2 99/2, 1/8*(12*cos(t)^2-4)

I think the only way in RPN is to specify the number of arguments, it can be with the symbols <-

arg1 f1 [enter]

arg1, arg2 f1←2 [enter]

arg1, arg2, arg3 f1←3 [enter]

I do not know if the following was already discussed: Optional Arguments

The RPN commands of the hp48 / 50 interpret a number of fixed arguments, while in the functional standard notation some languages the number of call arguments can be variable

if a function is defined as f1 (arg1, [arg2], [arg3], ...)

The following three calling options can be made.

f1(arg1) [enter]

f1(arg1, arg2) [enter]

f1(arg1, arg2, arg3) [enter]

for example Xcas syntax python

PHP Code:

`#cas`

def legendre_( n, evalX="" ):

local px, x, type2arg; purge(x)

px := 1/(2^n*n!)*diff((x^2-1)^n,x,n)

type2arg := getType(evalX)

if type2arg=="NUM" or type2arg=="EXPR" or type2arg=="VAR":

px:=subst(px,x=evalX)

elif type2arg=="STR" and evalX=="list":

px:=e2r(px)

return px;

#end

legendre_(2), legendre_(2,y), legendre_(2,"list"), legendre_(2,10), legendre_(2,cos(t)) [enter]

1/8*(12*x^2-4), 1/8*(12*y^2-4), poly1[3/2,0,-1/2],2 99/2, 1/8*(12*cos(t)^2-4)

I think the only way in RPN is to specify the number of arguments, it can be with the symbols <-

arg1 f1 [enter]

arg1, arg2 f1←2 [enter]

arg1, arg2, arg3 f1←3 [enter]