Re: Reevaluation of conditional arguments when the condition has changed
- To: mathgroup at smc.vnet.net
- Subject: [mg61056] Re: Reevaluation of conditional arguments when the condition has changed
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Sun, 9 Oct 2005 01:35:05 -0400 (EDT)
- Organization: Uni Leipzig
- References: <di7r8p$koj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, expr1 /. DownValues[foo] Regards Jens PS: This seems to be a bug, introduced by some kind of optimization. "David Park" <djmp at earthlink.net> schrieb im Newsbeitrag news:di7r8p$koj$1 at smc.vnet.net... | Dear MathGroup, | | Here is a programming problem that stumps me. We start with a condition that is always False. | | fooQ[_] := False | | Then write a definition that will factor out multipliers of fooQ objects. | | foo[a_ b_?fooQ] := a foo[b] | | The following does not factor because b, or anything else, fails the test. | | expr1 = foo[a b] | giving: foo[a b] | | Now I define b as a fooQ object. | | fooQ[b] := True | | Now when I enter the same expression the a factors out. | | foo[a b] | giving: a foo[b] | | But if I reevaluate expr1 the definition is not applied. | | expr1 | giving: foo[a b] | | Why shouldn't I expect that to evaluate and now factor? Is there a proper way to write the definitions so it will evaluate? | | David Park | djmp at earthlink.net | http://home.earthlink.net/~djmp/ | |