Reverse a list (first parameter) and unify the reversed list with the second parameter.
This predicate is located in the file 'list.txt', use ensure_loaded/1 to include this file.
see also: conc/3 del/3 largest_number/2 last/2 lengthlist/2 member/2 prefix/2 smallest_number/2 sublist/2 suffix/2 sum_list/2 sum_list_integer/2
| Example | |
| reverse([], []). | succeeds because [] is the reversed list of [] |
| reverse([a, b], [b, a]). | succeeds because [b, a] is the reverse of the list [a, b] |
| reverse([a, b], [a, b]). | fails because the reversed list of [a,b] is [b,a] and [b,a] cannot be unified with the list [a,b] (=second parameter) |
| reverse([a, b, c, d], B). | succeeds and the B is unified with the reversed list of
[a,b,c,d]: B=[d, c, b, a]] |