showfoods :- writeln('-- Foods --'), food(F), color(F,C), format('~w (~w)\n', [F, C]), fail.
;showfoods.

showfoods2 :- writeln('-- Foods --'), food(F), writeln(F), fail.
showfoods2 :- writeln('-- end --').

showfoods3 :- writeln('-- Foods --'), writeln(food(F)), fail.
showfoods3 :- writeln('-- end --').

food(apple).
food(broccoli).
food(carrot).
food(lettuce).
food(orange).
food(rice).
food(rice).
%food('Big Mac') :- true.

food_color(Color) :- food(F), color(F,Color).
%get_fwc(Color, Result) :- food(F), color(F,Color), Result = fwc(F,Color).
get_fwc(Color, fcw(F,Color)) :- food(F), color(F,Color).

food_color(F,C) :- food(F), color(F,C).

liked_food(F) :- food(F), likes(_,F).

liked(X,liked) :- likes(_,X).
liked(X,not_liked) :- \+likes(_,X).

describe_food(Food-Color) :- food(Food), color(Food,Color).
describe_food2(Food,Descrip) :- food(Food), color(Food,Color), liked(Food, Liked), Descrip=Food-Color-Liked.

describe_atom(A, Descrip) :- atom_length(A,Len), Descrip = A-Len.

swap(A,Result) :- term_to_atom(T,A), First-Second=T, Swapped = Second-First, term_to_atom(Swapped, Result).
swap2(A,Result) :- term_to_atom(First-Second,A), term_to_atom(Second-First, Result).


color(sky, blue).
color(dirt, brown).
color(grass, green).
color(broccoli, green).
color(lettuce, green).
color(apple, red).
color(carrot, orange).
color(orange,orange).
color(rice, white).         

likes(bob, carrot).
likes(bob, apple).
likes(joe, lettuce).
likes(mary, broccoli).
likes(mary, tomato).
likes(bob, mary).
likes(mary, joe).
likes(joe, baseball).
likes(mary, baseball).
likes(jim, baseball).

%food(X) :- likes(dave,X).
%likes(dave, burger)
%likes(dave, X) :- likes(mary,X).
