Re: output forms
- To: mathgroup at smc.vnet.net
- Subject: [mg121512] Re: output forms
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 18 Sep 2011 04:10:33 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
On 9/17/11 at 6:26 AM, kitas11 at yahoo.com (klkj fukyfl) wrote: >Hello, I need Matheamtica to do the following: >in: >a=1; b=2; c=3; d=a+b*c >out: >d=1+2*3 and so on... >previously I was using another system, but I found that this kind of >stuff is impossible >Can this be performed on Mathematica? Yes, but not easily or conveniently. Mathematic by default evaluates expressions immediately when using Set (=). So, by default, a+b*c will evaluate to 7 which will be assigned to d. And the output will be 7. To get the output you are looking for you could convert a,b,c to strings and do something like: In[5]:= {a, b, c} = Range[3]; StringJoin@Riffle[{"d=", "+", "*"}, ToString /@ {a, b, c}] Out[6]= d=1+2*3 There are certain to be other ways to do this within Mathematica. But since you are trying to leave things partially evaluated, you are working at cross purposes to the default way Mathematica operates. Consequently, any method is going to look something like a hack rather than natural input.