this short program crashes my PRIME
|
12-18-2013, 12:06 AM
Post: #1
|
|||
|
|||
this short program crashes my PRIME
Code:
First time it returns right answer, e.g.: ELODIFF(15)=.52 //this what I need Second time I get: ELODIFF(15)=15 //something gets wrong... After several callings with different arguments my HP PRIME CRASHES... |
|||
12-18-2013, 03:11 AM
Post: #2
|
|||
|
|||
RE: this short program crashes my PRIME
I think you may be confusing things by enclosing the returned variable C in parentheses. Try just RETURN C;
|
|||
12-18-2013, 06:14 AM
Post: #3
|
|||
|
|||
RE: this short program crashes my PRIME
I think the problem is with using SIZE in the FOR Loop. SIZE returns a list and not a scalar. You should assign the result of SIZE to a list first and then access the first element of that list as the upper loop limit.
Namir |
|||
12-18-2013, 06:28 AM
(This post was last modified: 12-18-2013 02:11 PM by Michael de Estrada.)
Post: #4
|
|||
|
|||
RE: this short program crashes my PRIME
(12-18-2013 06:14 AM)Namir Wrote: I think the problem is with using SIZE in the FOR Loop. SIZE returns a list and not a scalar. You should assign the result of SIZE to a list first and then access the first element of that list as the upper loop limit. Are you sure ? According to the Prime Help for SIZE, it accepts a list as the input and returns a scalar representing the number of element in the list, so for this program it should be 7. I just checked it out and it does works that way, so for example SIZE({{1,2,3},{4,5,6},{7,8,9},{10}}) returns 4. |
|||
12-18-2013, 07:35 AM
Post: #5
|
|||
|
|||
RE: this short program crashes my PRIME
Hello,
Not your fault... There is a bug in the return call in the for loop which is causing the issue... a workaround while waiting for the fix is to copy your 'output' in a variable (C will work) and then to do a break; to exit from the for loop... then return your C.... note, you can do: if A<=R<=B then break; end; this should work Cyrille |
|||
12-18-2013, 08:20 AM
Post: #6
|
|||
|
|||
RE: this short program crashes my PRIME
Thank you Cyrille, now it works!
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)