[ Non-logical Variables, Arrays, Bags, Shelves and Stores | Reference Manual | Alphabetic Index ]
bag_enter(+BagHandle, +Term)
Enter a term into an existing bag object
- BagHandle
- A bag
- Term
- An arbitrary term
Description
This enters an arbitrary term into a bag object that has previously
been created with bag_create/1. The order in which terms are entered
into a bag should not be considered relevant, a bag is conceptually
unordered. Entering and retrieving terms from a bag involves
copying the term each time, similar to what happens in setval/getval
and record/recorded. In particular, if the term contains variables,
they lose their identity and are replaced with fresh ones.
Modes and Determinism
Exceptions
- (4) instantiation fault
- BagHandle is not instantiated
- (5) type error
- BagHandle is not a bag
- (40) stale object handle
- BagHandle refers to an already destroyed bag
Examples
simple_findall(Goal, Solutions) :-
bag_create(Bag),
(
call(Goal),
bag_enter(Bag, Goal),
fail
;
true
),
bag_dissolve(Bag, Solutions).
See Also
bag_create / 1, bag_count / 2, bag_abolish / 1, bag_erase / 1, bag_retrieve / 2, bag_dissolve / 2