HP Prime: Lists in programs



What is the way to input a list to a program? I wrote a program (ProgA) that uses a list to do some arithmetic with its items. But if I input the list as {1,2,3,4} (say), it does not like it. Thus I modified the program so that it will read the list from the list L1. This works, but it brings another set of problems. If I create L1 using another program (ProgB) and after that I run Prog A, this ProgA may or may not read the list L1 correctly (the list is correct as I can confirm with [Shift]+[F7]). It is as if the list was there but not available to programs yet. If I power off after ProgB is run and then ON and run ProgA, it seems to work OK. Sorry if I am confusing...



could you post your programs so that we could try them and see what is happening?

in a program, you can create a variable, put an empty list in it and use EDITLIST(var) to edit the list.



show your program code !


Hi, here they are:

ProgramA takes a list of integers and finds the rational number whose continued fraction is that list. I have the list stored in L1. I would like to input the list as {n1, n2, ...} but I cannot.

EXPORT ProgramA()
LOCAL M:=[[1,0],[0,1]];

ProgramB inputs a rational number P/Q and outputs its continued fraction expansion (and writes it to list L1 also). I have to input the number as P and then Q; if I input P/Q the Prime makes that into a decimal, and the program sometimes does not work. Also, in 5th line, "not0" is for the "slashed equal" sign.

EXPORT ProgramB(P,Q)
LOCAL M,N:={};
WHILE M(2,3) not0 DO

(I have just copied these rather that posting pics. There may be some typo.) (BTW, and earlier version would not work with iPart instead of FLOOR).

If I run ProgramB on a number P/Q and then run ProgramA, this one has trouble reading list L1. I have not seen any consistent error to figure out what is wrong. If I run the Debug feature in ProgramA, most of the time works OK, but sometimes it does not, showing that list L1 has some strange items in it, even when L1 looks OK using [Shift]+[7]


[added] In programB, third line from the bottom, I have N->L1; instead of L1:=N. I just do not have that "store" symbol on my keyboard)

Edited: 3 Dec 2013, 2:44 p.m. after one or more responses were posted


BTW, ContinuedFraction does not appear on my Prime, though it exists on Xcas.


Hi again,
I have just upgraded to firmware 20131125, tested these programs, and it appears that the issue with ProgramA reading list L1 correctly seems to have been resolved.



And matrices now work in programs! That is great, thanks


Hi again,

Program B now works like this:

EXPORT ProgramB(P,Q)
LOCAL M,N:={};
WHILE M(2,3) not0 DO

I would like to be able to input the rational number R as P/Q, instead as inputing P and then Q. I replaced the 1st and 4th lines of the program with

EXPORT ProgramB(R)
The program runs OK but gives the wrong answer. It seems that the input makes the number into a decimal and then numer and denom cannot reconstruct it correctly (try 256/157)

Also, the Help for numer in the Prime has several typos. Usage is numer(a/b) and not numer(a,b)


Possibly Related Threads…
Thread Author Replies Views Last Post
  Does the HP Prime really compiles the user programs? CompSystems 3 2,744 12-13-2013, 01:55 PM
Last Post: Mike Morrow
  HP Prime: FLOOR, iPart , and their use in programs Alberto Candel 6 2,596 12-01-2013, 10:17 PM
Last Post: Alberto Candel
  HP Prime: matrices in programs, in need of help Alberto Candel 9 3,219 11-26-2013, 01:33 AM
Last Post: cyrille de Br├ębisson
  HP Prime: password protection for programs Davi Ribeiro de Oliveira 2 1,580 11-22-2013, 12:45 PM
Last Post: Geoff Quickfall
  [Prime]Passing lists as arguments Andy Gryc 2 1,407 11-18-2013, 10:16 PM
Last Post: Andy Gryc
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 3,284 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  Question about transfering programs to the HP Prime Namir 10 3,441 11-17-2013, 04:01 PM
Last Post: Namir
  [Download] PrimeComm: Alternative small utility to upload/download programs to the HP Prime Erwin Ried 6 2,511 11-17-2013, 10:18 AM
Last Post: Erwin Ried
  HP Prime: do not send programs and shuts down by pressing Apps Davi Ribeiro de Oliveira 1 1,348 11-12-2013, 11:05 AM
Last Post: Joseph Ec
  hp prime - programming with lists giancarlo 3 1,878 11-10-2013, 02:13 AM
Last Post: Giancarlo

Forum Jump: