ListTerm deleteFromList(int index, ListTerm l) { ListTerm r = new ListTermImpl(); ListTerm last = r; int i = 0; for (Term t : l) { if ((i++) != index) last = last.append(t.clone()); } return r; }
ListTerm deleteFromList(Term element, ListTerm l, Unifier un) { Unifier bak = un; ListTerm r = new ListTermImpl(); ListTerm last = r; for (Term t : l) { boolean u = un.unifies(element, t); if (u) un = bak.clone(); else last = last.append(t.clone()); } return r; }