Mercury 勉強メモ

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

P-99

P-99: 1.17 Split a list into two parts; the length of the first part is given.

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

P-99: 1.16 Drop every N'th element from a list

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

P-99: 1.15 Duplicate the elements of a list a given number of times

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

P-99: 1.14 Duplicate the elements of a list

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

P-99: 1.13 Run-length encoding of a list (direct solution)

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. Mercury では表現できないので省略.

P-99: 1.12 Decode a run-length encoded list

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

P-99: 1.11 Modified run-length encoding

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. Mercury では表現できないので省略.

P-99: 1.10 Run-length encoding of a list

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

P-99: 1.09 Eliminate consecutive duplicates of list elements

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

P-99: 1.08 Eliminate consecutive duplicates of list elements

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

P-99: 1.07 Flatten a nested list structure

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. 今回はMercury向けに問題を少し変更しています. ["a", "b", "c", "d", "e"]

P-99: 1.06 Find out whether a list is a palindrome

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. Yes

P-99: 1.05 Reverse a list

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

P-99: 1.04 Find the number of elements of a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. 4

P-99: 1.03 Find the K'th element of a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. c

P-99: 1.02 Find the last but one element of a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. c

P-99: 1.01 Find the last element of a list

P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます. d