Write a predicate that sorts a list of integers. Use an insertion sort.
Write a predicate permutation(L, M)
that is true if the list L is a permutation of M.
Write a predicate combination(L, N, M)
that is true if M is a combination
of N elements of L, i.e. a subset of size N that has its elements in
the same order as in L.
Write a predicate that sorts a list of integers. Use a merge sort.
Write a predicate that sorts a list of integers. Use a quicksort.
Write a predicate digits(L, N) that converts a list of digits (e.g. [3, 4, 5]) to an integer (e.g. 345).
We can represent a vector as a list of floating-point numbers. Write predicates that can calculate the following:
the sum of two vectors
multiplying a scalar by a vector
the dot product of two vectors
the angle between two vectors
All predicates should work in any direction.
We can represent a matrix as a list of lists of floating-point numbers.
Write a predicate that tests whether a matrix has dimensions N x N, for a given N. Also write predicates that can calculate the following:
the zero matrix of a given size
the sum of two matrices
the first column of a matrix (a vector)
the identity matrix of a given size
the transpose of a matrix
the product of two matrices
All predicates should work in any direction.