Re: generalized foldlist problem
- To: mathgroup at smc.vnet.net
- Subject: [mg69129] Re: generalized foldlist problem
- From: "dkr" <dkrjeg at adelphia.net>
- Date: Wed, 30 Aug 2006 06:35:11 -0400 (EDT)
- References: <ed0rja$sll$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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