P-99: 2.04 A list of prime numbers
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
P-99: 2.03 Determine the prime factors of a given positive integer (2)
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
[{3, 2}, {5, 1}, {7, 1}]
P-99: 2.02 Determine the prime factors of a given positive integer
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
[3, 3, 5, 7]
P-99 2.01 Determine whether a given integer number is prime
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
Yes
P-99: 1.28 Sorting a list of lists according to length of sublists
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
a)
[["o"], ["d", "e"], ["d", "e"], ["m", "n"], ["a", "b", "c"], ["f", "g", "h"], ["i", "j", "k", "l"]]
b)
[["i", "j", "k", "l"], ["o"], ["a", "b", "c"], ["f", "g", "h"], ["d", "e"], ["d", "e"], ["m", "n"]]
P-99: 1.27 Group the elements of a set into disjoint subsets
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
a)
["aldo", "beat"]["carla", "david", "evil"]["flip", "gary", "hugo", "ida"] ["aldo", "beat"]["carla", "david", "flip"]["evil", "gary", "hugo", "ida"] ["aldo", "beat"]["carla", "david", "gary"]["evil", "flip", "hugo", "ida"] ["aldo", "beat"]["carla", "david", "hugo"]["evil", "flip", "gary", "ida"] ["aldo", "beat"]["carla", "david", "ida"]["evil", "flip", "gary", "hugo"] ... ["hugo", "ida"]["david", "flip", "gary"]["aldo", "beat", "carla", "evil"] ["hugo", "ida"]["evil", "flip", "gary"]["aldo", "beat", "carla", "david"]
b)
[["aldo", "beat"], ["carla", "david"], ["evil", "flip", "gary", "hugo", "ida"]] [["aldo", "beat"], ["carla", "evil"], ["david", "flip", "gary", "hugo", "ida"]] [["aldo", "beat"], ["carla", "flip"], ["david", "evil", "gary", "hugo", "ida"]] [["aldo", "beat"], ["carla", "gary"], ["david", "evil", "flip", "hugo", "ida"]] ... [["hugo", "ida"], ["evil", "gary"], ["aldo", "beat", "carla", "david", "flip"]] [["hugo", "ida"], ["flip", "gary"], ["aldo", "beat", "carla", "david", "evil"]]
P-99: 1.26 Generate the combinations of K distinct objects chosen from the N elements of a list
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
["a", "b", "c"] ["a", "b", "d"] ["a", "b", "e"] ["a", "b", "f"] ["a", "c", "d"] ["a", "c", "e"] ["a", "c", "f"] ["a", "d", "e"] ["a", "d", "f"] ["a", "e", "f"] ["b", "c", "d"] ["b", "c", "e"] ["b", "c", "f"] ["b", "d", "e"] ["b", "d", "f"] ["b", "e", "f"] ["c", "d", "e"] ["c", "d", "f"] ["c", "e", "f"] ["d", "e", "f"]