[ library(listut) | Third Party Libraries | Reference Manual | Alphabetic Index ]

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

Access nth element and remainder of a list
Integer position index, counting from 0
A list
Any term
A list


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

See Also

nth0 / 3, nth1 / 3, nth1 / 4