# Determining the Ordinal Position of a Node

Given a list and a node, you can determine the position of the node within the list, counting from the beginning or the end of the list. To determine the position of a node relative to the beginning of a list, use the `GetNodePosFromHead()` function:

  `int32 GetNodePosFromHead( const List *l, const Node *n );`

The`l` argument is a pointer to the list in which the node is located; the `n` argument is the node to find in the list. The function scans the list looking for the node, and returns the position of the node within the list. The first node in the list has position 0. If the node cannot be located in the list, the function returns -1.

To determine the position of a node relative to the end of a list, use the `GetNodePosFromTail()` function:

  `int32 GetNodePosFromTail( const List *l, const Node *n );`

The `l` argument is a pointer to the list in which the node is located; the `n` argument is the node to find in the list. The function scans the list looking for the node, and returns the position of the node relative to the end of the list. The last node in the list has position 0. If the node cannot be located in the list, the function returns -1.