Sunday, October 18, 2015

HP Prime Programs Update: BOOLLIST and SAM

Two typos had to be corrected for the BOOLLIST (choose a list's elements by use of a boolean list) and SAM (random perumtation).  Both of the program listings are now correct and are the links are listed here:

BOOLLIST


EXPORT BOOLLIST(LA, LB)
BEGIN

LOCAL LC, n, s, k, j;

//  Initialization
LC≔{ };
j≔1;
s≔SIZE(LA);
n≔SIZE(LB);

// Process
FOR k FROM 1 TO s DO

IF LB(j)==1 THEN
LC≔CONCAT(LC,LA(k));
END;

j≔j+1;

IF j>n THEN
j≔1;
END;

END;

RETURN LC;

END;


SAM


Input:  SAM(n)

EXPORT SAM(n)
BEGIN
LOCAL s,L0,L1,I,c;

L0≔MAKELIST(X,X,1,n,1);
L1≔{ };
I≔0;

REPEAT
c≔RANDINT(1,n);
IF L0(c)≠0 THEN
L1≔CONCAT(L1,{L0(c)});
L0(c)≔0;
I≔I+1;
END;
UNTIL I==n;

RETURN L1;

END;


Eddie

This blog is property of Edward Shore.  2015

No comments:

Post a Comment

Retro Review: Texas Instruments TI-68

Retro Review:  Texas Instruments TI-68 Company:  Texas Instruments Years:  1989 - 2002 Type:  Scientific, Formula Programmin...