Re: New to Mathematica- How to write functions????????
- To: mathgroup at smc.vnet.net
- Subject: [mg58880] Re: New to Mathematica- How to write functions????????
- From: OT <montoz at invalidiol.it>
- Date: Fri, 22 Jul 2005 01:58:30 -0400 (EDT)
- References: <dboufp$sse$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Someonekicked ha scritto: > 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; > } > > this function in Mathematica would be: xxx[s_Integer, y_Integer]:=Module[{Q}, Q = s*y; Q ] more generally: type_t function( some_input ) { int local_var_1; double local_var_2; local_var_1=somefunction(some_input); local_var_2=somefunction(some_input); ... ... return(local_var_2); } wolud be: function[someinput_]:=Module[{local1,local2), local1=somefunction[someInput]; local2=somefunction[someInput]; ... ... local2 } bye
- Follow-Ups:
- Re: Re: New to Mathematica- How to write functions????????
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: New to Mathematica- How to write functions????????