| |||||||||||
| Retrieves the ith term in a term vector.
tv_get(+Vector, +Index, ?Term)tv_get/3 retrieves a copy of the term at index Index in the term vector Vector and unifies it with Term. Index has to be an integer in the range 1 .. N, where N is the size of the term vector (see tv_size/2).
Arguments
Vector object (term vector) Index integer Term term
Examples
% find all prime numbers between 1 and N
prime_sieve(N, Primes) :-
% create a term vector
tv_create(Vector),
% set it's size to N and fill all elements to 'prime'
init_sieve(Vector, N),
% set all non prime numbers to 'not_prime'
compute_primes(Vector, N),
% collect all elements still marked with 'prime'
collect_primes(Vector, N, Primes).
Standard
This predicate is not part of the ISO-Prolog Standard.
See alsotv_create/1, tv_add/2, tv_size/2, tv_setsize/2, tv_set/3, tv_get/3, tv_list/2.
| |||||||||||
| |||||||||||
| Back> |
|