Re: FullForm puzzle.

*To*: mathgroup at smc.vnet.net*Subject*: [mg106302] Re: FullForm puzzle.*From*: Norbert Marxer <marxer at mec.li>*Date*: Fri, 8 Jan 2010 04:12:41 -0500 (EST)*References*: <hi42dp$n3h$1@smc.vnet.net>

On Jan 7, 8:27 am, Jack L Goldberg 1 <jackg... at umich.edu> wrote: > Fellow mathematistas: > > I sent this post to the two responders but thought it might be of interest > > I use a transformations in some of my code that takes a <= x <= b > and converts it into a function I have defined called "characteristic > function" - the name is obviously irrelevant. But to make this > transformation I need to know what the FullForm is. If it (the > FullForm) varies from one command to another, how can I count on my > transformation working. For example, suppose a line in my Module > looks like this: > (1) "something"/.LessEqual[2,x,3] -> characteristic[x,2,3] > > But if "something" contains the FullForm "Inequality[ ... ]" the > transformation explicit in (1) will fail. > > I ran into this and found a simple work-around. However, it took me a > couple of hours to pinpoint the problem since it was imbedded in a > relatively long code. > > Jack Hello I would use LogicalExpand with your expressions. Then your three expressions will all have the same FullForm. (*This gives False*) e1 = LessEqual[2, x, 3]; e2 = Inequality[2, LessEqual, x, LessEqual, 3]; e3 = 2 <= x && x <= 3; SameQ[e1, e2, e3] (*This gives True*) e1L = LogicalExpand[e1]; e2L = LogicalExpand[e2]; e3L = LogicalExpand [e3]; SameQ[e1L, e2L, e3L] SameQ[e1L // FullForm, e2L // FullForm, e3L // FullForm] I hope this helps. Best Regards Norbert Marxer