I have a function that acts upon the pixel data of an image. For the sake of simplicity, the image has only one row which means that I can use lists to hold the data.
So, said function needs to return this list but just doing
...
Return (SomeFormulaThatResultsInAList)
...
results in an "Incorrect type"-error.
My assumption is that Return
can only return numbers, not lists, am I right? If so, how can I return a list?
Btw, I am using a TI-Nspire CX CAS
My assumption is that
Return
can only return numbers, not lists, am I right?
That is correct. From the TI Nspire reference guide:
Return
[Expr]Returns Expr as the result of the function. …
In the language of the TI manual, an Expr must be a algebraic expression. It doesn't need to be a number -- along the lines of 2x+5
is fine -- but it has to be something "shaped like" a number. A list isn't suitable.e
There is no way to directly return a list from a function in the TI CAS environment. It's simply not a feature which the language supports.
What you could do as a workaround, however, is rewrite the function as a program (Prgm
), and store the result to a global variable with a predetermined name. It's ugly, but it'll work.