HP Forums

Full Version: Create empy list on 38g/39g/40g
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

This is such a simple question, but I can't find an answer in the manual.

How do I, under program control, create an empty list, or else initialize an existing list (of arbitrary size) to empty? I know how to do it from the keyboard by going into the VAR menu, selecting the list, and pressing [DEL]. (By "program" I mean HP-BASIC, not SysRPL.)

I'm trying to get a program to initialize itself to a known state, which requires an empty list to which it can add things as it goes.

{ } -> L# should do it. (where # is 0-9)

Nope. {} gives a syntax error, with or without a space between the braces.

Quote:
Nope. {} gives a syntax error, with or without a space between the braces.

I got the same thing. MAKELIST requires a sequence - I can't imagine a way to create an empty list.

I have a feeling that empty lists aren't possible on the 38g/39g/40g.

Possible workaround (?):

Initialize the list with {1} and delete the "first 1" at the end program execution

{1} -> L1
** commands to add elements to L1
Result: L1 = {1, #, #, ...}
**
SUB L1; L1; 2; SIZE(L1)

Result: L1={#, #, #, ...}

SUB - CMDS-Matrix menu
SIZE - MATH-List menu

I hope this helps.

Eddie

Edited: 25 Oct 2011, 9:10 a.m.

If you have an empty list (via DEL in the LIST menu then you can do the following:

Say L9 is empty and you want to make L1 empty: L9>L1:

HTH

Cheers,

Marwan