2 Questions 1.How to find differences in lists in prolog and 2. Determine if the lists are the same
Posted
by Alexander
on Stack Overflow
See other posts from Stack Overflow
or by Alexander
Published on 2010-03-11T15:57:15Z
Indexed on
2010/03/13
15:05 UTC
Read the original article
Hit count: 146
prolog
1.If i have two lists say A and B made upp of different letters. [b,a,c] in list A and [b,d,c,e] in list B how can i get prolog to give me C,which is a list of elements that A has which are not included in list B Ex. So if i type difference([b,a,c],[b,d,c,e],C). I want the answer to read: C=[a]
- If i have two lists where list A is made up off [a,b,c] and list B is [c,a,b] i want the result to be Yes if i type: same([a,b,c],[c,a,b]). since they contain the same elements the fact that they are in a different order does not matter. Also it should only answer yes if all of the elements are the same not if 3/4 are right.
© Stack Overflow or respective owner