[ library(listut) | Reference Manual | Alphabetic Index ]

# nth0(?I, ?List, -Elem, -Rest)

Access nth element and remainder of a list

I
  Integer position index, counting from 0
List
  A list
Elem
  Any term
Rest
  A list

## Description

Unifies Elem with the Nth element of List, counting from 0, and Rest with the other elements. It can be used to select the Nth (counting from 0) element of List (yielding Elem and Rest), or to insert Elem after the Nth (counting from 1) element of Rest, when it yields List, e.g. nth0(2, List, c, [a,b,d,e]) unifies List with [a,b,c,d,e].

### Modes and Determinism

- nth0(+, +, -, -) is det
- nth0(-, +, -, -) is nondet
- nth0(-, -, -, -) is nondet

## See Also

nth0 / 3, nth1 / 3, nth1 / 4