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]}