multiple arguments, variable arguments, default values
|
04-17-2021, 01:11 PM
Post: #1
|
|||
|
|||
multiple arguments, variable arguments, default values
From the recent public beta announcement,
(04-14-2021 06:32 AM)Tim Wessman Wrote: [*]Able to have multiple functions of same name with different number of arguments (no default arguments though) I thought someone might benefit from seeing the syntax for this. And while technically correct that PPL does not support default arguments, you can still get the equivalent of default arguments as shown below. Here's an example of multiple arguments using the same function name defined with different number of arguments. Code:
And here's a simple example of the variable argument syntax. Code:
IMHO, these are nice additions to PPL. |
|||
04-17-2021, 04:32 PM
(This post was last modified: 04-19-2021 05:14 PM by compsystems.)
Post: #2
|
|||
|
|||
RE: multiple arguments, variable arguments, default values
Testing the code in the simulator
QF(1,2,3) [enter] returns "Error: Invalid input" PHP Code: export parallelResistors_home( a, b, ... c ) 0.92307692308 > 1 / ( ½ + ¼ + 1/3) // ok parallelResistors_home( 2, 4 ) [enter] returns 1.33333333333...∞ > 1 / ( ½ +¼ ) exact(Ans) [enter] 4/3 parallelResistors_home( 1, 2, 4, 3, 5 ) [enter] returns 0.43795620438 > 1 / ( 1 + ½ + ¼ + 1/3 + 1/5 ) // ok PHP Code: #cas parallelResistors_cas(R_1, R_2, R_3) > 1 / ( (1/R_1) +(1/R_2)+1/R_3) ) > R_1*R_2*R_3 / (R_1*R_2 + R_1*R_3 + R_2*R_3) |
|||
04-17-2021, 05:59 PM
Post: #3
|
|||
|
|||
RE: multiple arguments, variable arguments, default values
(04-17-2021 04:32 PM)compsystems Wrote: QF(1,2,3) [enter] returns "Error: Invalid input" x^2+2x+3 has imaginary roots. Go to Home Settings and turn on Complex mode to see the results. Quote:[php]#cas I think the new syntax for multiple and variable arguments is only for PPL, not CAS programming. Also, note that there is no space between the dots and the variable name: ...c not ... c |
|||
04-19-2021, 09:50 AM
Post: #4
|
|||
|
|||
RE: multiple arguments, variable arguments, default values
Hello,
Thanks, nice example and good test programs to make sure the system works. indeed, these are PPL improvements, not CAS ones... Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
04-19-2021, 08:39 PM
Post: #5
|
|||
|
|||
RE: multiple arguments, variable arguments, default values
> ... turn on Complex mode to see the results.
change flag externally HComplex:=00; [enter] 00 // a+b*i format and complex solutions off QF(1,2,3) [enter] returns "Error: Invalid input" > "Unreral" HComplex:=01; [enter] 01 // a+b*i format and complex solutions on QF(1,2,3) [enter] {−1+1.41421356238*i, −1-1.41421356238*i } [ab/c] {−1+√2*i,−1-√2*i} HComplex:=11; [enter] 11 // a+b*i> (a,b) format and complex solutions on QF(1,2,3) [enter] { (−1, 1.41421356238),(−1, −1.41421356238 )} change the flag internally within a code PHP Code: EXPORT QF(a,b,c) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)