P-99: 4.02 Construct completely balanced binary trees
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
t('x', t('x', t('x', nil, nil), nil), t('x', nil, nil)) t('x', t('x', nil, t('x', nil, nil)), t('x', nil, nil)) t('x', t('x', nil, nil), t('x', t('x', nil, nil), nil)) t('x', t('x', nil, nil), t('x', nil, t('x', nil, nil)))
P-99: 4.01 Check whether a given term represents a binary tree
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
Mercuryでは以下のようなユーザ定義型でTreeを表すので、形式のチェックは不要。
:- type tree(T) ---> t(T, tree(T), tree(T)) ; nil.
P-99: 3.05 Huffman code
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
[{'a', "0"}, {'b', "101"}, {'c', "100"}, {'d', "111"}, {'e', "1101"}, {'f', "1100"}]
P-99: 3.04 Gray code
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
["000", "001", "011", "010", "110", "111", "101", "100"]
P-99: 3.03 Truth tables for logical expressions (3)
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
no no no yes no no yes yes no yes no yes no yes yes yes yes no no yes yes no yes yes yes yes no yes yes yes yes yes
P-99: 3.02 Truth tables for logical expressions (2)
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
yes yes yes yes no yes no yes no no no no
P-99: 3.01 Truth tables for logical expressions
P-99: Ninety-Nine Prolog Problemsの問題にMercuryで解答していきます.
yes yes yes yes no yes no yes no no no no