Write a predicate
cmp_list/3, the first 2 arguments are 2 lists, and the last one isComparisonwhich meansge,lt,le, orgt.
ge: greater or equal
lt: less than
le: less or equal
gt: greater than
the output should be like this:
the first two lists represent a version of a software, and the function is used to compare two versions of a software to see which one is newer:
?- cmp_list([2,3,4], [2,3,5], C).
C = lt ;
C = le .
?- cmp_list([1,2,3,4], [1,1,8], C).
C = gt ;
C = ge .
This smells like homework, so I’ll just give you a couple of hints.
leorge).[], [V|Vt], ...which could be the end of the recursion when comparing, say 1.2 and 1.2.3, so the third argument should belt.gt.gtorltaccordingly. If they are equal, recurse on the tails.