Availability:C-language interface function
int 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. 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 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);
}
}
Note that l can be redefined within a PL_cons_list
call as shown here because operationally its old value is consumed
before its new value is set.