Can programs have optional arguments?
|
09-09-2017, 01:56 AM
Post: #1
|
|||
|
|||
Can programs have optional arguments?
Is it possible to write programs with optional arguments with default values? If so, what is the syntax?
Thx -Donald |
|||
09-09-2017, 02:52 AM
Post: #2
|
|||
|
|||
RE: Can programs have optional arguments?
It is not possible, it is very related to define polymorphic functions and that is not possible in HP PPL, the alternatives can be to create 2 independent functions, or send a parameter that determines the different type of action you want to have on the data sent.
Viga C | TD | FB |
|||
09-09-2017, 04:09 AM
Post: #3
|
|||
|
|||
RE: Can programs have optional arguments?
Another option, although awkward, is possible: Make the input a string, and then parse the string yourself in your program.
<0|ɸ|0> -Joe- |
|||
09-09-2017, 05:13 AM
Post: #4
|
|||
|
|||
RE: Can programs have optional arguments?
Thank you
|
|||
09-09-2017, 03:34 PM
Post: #5
|
|||
|
|||
RE: Can programs have optional arguments?
Bonjour
J'ai déja fait ce genre de choses en utilisant une liste pour transmettre/recevoir les paramètres. Hello I've already done this sort of thing using a list for transmit / receive parameters. Sorry for my english |
|||
09-09-2017, 10:07 PM
Post: #6
|
|||
|
|||
RE: Can programs have optional arguments?
I'm thinking like a function that has:
func(a,b,[c]), like some of the library functions.... You can create 2 functions but you can't do it like this: EXPORT func(a,b,c=0) ... I don't see how a list lets you do this...? Thx -D |
|||
09-10-2017, 05:35 AM
Post: #7
|
|||
|
|||
RE: Can programs have optional arguments?
Bonjour, Hello
Par exemple : For exemple : Code:
Func({10,15,2}) -> c=2 Func({10,15}) -> c=0 C'est un peu artisanal mais cela fonctionne. It's a little crafty but it works. Si il y a plusieurs arguments optionnels et d'autres obligatoires vous pouvez mixer. If there are several optional arguments and mandatory others you can mix. Code:
Espérant vous avoir aidé. Hoping you helped. Sorry for my english |
|||
09-11-2017, 05:13 AM
Post: #8
|
|||
|
|||
RE: Can programs have optional arguments?
Hello,
PPL does not support this for user functions. sorry. You can "emulate" it (as suggesteed before) either by creating 2 distinct functions (func2 and func3, for respectivly 2 and 3 args for example) and/or by the use of a list of input parameters. 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. |
|||
09-11-2017, 04:52 PM
Post: #9
|
|||
|
|||
RE: Can programs have optional arguments?
Giac has support for default parameters, for example
Code: f(x=3):=x*x; f(); f(5) |
|||
09-11-2017, 08:24 PM
Post: #10
|
|||
|
|||
RE: Can programs have optional arguments?
Good!
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)