       Re: newbie question on functions

• To: mathgroup at smc.vnet.net
• Subject: [mg51768] Re: newbie question on functions
• From: David Bailey <dave at Remove_Thisdbailey.co.uk>
• Date: Mon, 1 Nov 2004 02:53:04 -0500 (EST)
• References: <cm22t7\$gk1\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Todd Allen wrote:
> Hi all,
>
>      I have what is probably a nieve question, but it is giving me some difficulty.  I am trying to generate a function in which I pass two columns of information from a matrix to this function to perform some calculations.  I can successfully pass the data and get the resulting calculation......but the problem is the function returns the results but does not save the results in memory to perform subsequent calculations with.  How can I get the function to keep the result?  Is there a way to assign the function output to a new variable before mathematica discards the results.  Does this behavior have anything to do with the Head of the function  being symbolic, rather than say a list??
>
> Below is the relevant code:
>
> SetAttributes[ratio,Listable];
> SetAttributes[intensity,Listable];
>
> ratio[cy3_,cy5_]:=Table[Log[2,(cy3/cy5)]]//N;
> intensity[cy3_,cy5_]:=Table[Log[2,(cy3*cy5)]]//N;
> ratio[Table[fmicroarray[[i,18]],{i,1,Length[fmicroarray]}],
>   Table[fmicroarray[[i,19]],{i,1,Length[fmicroarray]}]]
>
>
> I appreciate any insight you might have.  Thanks.
>
> Todd
>
Yes, of course you can save the result of a calculation. For example:

result=intensity[4.,5.]

In fact, even if you do not explicitly save your answer Mathematica
saves it and you can use the % notation to access it. This can be
useful, but I don't generally recommend it for routine use because if
you re-execute the cells in a notebook in a different order '%' may
refer to something else the next time round!

David Bailey

```

• Prev by Date: Re: Re: 3D plotting problem
• Next by Date: Re: bimodal ditribution form counting signs of Pi digits differences
• Previous by thread: Re: MPS format, Linear Programming, and Optimization'MPSData
• Next by thread: Re: newbie question on functions