Calling a function with an arbitrary number of arguments
|
05-04-2019, 03:37 PM
(This post was last modified: 05-05-2019 04:02 AM by Han.)
Post: #4
|
|||
|
|||
RE: Calling a function with an arbitrary number of arguments
Here is a short (CAS) program that takes a variable number of inputs. In this case, we expect 2 inputs but the program handles cases where more (or fewer) than 2 inputs are provided (by returning an error message). Here, the input is the variable 'args' which is (conceptually speaking) a list of values, which are then turned into a vector of values called 'argv' by encapsulating the list of values in square brackets. Non-CAS programs cannot handle variable inputs; but one way to get around this is to create a "wrapper" CAS program that handles the input and then passes it to your non-CAS program(s).
Code: #cas Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Calling a function with an arbitrary number of arguments - fakuivan - 05-02-2019, 02:08 AM
RE: Calling a function with an arbitrary number of arguments - cyrille de brébisson - 05-02-2019, 06:05 AM
RE: Calling a function with an arbitrary number of arguments - parisse - 05-02-2019, 10:56 AM
RE: Calling a function with an arbitrary number of arguments - Han - 05-04-2019 03:37 PM
RE: Calling a function with an arbitrary number of arguments - fakuivan - 06-13-2019, 08:31 PM
|
User(s) browsing this thread: 1 Guest(s)