- Added termlistAddNew function to mimic set behaviour.

This commit is contained in:
ccremers 2004-07-25 18:14:21 +00:00
parent f8aacee6ad
commit 9723fff382
2 changed files with 16 additions and 0 deletions

View File

@ -215,6 +215,19 @@ termlistAppend (const Termlist tl, const Term term)
return tl; return tl;
} }
//! Add a term only to a list if it wasn't in it before.
/**
* Mimics a basic set type behaviour.
*/
Termlist
termlistAddNew (const Termlist tl, const term t)
{
if (inTermlist (tl, t))
return tl;
else
return termlistAdd (tl, t);
}
//! Concatenates two termlists. //! Concatenates two termlists.
/** /**
* The last pointer of the first list is made to point to the second list. * The last pointer of the first list is made to point to the second list.
@ -762,3 +775,5 @@ int termlistOrder (Termlist tl1, Termlist tl2)
else else
return 1; return 1;
} }

View File

@ -32,6 +32,7 @@ __inline__ int inTermlist (Termlist tl, const Term term);
int isTermlistEqual (Termlist tl1, Termlist tl2); int isTermlistEqual (Termlist tl1, Termlist tl2);
Termlist termlistAdd (Termlist tl, Term term); Termlist termlistAdd (Termlist tl, Term term);
Termlist termlistAppend (const Termlist tl, const Term term); Termlist termlistAppend (const Termlist tl, const Term term);
Termlist termlistAddNew (const Termlist tl, const term t);
Termlist termlistConcat (Termlist tl1, Termlist tl2); Termlist termlistConcat (Termlist tl1, Termlist tl2);
Termlist termlistDelTerm (Termlist tl); Termlist termlistDelTerm (Termlist tl);
Termlist termlistConjunct (Termlist tl1, Termlist tl2); Termlist termlistConjunct (Termlist tl1, Termlist tl2);