HP Forums
EDITLIST in CAS program - 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: EDITLIST in CAS program (/thread-3902.html)



EDITLIST in CAS program - salvomic - 05-18-2015 08:01 PM

I'm trying EDITLIST in a #CAS program and it seems not to edit a list.

The line
EDITLIST(flows);
works well in a Home program, but has no effect in a #CAS/#end program.

Am I wrong?

Salvo


RE: EDITLIST in CAS program - Joe Horn - 05-20-2015 05:48 AM

(05-18-2015 08:01 PM)salvomic Wrote:  I'm trying EDITLIST in a #CAS program and it seems not to edit a list.

The line
EDITLIST(flows);
works well in a Home program, but has no effect in a #CAS/#end program.

Am I wrong?

Salvo

It returns the correctly edited list (to the history stack) as its output, but in CAS it fails to automatically store that result back into the named list. So in a CAS program, you'll have to use this apparently redundant syntax: L1:=EDITLIST(L1). At least until that bug is fixed.


RE: EDITLIST in CAS program - salvomic - 05-20-2015 07:01 AM

(05-20-2015 05:48 AM)Joe Horn Wrote:  ...
So in a CAS program, you'll have to use this apparently redundant syntax: L1:=EDITLIST(L1). At least until that bug is fixed.

thank you!
I'll try this, then, until the bug will be corrected.

Salvo


RE: EDITLIST in CAS program - StephenG1CMZ - 10-11-2015 07:43 AM

Actually, I wonder whether that should be a bug?
Using L1 := EDITLIST(L1)
Looks like a useful syntax for those times you want to edit a list and keep the original:
L2 := EDITLIST(L1)

If EDITLIST (L1) always changes L1, that last line would make
L2 = L1 = edited
Whereas
L2 = edited L1 =Original
Would be it's obvious meaning without looking up EDITLIST's spec.

So for readability of the source code, I would suggest EDITLIST should not automatically edit the list given as a parameter, though if no destination list is specified it should default to doing so).

A potential downside is that that might be less efficient, but it avoids
L2:=EDITLIST(L1) editing L1 when you might not expect it to.
If doing this is considered too wasteful given that on many occasions you will be editing back to the same list,
I would suggest EDITLIST should not be assignable - the corresponding code then becoming:
EDITLIST (L1); // no L2 makes it clear what is being edited
Or
L2:=L1; //keep original
EDITLIST (L2); // change copy
L2:=EDITLIST (L1) // could give syntax error to avoid confusion


I would also like to suggest EDITLIST should have an optional READONLY parameter (alternatively: a VIEWLIST command) for those times when you want to browse a list without changing it.
See for example how I use it in Version 0.3 of my Z EDITOR (select Searchall then View, and see how awkward the editing can look before my program implements search-and-replace). Having a readonly setting would be much neater.