Re: New to Mathematica- How to write functions????????

• To: mathgroup at smc.vnet.net
• Subject: [mg58890] Re: [mg58876] New to Mathematica- How to write functions????????
• From: Zhengji Li <zhengji.li at gmail.com>
• Date: Fri, 22 Jul 2005 01:58:40 -0400 (EDT)
• References: <200507211946.PAA29492@smc.vnet.net>
• Reply-to: Zhengji Li <zhengji.li at gmail.com>
• Sender: owner-wri-mathgroup at wolfram.com

```zzz[s_, y_] := Module[
{Q},
Q = s y;
(*do anything you want, each statement ends in a semi*)
....
Q  (* the last statement without a semi is the result of zzz *)
]

On 7/22/05, Someonekicked <someonekicked at comcast.net> wrote:
> new to mathematica, looked at the help, but did not get the help i needed..
>
> I want to write a function that does multiple calculations in its body, then
> it returns a value.
> I am talking about functions similar to functions that you can declare in
> C++.
> can anyone give me an example?
>
>
> in C++, a function would be like, (note int means integer)
>
> int zzz(int s, int y)
> {
>   int  Q;
>   Q = s*y;
>   return Q;
> }
>
>
> well thats just a simple example, the body of my function is going to be
> complicated...
> I know in mathematica, I can solve the same zzz by
> zzz[s_,y_] := s*y;
>
> However, what if i want the body more complicated and do more than one
> thing??
>
>
>

--
Li Zhengji
-------------------------------------------------------------
If all you have is a hammer, everything is a nail.
-------------------------------------------------------------

```

• Prev by Date: Re: a bad demonstration of Mathematica's MathML capabilities
• Next by Date: Re: New to Mathematica- How to write functions????????
• Previous by thread: Re: New to Mathematica- How to write functions????????
• Next by thread: Re: New to Mathematica- How to write functions????????