FW: R. H. Rand's permission: german translation of your "introduction to maxima"[Scanned]
Subject: FW: R. H. Rand's permission: german translation of your "introduction to maxima"[Scanned]
From: Robert Gloeckner
Date: Mon, 16 Jan 2006 17:51:03 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello Volker,
van.Nek at gmx.net wrote:
| Am 16 Jan 2006 um 12:15 hat Robert Gloeckner geschrieben:
| (C1) roll_dice(n):= block ( /* simulation of n throws of a dice */
| [ tmp, count:[0,0,0,0,0,0] ], /* local variables */
| for i:1 thru n do ( /* loop */
| tmp: random(6)+1, /* randomly throwing */
| count[tmp]: count[tmp]+1 ), /* counting */ /* end of loop */
| count )$ /* return value */
|
| I copied this from my text editor into xmaxima and do now use this
function.
|
| (C2) roll_dice(1000);
| (D2) [163, 176, 159, 148, 178, 176]
|
I get an error, if I try:
roll_dice(n) := block (
~ [ tmp, count:[0,0,0,0,0,0] ],
~ for i:1 thru n do (
~ tmp: random(6)+1,
~ count[tmp]: count[tmp]+1 ),
~ count );
Display all 1103 possibilities? (y or n)
&ALLOW-OTHER-KEYS LEAST-NEGATIVE-SINGLE-FLOAT
&AUX LEAST-POSITIVE-DOUBLE-FLOAT
...
PPRINT-EXIT-IF-LIST-EXHAUSTED
CELL-ERROR PPRINT-FILL
CELL-ERROR-NAME PPRINT-INDENT
(%o1) roll_dice(n) := block([tmp, count : [0, 0, 0, 0, 0, 0]],
for i thru n do (dom(6) + 1, count : count + 1), count)
tmp tmp
(%i2) (%i2) roll_dice(1000);
Subscript must be an integer:
tmp
#0: roll_dice(n=1000)
~ -- an error. Quitting. To debug this try debugmode(true);
(%i3) (%i3)
What am I doing wrong?
Regards,
Robert
- --
https://gna.org/projects/mipisti - (microscope) picture stitching
~ T_a_k_e__c_a_r_e__o_f__y_o_u_r__R_I_G_H_T_S.
~ P_r_e_v_e_n_t__L_O_G_I_C--P_A_T_E_N_T_S
~ http://www.ffii.org, http://www.nosoftwarepatents.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFDy872V8k0kPlGZngRAuxXAJ4h0sm4fCiukmZsVhrRmv5Yy2I/4QCgrb7x
aiXrqmuY2SBxoHLWHpLp8R4=
=b8Ab
-----END PGP SIGNATURE-----