Re: Multiple nests?
- To: mathgroup at smc.vnet.net
- Subject: [mg81787] Re: Multiple nests?
- From: Norbert Marxer <marxer at mec.li>
- Date: Wed, 3 Oct 2007 06:09:57 -0400 (EDT)
- References: <fdvdat$spn$1@smc.vnet.net>
On 3 Okt., 08:37, Anolethron <Humbleguy... at hotmail.com> wrote: > I'm using Mathematica 5.2 and i need to apply a function to a list > several times. I'm using next for doing it once, but after this process > i need to apply a different function to the result of the previous one, > as in this naif example: > > no1[n_]:=Nest[function,list,n] > no2[m_]:=Nest[function2,result of the previous one,m] > no3[l_]:=Nest[function3,resultofthepreviousone,l] > > Is there a command or a way to do this straight away? > > Thanks in advance Hello You can use Fold and Nest. Fold[Nest[#2[[1]],#1,#2[[2]]]&,{a,b,c},{{f1,2},{f2,3},{f3,4}}] will give you: f3[f3[f3[f3[f2[f2[f2[f1[f1[{a,b,c}]]]]]]]]] This menas f1 is applied twice, f3 is applied three times etc You can easily construct a function from this, where you have to supply the functions and the number of evaluations. I hope this helps. Best Regards Norbert Marxer