Availability:C-language interface function
bool PL_cons_list(term_t
-l, term_t +h, term_t +t)Create a list (cons-) cell in l from the head h
and tail t. As with PL_cons_functor(),
the term references h and t may be used for other
purposes after the call to PL_cons_list().
The code below creates a list of atoms from a char **
. The
list is built tail-to-head. The PL_unify_*()
functions can
be used instead to build a list head-to-tail.
void
put_list(term_t l, int n, char **words)
{ term_t a = PL_new_term_ref();
PL_put_nil(l);
while( --n >= 0 )
{ PL_put_atom_chars(a, words[n]);
PL_cons_list(l, a, l);
}
}