MathGroup Archive 2009

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

Search the Archive

Foldlist with more than one list as argument

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105504] Foldlist with more than one list as argument
  • From: Faysal Aberkane <faysal.aberkane at gmail.com>
  • Date: Sat, 5 Dec 2009 05:35:03 -0500 (EST)

I think this function can be particularly useful :

FoldListN[f_,x_,l_] := FoldList[f[#1,Sequence@@#2]&,x,Transpose[l]]

Example :
l1 = {a,b,c};
l2 = {1,2,3};
l3 = {=80,=B2,=FF};
l4={X,Y,Z};

FoldListN[f,x,{l1,l2,l3,l4}]

output :
{x,f[x,4,1,=80,X],f[f[x,4,1,=80,X],b,2,=B2,Y],f[f[f[x,4,1,=80,X],b,2,=B2,Y],c,
3,=FF,Z]}


  • Prev by Date: Newbie Qn: Change Directory
  • Next by Date: Re: Flatten alternative
  • Previous by thread: Re: Newbie Qn: Change Directory
  • Next by thread: Re: Evaluating Global Variables Named Strings as