Lisp Scheme Part22 ..
[2ch|▼Menu]
89:デフォルトの名無しさん
08/05/24 15:33:59
prolog で解いてみた。いろいろ微妙。
xor( A, B ) :-
A -> ¥+B ; B.

truth(Is) :-
Is = [ [rabbit, g], [hatman, n], [yamane, n] ] ;
Is = [ [rabbit, n], [hatman, g], [yamane, n] ] ;
Is = [ [rabbit, n], [hatman, n], [yamane, g] ] .

rabbit_says(Is) :-
truth(Is),
member( [rabbit, n], Is ).

hatman_says(Is) :-
truth(Is),
member( [hatman, n], Is ).

yamane_says(Is) :-
xor( rabbit_says(Is), hatman_says(Is) ).

more_research(Is) :-
xor( rabbit_says(Is), yamane_says(Is) ).

solve(It) :-
truth(It),
yamane_says(It),
more_research(It).

?- findall(It, solve(It), All).
All = [[[rabbit, g], [hatman, n], [yamane, n]]].



次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4751日前に更新/247 KB
担当:undef