del(?Element, ?List, -ResultList)
del(?Element, ?List, +ResultList)

Delete an element from the List (second parameter) and unify the result with the third parameter ResultList.

If the ResultList parameter is not a variable then any or both of the first two parameters can be a variable. The last two examples in the example table below demonstrate this.

This predicate is located in the file 'list.txt', use ensure_loaded/1 to include this file.

see also: conc/3 largest_number/2 last/2 lengthlist/2 member/2 prefix/2 reverse/2 smallest_number/2 sublist/2 suffix/2 sum_list/2 sum_list_integer/2

Example
del(a, [a, b, c], Result). succeeds and the Result variable is unified with the list [b, c]
del(d, [a, b, c], Result). fails because element d could not be removed from the list [a,b,c]
del(A, [b, a, c, d], [b, a, c]). succeeds and the first variable A is unified with the element that must be deleted from the list [b,a,c,d] to produce the list [b,a,c]
A=[d]
del(x, B, [b, a, c]). Four solutions are produced, each possible combination of deleting an element x of a list to produce the list [b,a,c]:
B=[x, b, a, c]

B=[b, x, a, c]

B=[b, a, x, c]

B=[b, a, c, x]

 

 

info@trinc-prolog.com