246
Programming
MAKELIST(0,X,1,2*sides,1)
L2;
FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides)
roll;
L2(roll)+1
L2(roll);
END;
END;
ROLLDIE(n)
BEGIN
RETURN 1 + FLOOR(n*RANDOM);
END;
In this scenario, assume there is no
ROLLDIE
function
exported from another program. Instead,
ROLLDIE
is
visible only in the context of
ROLLMANY
.
Finally, the list of results could be returned as the result of
calling
ROLLMANY
instead of being stored directly into
the global list variable, L2. This way, if the user wanted
to store the results elsewhere, it could be done easily.
EXPORT ROLLMANY(n,sides)
BEGIN
LOCAL k,roll,results;
MAKELIST(0,X,1,2*sides,1)
results;
FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides)
roll;
results(roll)+1
results(roll);
END;
RETURN results;
END;
On the Home screen, you would enter
ROLLMANY(100,6)
L5
and the results of the
simulation of 100 rolls of two six-sided dice would be
stored into list L5.
Содержание 39gII
Страница 1: ...HP 39gII graphing calculator user s guide Edition1 Part Number NW249 90001 ...
Страница 2: ...Printing History Edition 1 November 201 1 ...
Страница 32: ...22 Getting started ...
Страница 58: ...48 Apps and their views ...
Страница 70: ...60 Function app ...
Страница 80: ...70 Solve app ...
Страница 132: ...122 Parametric app your own table and the split screen functionality available in the Function app ...
Страница 136: ...126 Polar app ...
Страница 140: ...130 Sequence app ...
Страница 148: ...138 Finance app ...
Страница 152: ...142 Linear Solver app ...
Страница 218: ...208 Matrices ...
Страница 226: ...216 Notes and Info ...
Страница 238: ...228 Variables and memory management ...
Страница 318: ...308 Programming ...
Страница 340: ...330 Reference information ...
Страница 346: ...vi Product Regulatory Information ...