Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: functional programming excercise from Mastering Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55282] Re: functional programming excercise from Mastering Mathematica
  • From: "Valeri Astanoff" <astanoff at yahoo.fr>
  • Date: Fri, 18 Mar 2005 05:34:01 -0500 (EST)
  • References: <d1bflp$lja$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Why not this way :

In[1]:=
foldList[f_,x_,vars_]:=ComposeList[Function[x,f[x,#]]& /@ vars,x]

In[2]:=
foldList[f, x, {a, b, c }]

Out[2]=
{x,f[x,a],f[f[x,a],b],f[f[f[x,a],b],c]}

In[3]:=
FoldList[f, x, {a, b, c }]

Out[3]=
{x,f[x,a],f[f[x,a],b],f[f[f[x,a],b],c]}


v.a.


  • Prev by Date: Writing result of "Do" in a single List
  • Next by Date: Re: Interaction of Sum/Plus and KroneckerDelta
  • Previous by thread: Re: functional programming excercise from Mastering Mathematica
  • Next by thread: Re: functional programming excercise from Mastering Mathematica