Subject: Package descriptive, working with frequency lists
From: Barton Willis
Date: Tue, 11 Dec 2012 13:23:57 +0000
To avoid a Maxima misfeature, the variable p needs to be declared local. Without the local declaration,
Maxima checks if p is a global array before it checks if p is a locally defined list.
frequ_mean(x) := block([sum:0, total:0],
local(p),
for p in x do
(sum: sum+p[1]*p[2],
total: total+p[2]),
sum/total)$
Without local(p):
(%i2) p[1,2] : 9$
(%i3) frequ_mean([[1,2],[10,20]]);
evaluation: array p must have 2 indices; found: p[1]
--Barton
________________________________