AnyDice

count VALUES in SEQUENCE

This function counts how often any of the listed VALUES occur in the SEQUENCE.

Examples

output [count {1, 2} in {1..6}] named "obviously 2 matches"
output [count 3 in 3d6] named "rolling 3s on 3d6"
output [count {2, 4, 6} in 2d6] named "rolling evens on 2d6"
output [count {4..6, 6} in d6] named "rolling above 3 on a d6, counting 6s double"

Do it yourself

function: count VALUES:s in SEQUENCE:s {
 COUNT: 0
 loop P over {1..#VALUES} {
  COUNT: COUNT + (P@VALUES = SEQUENCE)
 }
 result: COUNT
}