ti-basicti-nspire

Is there a way to use lists as arguments for functions in TI-Basic?


I am making a function in my TI-nspire CS II CAS to calculate the equivalent resistance of a resistors in parallel, with this formula: Parallel of resistors

I made a program that can do this with any number of resistors in parallel. Like this:}

Define prl(list)=
Prgm
:Local req
:req:=0
:For i,1,dim(list)
:  req:=req+list[i]^(−1)
:EndFor
:Disp req^(−1)
:EndPrgm

However, I realised that I can't do operations with it such as

3+prl({4,6,7})

,since this is a program and not a function. I tried to just copy and paste the program into a function:

Define pr(list)=
Func
:Local req
:req:=0
:For i,1,dim(list)
:  req:=req+list[i]^(−1)
:EndFor
:Return req^(−1)
:EndFunc

But it gives me the error 'Invalid in a function or current expression'. The point of the list is so that the program does the job no matter the number of resistors I want to input, but apparently that doesn't work for a function. What can I do?


Solution

  • The path of least resistance is to use functions instead of programs. Note that sum can be used on a list.

    enter image description here