Is there something more complex that you are trying to achieve? If the example given is the end goal then you could use a regular expression as your show rule. With longer lists it will become slower and slower.
#let characters = ("Sam", "Dave", "Adam")
#let rePattern = "("+characters.map(c => "\b"+c).join("|")+"):"//(\bSam|\bDave|\bAdam):
#show regex(rePattern): it => {
show ":": [...]
it
}
Alice:
Bob:
Clarice:
Dave:
Output
The regular expression pattern here ends up being (\bSam|\bDave|\bAdam):. The ‘\b’ makes sure that the character before the start of each name is not a character (typically a space). It’s optional but without it you could match too many things.
And if you wanted it as the log function:
Code
#let characters = ("Sam", "Dave", "Adam")
#let rePattern = "("+characters.map(c => "\b"+c).join("|")+"):"//(\bSam|\bDave|\bAdam):
#let log(body) = {
show regex(rePattern): it => {
show ":": [...]
it
}
body
}