# Multiply single Elements of a List with each other in specific ways

I have a problem with one code and hope that you can help me with that.

I have a list which looks like the following

List = {a, b, c, d, e}


the desired result is a new list with

{a, a*b, a*b*c, a*b*c*d, a*b*c*d*e}


• Like Fold[Times, 1, list]? Also List is a built-in symbol, so don't use it as a variable. Stick to variables starting with lower-case letters. – J. M.'s ennui Jan 31 '20 at 16:11
• @J.M. your command returns abcde. The OP asks that this is the final element of the new list created by multiplication of the elements of the original ones. – DiSp0sablE_H3r0 Jan 31 '20 at 16:16
• Oops, that should be FoldList[] and not Fold[]; thanks @Darth! – J. M.'s ennui Jan 31 '20 at 16:17
• @J.M.isinlimbo that's the trick, yes. I tried to do it using Nest, NestList and failed spectacularly :-) – DiSp0sablE_H3r0 Jan 31 '20 at 16:18
• FoldList[Times, {a, b, c, d,e}] – A little mouse on the pampas Feb 1 '20 at 5:25

Accumulate takes the sum of the terms: this can be changed to the product of by changing the Plus to Times:

 list = {a, b, c, d, e};
Accumulate@list /. Plus -> Times
{a, a b, a b c, a b c d, a b c d e}

• Alternatively Block[{Plus = Times}, Accumulate@list] if you don't want to use replacements. – NonDairyNeutrino Feb 1 '20 at 5:58

Another way:

list = {a, b, c, d, e};
E^Accumulate[Log[list]]


Since Accumulate equals Rest[FoldList[Plus,0,list]] , So Foldlist also works.

Here's an operator version of @JM's suggestion in the comments:

list = {a, b, c, d, e};

FoldList[Times] @ list


{a, a b, a b c, a b c d, a b c d e}

Another:

ReplaceList[{a, b, c, d,e}, { x__,___} :> Times@x ]


{a, a b, a b c, a b c d, a b c d e}

Comparing:

ReplaceList[{a, b, c, d,e}, { x__,___} :> Times@x ] == FoldList[Times] @ {a, b, c, d,e}


True