If I have a list $L$ in GAP, and a certain list of properties $a,b,c$, how can I count the the number of elements in my list that have all three properties? I've searched the manual (chapter on Lists), but haven't found the function I'm looking for.

Specifically, if $G$ is a finite group, the list I am working with is:


I'd like to count the elements in this list that would return true for all three of the following queries:


for specified values of $m$ and $n$. I'd like to avoid going through a list and counting 'trues,' so it would be great if GAP could just give me a number.


2 Answers 2


More succinct is:

Number(L,c->IsAbelian(c) and Exponent(c)=n and Order(c)=m);
  • 4
    $\begingroup$ Also, if you want a list of elements with the desired properties, you can use "Filtered(L, c->IsAbelian(c) and Exponent(c)=n and Order(c)=m);". $\endgroup$ Aug 7, 2013 at 6:44

I just answered my own question. Here it is if anyone is interested.

SizeBlist(List(L,c->IsAbelian(c) and Exponent(c)=n and Order(c)=m))

SizeBlist counts the true entries in a Boolean list, and due to the use of 'and' the nested list will only have a true value if the representative subgroup satisfies all three conditions.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .