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

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

Access nth element and remainder of a list
I
Integer position index, counting from 1
List
A list
Elem
Any term
Rest
A list

Description

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

Modes and Determinism

See Also

nth0 / 3, nth1 / 3, nth0 / 4