Use sum_if() Let's say you want the count of children of prototype 'pArticle':
What you are doing is collecting a list of qualifying objects (i.e. a sub-set of the children) setting a value of 1 for each item and returning the sum of those values - i.e. your modified child-count.
Ah, @galen beat me to it, but happily we're in accord. Seeing his examples, reminds me to point out that the second 'filter' input to
sum_if() is actually a query, i.e. the syntax you use in an agent's query or in
find(). Thus the filter could be more than one test. For instance, counting all children that aren't of prototype 'pArticle' and are not separators:
sum_if(children, $Prototype!="pArticle"& !$Separator,1)
sum_if parameters are separated by commas but f it helps you understand the process better you can safely put parentheses around your query. So the above can also be:
sum_if(children, ($Prototype!="pArticle"& !$Separator),1)