Generating subsets using length/2 and ord_subset/2
问题 I am a beginner in prolog. I tried this in swipl interpreter: ?- length(Lists, 3), ord_subset(Lists, [1, 2, 3, 4]). false. expecting to get all length-3 lists that are subsets of [1, 2, 3, 4] like [1, 2, 3] or [1, 2, 4]. Why do i get false? Notice: both length and ord_subset are builtin functions (or whatever they are called) in SWI-Prolog. 回答1: You don't get a solution because the ord_subset/2 predicate only checks if a list is a subset of another list; it does not generate subsets. Here is