Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5042

Re: output forms

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: output forms
Date 2011-09-18 08:15 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j549av$6an$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 9/17/11 at 6:26 AM, kitas11@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.

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: output forms Bill Rowe <readnews@sbcglobal.net> - 2011-09-18 08:15 +0000

csiph-web