# Question:how do I count the number of times a value appears in a set within a list?

## Question:how do I count the number of times a value appears in a set within a list?

Maple

Hi,

I will start off with the programming already accomplished. The first part of programming was salvaged from mathexchange whereby I am able to perform combinations with repititions.

>with(combinat):
choosing:=proc(n,m,k:=1)
local duplicated:=[seq(op(n),i=1..k)]:
return combinat:-choose(duplicated,m):
end proc:
>choosing([w,b,g],4,4);
[[b, b, b, b], [b, b, b, g], [b, b, b, w], [b, b, g, g], [b, b, g, w], [b, b, w, w], [b, g, g, g], [b, g, g, w], [b, g, w, w], [b, w, w, w], [g, g, g, g], [g, g, g, w], [g, g, w, w], [g, w, w, w], [w, w, w, w]]

the next step I'm hoping to accomplish is to receive a list giving me a count of each value from each set of combinations. For example, in the first set i have 4 counts of black (b), 0 counts of white (w) and 0 counts of grey (g).  the second set tells me i have 3 counts of b, 0 counts of w and 1 count of g, etc.

the purpose of this is to apply a formula to each set of values.

﻿