nth0/6

nth0(? N, ? List, ? Elem, ? Rest)*

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 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. nth0(2, List, c, [a,b,d,e]) unifies List with [a,b,c,d,e]. nth//44 is the same except that it counts from 1. nth0//44 can be used to insert Elem after the Nth element of Rest.