[ Recorded Database | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
erase(+Key, ?Value)
Succeeds if the term Value associated with key Key is removed as an entry
in the indexed database.
- +Key
- Atom or compound term.
- ?Value
- Any Prolog term.
Description
Finds the first term associated with Key that can be unified with Value
and removes its entry from the indexed database. It fails if such an
entry cannot be found. If Value is uninstantiated, the first value
under the key Key is removed. In the case of compound terms, all keys
of the same name and arity are treated as equal. Backtracking through
calls of erase/2 does not undo an erasure.
Fail Conditions
Fails if Value associated with Key is not a record in the indexed
database.
Resatisfiable
No.
Exceptions
- (4) instantiation fault
- Key is not instantiated.
- (5) type error
- Key is neither an atom nor a compound term.
Examples
Success:
[eclipse]: record(whiskey,jameson),
> record(whiskey,bushmills),
> record(whiskey,glenfiddich),
> record(whiskey,dimple).
yes.
[eclipse]: erase(whiskey,dimple),erase(whiskey,Value).
Value = jameson
yes.
[eclipse]: recorded(whiskey,L).
L = bushmills More? (;)
L = glenfiddich More? (;)
no (more) solution.
Fail:
erase(whiskey,jameson).
Error:
erase(Key,anything). (Error 4)
erase("whiskey",anything). (Error 5)
See Also
erase_all / 1