Trouble with this programm. Please help!
|
03-16-2015, 03:10 PM
Post: #1
|
|||
|
|||
Trouble with this programm. Please help!
Hi everybody I have had my hp prime for a few weeks now and I have trouble entering this program directly in the calculator. It says that there is a sintaxis problem. Can you help me fix it?Thank you.
This is the programm: EXPORT PARAL(L1) BEGIN LOCAL T; LOCAL I; LOCAL N; T:=0; I:=0; N:=SIZE(L1); FOR I FROM 1 TO N DO T:=T+1/L1(I); END; T:=1/T; RETURN(T); END; |
|||
03-16-2015, 03:48 PM
Post: #2
|
|||
|
|||
RE: Trouble with this programm. Please help!
Try replacing 'SIZE' with 'length'.
|
|||
03-16-2015, 04:00 PM
Post: #3
|
|||
|
|||
RE: Trouble with this programm. Please help!
It says than the error is in line 4 and I don't understand why because I used the same sintaxis in line 3
|
|||
03-16-2015, 04:04 PM
Post: #4
|
|||
|
|||
RE: Trouble with this programm. Please help!
The problem is the way you pass in the LIST (L1): Lists can't be used as inputs in the case.
Pre-define your list L1 then run this code: Code:
|
|||
03-16-2015, 04:09 PM
(This post was last modified: 03-16-2015 04:17 PM by Marcio.)
Post: #5
|
|||
|
|||
RE: Trouble with this programm. Please help!
I would just replace SIZE with lenght as it will work with both lists and vectors.
Code:
Example: Both PARAL([1 2 3]) and PARAL({1,2,3}) will return 6/11, which is equivalent to 0.545454.... |
|||
03-16-2015, 04:16 PM
Post: #6
|
|||
|
|||
RE: Trouble with this programm. Please help!
Now it says there is a problem with T:=0;
|
|||
03-16-2015, 04:32 PM
Post: #7
|
|||
|
|||
RE: Trouble with this programm. Please help!
Are you sure you have the latest version of the Prime software?
With version 6975 I have no errors with your program. Here is what I got: Regarding the variable names in your program I would recommend not to use Global names for local variables as this can be confusing. Having L1 as your program parameter doesn't change the content of the L1 global variable but this is confusing as well as using T, I and N for local variables. I would use lower case names instead of upper case to show the difference. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)