Skip to main content
3 of 4
added 171 characters in body
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112
Clear[P1, P2, B1, B2, P3, B3] 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 initially, to be replaced with Count

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

Examples

P1comb 
-count[{}, P1] + f[P1] 
B3comb 
-count[{P1, P2, B1, B2, P3}, B3] + f[B3] 

Assigning values after symbolic construction.

With[{d = a}, d = {1, 2, 3, 4, 3, 2}]; B2 
4 
B3comb /. count -> Count 
-1 + f[2] 
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112