#
The# filter has one argument, a set filter . The value of the #-filter is the number of squares in its argument. The number of squares
of a set is also called the cardinality of that set.
The # filter always matches a position. If its argument is an empty set, its value is 0.
Suppose for example that the current position is the start position of a chess game. Then
#K ≡ 1 #[Kk] ≡ 2 #P attackedby K ≡ 3
To find a position where there are multiple white queens, you could use:
#Q>1
In this case, however, you could just use
Q>1
because a set filter that is compared to a number is automatically converted to its cardinality (that is, the set filter
is prefaced by #).
Examples
The# filter is used in chameleon.cql, parallelpaths.cql, and queenpawnpinecho.cql.
In chameleon.cql, the line
#[Aa]==source:#[Aa]checks that the number of pieces in the current positions is the same as the number of pieces in the position named by the variable
source, using the : filter.