subst(lambda ...), was: multiple evaluations & integrate
- Subject: subst(lambda ...), was: multiple evaluations & integrate
- From: Barton Willis
- Date: Sun, 23 Jun 2013 11:42:37 +0000
The function sublis controls evaluation of lambda forms using mqapply (not mquote):
(%i2) sublis(['sin = lambda([x],42)], sin(z));
1> (MSUBLIS-SUBST ((%SIN SIMP) $Z) T)
2> (MSUBLIS-SUBST ($Z) NIL)
3> (MSUBLIS-SUBST $Z T)
<3 (MSUBLIS-SUBST $Z)
3> (MSUBLIS-SUBST NIL NIL)
<3 (MSUBLIS-SUBST NIL)
<2 (MSUBLIS-SUBST ($Z))
2> (MSUBLIS-SUBST %SIN T)
<2 (MSUBLIS-SUBST ((LAMBDA SIMP) ((MLIST) $X) 42))
<1 (MSUBLIS-SUBST ((((LAMBDA SIMP) ((MLIST) $X) 42)) $Z))
(%o2) 42
(%i3) sublis(['sin = lambda([x],42)], sin(z)), sublis_apply_lambda : false;
1> (MSUBLIS-SUBST ((%SIN SIMP) $Z) T)
2> (MSUBLIS-SUBST ($Z) NIL)
3> (MSUBLIS-SUBST $Z T)
<3 (MSUBLIS-SUBST $Z)
3> (MSUBLIS-SUBST NIL NIL)
<3 (MSUBLIS-SUBST NIL)
<2 (MSUBLIS-SUBST ($Z))
2> (MSUBLIS-SUBST %SIN T)
<2 (MSUBLIS-SUBST ((LAMBDA SIMP) ((MLIST) $X) 42))
<1 (MSUBLIS-SUBST ((MQAPPLY) ((LAMBDA SIMP) ((MLIST) $X) 42) $Z))
(%o3) lambda([x],42)(z)
Maybe $substitute could be modified to use the mqapply trick. As for extending the (obscure) option
variable sublis_apply_lambda to substitute, I dunno--generally I lean toward fewer (obscure) option variables.
Is mqapply used this way a crazy hack that just happens to wrork?
--Barton