Mercury 勉強メモ

関数論理型言語 Mercury を勉強するブログです.

2014-03-01から1ヶ月間の記事一覧

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"], …

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"]["c…

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",…

P-99: 1.25 Generate a random permutation of the elements of a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. ["f", "e", "a", "c", "b", "d"]

P-99: 1.24 Lotto: Draw N different random numbers from the set 1..M

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. [3, 14, 25, 42, 17, 49]

P-99: 1.23 Extract a given number of randomly selected elements from a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. ["e", "h", "f"]

P-99: 1.22 Create a list containing all integers within a given range

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. [4, 5, 6, 7, 8, 9]

P-99: 1.21 Insert an element at a given position into a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. ["a", "alfa", "b", "c", "d"]

P-99: 1.20 Remove the K'th element from a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. b ["a", "c", "d"]

P-99: 1.19 Rotate a list N places to the left

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. ["d", "e", "f", "g", "h", "a", "b", "c"] ["g", "h", "a", "b", "c", "d", "e", "f"]