MathGroup Archive 2006

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

Search the Archive

Re: generalized foldlist problem


Arek,

No need to use Fold or FoldList.

In[1]:=
fn[list1_List,list2_List]:=
With[{len=Length[list1]+1},Plus@@(Join[Table[0,{#1-1}],Table[list1[[#1]],{Min[#2,len-#1]}],Table[0,{len-#1-#2}]]&@@@Thread[{Range[len-1],list2}])];
In[2]:=
fn[{a,b,c,d,e},{3,2,5,1,6}]
Out[2]=
{a,a+b,a+b+c,c+d,c+e}

dkr


  • Prev by Date: Re: using FindRoot to find multiple answers in a domain?
  • Next by Date: transforming a rule of lists to a list of rules
  • Previous by thread: Re: generalized foldlist problem
  • Next by thread: RE: generalized foldlist problem