?- print_list([a,b,c]). a b c
?- create_list(5,12,S). S=[5,6,7,8,9,10,11,12]
?- increment_elements([5,6,a,8,b],S). S=[6,7,a,9,b]
?- encaps([a,b,1,d,e],S). S = [[a],[b],,[d],[e]]
?- insert_zeros([1,2,3,4,5],S). S = [1,0,2,0,3,0,4,0,5,0]
?- clone([g,6,7],S). S = [[g,6,7][g,6,7]]
?- modify([m,o,d,i,f,y,e,t],6,i,Y). Y = [m,o,d,i,f,y,i,t]
% random_matrix(I,J,N,Mat). ?- random_matrix(0,9,3,M). M = [[2,4,5],[1,0,3],[9,3,2]]
subset(L,K), which holds iff L is a subset of K.
disjoint(L,K), which holds iff L and K are disjoint (i.e. they have no elements in common).
union(L,K,M), which holds iff M is the union of L and K.
intersection(L,K,M), which holds iff M is the intersection of L and K.
difference(L,K,M), which holds iff M is the difference of L and K.
Consider two different implementations: (1) the input list can have repeated elements, (2) the input list does not have repeated elements (it is, in fact, a set).
length(L,N)which holds iff N is the length of the list L.
sumlist(L,N)which, given a list of integers L, returns the sum N of all the elements of L. (the input list must contain only numbers.)
add_up_list(L,K)which, given a list of integers L, returns a list of integers in which each element is the sum of all the elements in L up to the same position. For example:
?- add_up_list([1,2,3,4],K). K = [1,3,6,10]; no
merge(L,K,M)which, given two ordered lists of integers L and K, returns an ordered list M containing all the elements of L and K.
emptybt the empty binary tree consbt(N,T1,T2) the binary tree with root N and left and right subtrees T1 and T2
preorder(T,L)which holds iff L is the list of nodes produced by the preorder traversal of the binary tree T.
search_tree(L,T)which, given a list of integers L, returns a balanced search-tree T containing the elements of L.