I would like to create a function with several expressions in the code body.
For example, I would like to write something like this, but which will actually work.
myFunction[x]:=
y=x
y=y+3;
(y+3)^3
I know that I can do this :
myFunction[x]:=(y=x;y=y+3;(y+3)^3)
But it will be hardly writable if I have a lot of expression to evaluate.
How can I do it?
(I just installed Mathematica and read some tutorials on the internet so my knowledge is veeeeeery basic).
Module[{y},...]to makeya local variable. You can use newlines, they have no syntactical meaning. – Felix Feb 28 '17 at 15:00myFunction[x]:=Module[{y},y=x;y=y+3;(y+3)^3]And I can do newline between my ";" ? – StarBucK Feb 28 '17 at 15:04Module(or simply parentheses for that matter) you can use a newline for spacing, but you still need;(CompoundExpression) or you end up multiplying expressions unintentionally. Please see (41091) for more. – Mr.Wizard Feb 28 '17 at 15:11