| |||||||||||
| 項ベクトルの中でi番目の項を読み出します。
tv_get(+Vector, +Index, ?Term)tv_get/3は、項ベクトルVectorにおけるインデックスIndexでの項のコピーを読み出して、Termでそれを単一化します。 Indexはレンジ1 .. Nにおける整数でなければなりません、そこで、Nは項ベクトルのサイズです。(tv_size/2を参照します)
引数Vector オブジェクト(項ベクトル) Index 整数 Term 項
例題
% 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).
標準
この述語は、ISO-Prolog 標準の要件ではありません。
以下も参照して下さいtv_create/1, tv_add/2, tv_size/2, tv_setsize/2, tv_set/3, tv_get/3, tv_list/2. | |||||||||||
| |||||||||||
| 戻る> |
|