
bag_retrieve(+BagHandle, -List)

   Retrieve a bag's contents

Arguments
   BagHandle           A bag
   List                A variable or list of terms

Type
   Non-logical Variables, Arrays, Bags, Shelves and Stores

Description
	This returns a list containing a copy of every term that has
	been entered into the bag since it was created.  It should not
	be assumed that the list order reflects the order in which the
	terms were entered into the bag.  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
   bag_retrieve(+, -) is det

Exceptions
     4 --- BagHandle is not instantiated
     5 --- BagHandle is not a bag
    40 --- BagHandle refers to an already destroyed bag

Examples
   
    simple_findall(Goal, Solutions) :-
    	bag_create(Bag),
	(
	    call(Goal),
	    bag_enter(Bag, Goal),
	    fail
	;
	    true
	),
	bag_retrieve(Bag, Solutions),
	bag_abolish(Bag).
    

See Also
   bag_create / 1, bag_enter / 2, bag_count / 2, bag_erase / 1, bag_abolish / 1, bag_dissolve / 2
