HP Forums
parse var in a cycle (like j -> Cj) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: parse var in a cycle (like j -> Cj) (/thread-3303.html)



parse var in a cycle (like j -> Cj) - salvomic - 03-08-2015 11:31 AM

hi all,
I little help to make in a program something like: to parse columns os Statistics adding a var in a cycle.
i.e. I must get C1, C2, C3 and I think to do:
FOR j FROM 0 TO 9 DO
// use Cj (C0, C1, C2...), but I cannot use Cj as it would be another var... and not C(j)...
n:= size(Cj); // doesn't work...
END;

thank you!


RE: parse var in a cycle (like j -> Cj) - DrD - 03-08-2015 12:08 PM

Would using lists work for you? Something like:

Code:

EXPORT Varb()
BEGIN
local n, CL:={'C0', 'C1', 'C2'} ;

for n from 1 to length(CL) do
  print(CL(n));
end;

END;



RE: parse var in a cycle (like j -> Cj) - salvomic - 03-08-2015 01:00 PM

(03-08-2015 12:08 PM)DrD Wrote:  Would using lists work for you? Something like:

[code]
EXPORT Varb()
BEGIN
local n, CL:={'C0', 'C1', 'C2'} ;

...

I can try.
I must calculate for example mean on the lists, so sum their items and so on...
I'll try in a few minutes, than I'll tell you,
thanks
Salvo


RE: parse var in a cycle (like j -> Cj) - salvomic - 03-08-2015 04:20 PM

yes, it works!
but with eval()

see here.

Code:

local DL:={eval('D1'), eval('D2'), ...}



RE: parse var in a cycle (like j -> Cj) - DrD - 03-08-2015 07:00 PM

(03-08-2015 04:20 PM)salvomic Wrote:  yes, it works!
but with eval()

see here.

Code:

local DL:={eval('D1'), eval('D2'), ...}

Lists are very useful, for example, you can evaluate each element in the list:
Code:

EXPORT Varb()
BEGIN

local a:=1,b:=2,c:=3, DL:={'a',' b', 'c'};
RETURN EVAL(DL);  //  Evaluates each element in the list DL

END;



RE: parse var in a cycle (like j -> Cj) - salvomic - 03-08-2015 07:07 PM

(03-08-2015 07:00 PM)DrD Wrote:  Lists are very useful, for example, you can evaluate each element in the list:

yes, you're write, I agree