Mercury 勉強メモ

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

2014-04-14から1日間の記事一覧

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(…

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.