Skip to main content
1 of 4
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112
Clear[P1comb, P2comb, B1comb, B2comb, P3comb, B3comb] a = {P1, P2, B1, B2, P3, B3}; b = {P1comb, P2comb, B1comb, B2comb, P3comb, B3comb}; 

Using lower-case count to illustrate the output. (Replace with Count.)

Array[With[{c = b[[#]]}, c = f[a[[#]]] - count[Take[a, # - 1], a[[#]]]] &, Length[a]] 

E.g.

B3comb

-count[{P1, P2, B1, B2, P3}, B3] + f[B3] 
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112