IF Computer > MINERVA > Manual > Reference > Predicates > Term vector

Term vector

MINERVA
ifcomputer logo
f
Expert Services on the Web

Minerva supports so called term vectors to store and retrieve terms.

There exist different types of predicate classes to support the management of global data: the Minerva database (manipulated with assert, retract, clause, etc), global variables (manipulated with set_global, get_global, etc), blackboards (manipulated with bb_put, bb_get, etc) and term vectors.
There exist the following predicates to handle term vectors:

  • tv_create/1
  • tv_add/2
  • tv_size/2
  • tv_setsize/2
  • tv_set/3
  • tv_get/3
  • tv_list/2

A term vector is a kind of dynamically resizable array of terms.
Before you can store/retrieve terms from a term vector, you have to create a term vector. This is done with tv_create/1. The term vector is initially empty, i.e. it's size is 0. You may add terms to the term vector with the predicates tv_add/2 or tv_set/3. You may retrieve all terms of the vector by calling tv_list/2 and you can access a single term with tv_get/3.

Examples:

main(_) :-
    my_findall(I, for(1,I,10), Numbers).

my_findall(Term, Goal, Terms) :- % create a term vector ... tv_create(Vector), % .. . add a bulk of data to it ... retrieve_info(Vector, Term, Goal), % ... and collect all terms. tv_list(Vector, Terms).

retrieve_info(Vector, Term, Goal) :- % call a goal ... call(Goal), % ... store the information ... tv_add(Vector, Term), % ... and backtrack until there are no more results. fail. retrieve_info(_, _, _).

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/termvector/print_en.html
published 2008/7/14 update 2003/1/23 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS