# child

The`child`

filter returns the primary child of the current position. Thus,

x=childwill set the variable

`x`

to the primary child of the current position (if the current position is a terminal position, then the assignment will not match and `x`

will not be modified). Recall that if variations is not set in the CQL header, then the primary child of the current position is the same as the child, as any position has at most one child.
If the `child`

filter is followed by a numeric filter enclosed in parentheses, then the the child with index *i* is returned, where *i* is the value of that numeric filter:

x=child(1)If no such child exists, the filter will not match. Thus

`child`

without an argument is the same as `child(0)`

.

## Getting the number of children

The following computes the number of childen in a position:` countmoves ――`