|
From: Barton W. <wi...@un...> - 2015-06-01 21:29:38
|
A simple example:
(%i22) larry(x) := block([a],
a[1] : x)$
(%i23) buddy(x) := block([a],
local(a),
a[1] : x)$
(%i24) a[2] : 2015;
(%o24) 2015
(%i25) buddy(0);
(%o25) 0
OK:
(%i26) a[1];
(%o26) a[1]
(%i27) a[2];
(%o27) 2015
Let's try Larry:
(%i28) larry(0);
(%o28) 0
Oops--be careful:
(%i29) a[1];
(%o29) 0
(%i30) a[2];
(%o30) 2015
Also, I think the translator doesn't handle local correctly--maybe this is reported?
(%i1) buddy(x) := block([a],
local(a),
a[1] : x)$
(%i2) translate(buddy);
(%o2) [buddy]
(%i3) a[2] : 2015;
(%o3) 2015
(%i4) buddy(0);
(%o4) 0
--Barton
________________________________
From: Mike Valenzuela <mic...@gm...>
Sent: Monday, June 1, 2015 16:19
To: Barton Willis
Cc: Luigi Marino; max...@li...
Subject: Re: [Maxima-discuss] complete_square
Oh thank you Barton Willis,
I thought block([whatever], ...) made whatever local. I never knew about local. Thank you.
On Mon, Jun 1, 2015 at 1:50 PM, Barton Willis <wi...@un...<mailto:wi...@un...>> wrote:
1. Experiment with replacing ev(b_vec[i,1], map(lambda([avar], avar=0), vars)) with subst(map(lambda([avar], avar=0), vars), b_vec[i,1]) .
The subst function has clean semantics, but ev doesn't.
2. Likely b_vec and c_mat should be declared local; see for example, Robert Dodier<http://search.gmane.org/?author=Robert+Dodier&sort=date> | 19 Jun 16:50 2008 on
http://blog.gmane.org/gmane.comp.mathematics.maxima.general/month=20080601/page=36
--Barton
> complete_square_alt_form:0$
> complete_square(expr, vars):=block([a_const:expr, b_vec, c_mat, c_mat_inv, new_const, offset, x],
...
|