# ✵

`✵`

(or `flip`

) is a transform filter corresponding to the following 8 basic transforms.
**id**, the identity**rotate**: counterclockwise rotation about the board center by 90°_{90}**rotate**: rotation by 180° about the board center_{180}**rotate**: clockwise rotation about the board center by 90°_{270}**reflect**: reflection about the horizontal bisector._{h}**reflect**: reflection about the vertical bisector._{v}**reflect**reflection about the_{a1h8}`a1-h8`

diagonal.**reflect**: reflection about the_{h1a8}`h1-a8`

diagonal.

These are called dihedral transforms because they arise from the rigid transformations of a chessboard into itself.

`✵`

is normally called with a single argument filter, *F*:

✵F

`✵`

also accepts an optional `count`

parameter.
`✵`

matches the current position if any transformation of *F**F* by one of the 8 basic transforms above matches the current position.

For example, suppose *F* is the filter `{♔a1 ♚h8}`

, matching a position in which the white king is on `a1`

and the black king is on `h8`

. If we transform this filter by **reflect _{h}** we get the new filter

`{♔a8 ♚h1}`

. The filters that results from transforming `{♔a1 ♚h8}`

by all the elements of `✵`

, which is to say all the reflections and rotations of the board including the identity, are:
{♔a1 ♚h8} {♔h1 ♚a8} {♔a8 ♚h1} {♔h8 ♚a1}

The filter `✵{♔a1 ♚h8}`

will thus match a position if any of these four filters match the position, that is, if the kings are on opposite corners in the current position. (This can also be done, much more efficiently, using `♚==diagonal 7 ♔`

)

If *F* is a set filter then so is

✵F

in which case its value is the union of the values of each of the sets represented by each transformed version of *F*.

For example,

`✵a1`

is the set `[a1,h1,a8,h8]`

.

If *F* is a numeric filter then so is `✵`

in which case its value is the maximum of the values of all the values of the matching transformed versions of *F**F*.

✵countF

is a numeric filter whose value is the number of distinct matching transformed versions of *F*. For example, if the current position is the initial position, then

✵count find {♕a1 ♛h8}

is the number of distinct configurations of the white and black queens on opposite corners that occur in a game. In other words, this is the number of corner squares such that there is some position in the game in which a white queen is on that corner and a black queen on the opposite corner.

The `✵`

filter also modifies directions parameters and filters. Thus,

✵up♖ //The ✵ of squares above a ♖

matches whenever

orthogonal♖ //squares to the left, right, above or below some ♖

matches.

# Examples

`✵`

is used in staircase-sort.cql , which finds staircase maneuvers by the queen. There, a staircase is defined using a particular pair of directions, and `✵`

is used to generate all the other directions.