(* P1comb = f[P1]; *)
P1comb = f[P1] - Count[{ }, P1];
P2comb = f[P2] - Count[{P1}, P2];
B1comb = f[B1] - Count[{P1, P2}, B1];
B2comb = f[B2] - Count[{P1, P2, B1}, B2];
P3comb = f[P3] - Count[{P1, P2, B1, B2}, P3];
B3comb = f[B3] - Count[{P1, P2, B1, B2, P3}, B3];
I am writing the above code, which works perfectly fine. Then I noticed a pattern, so I am just wondering if I might be able to write it better (more compactly) and more efficient using something like FoldList or NestList combined with a pure function, like
FoldList/NestList [] & {P1,P2,B1,B2,P3,B3}
Thanks.


bigfunction, it used double of the execution time. I think it might be caused byAppend? But don't worry. That's not really the point here. – Chen Stats Yu Jun 18 '18 at 01:25