我的节目(在SWI-Prolog中):
has_ram('one-v',512-mb-ram).
has_ram('one-s',1-gb-ram).
has_ram('m8',2-gb-ram).
has_ram('one-sv',1-gb-ram).
has_processor('one-v',1-ghz).
has_processor('one-s',1.5-ghz).
has_processor('one-m8',2.3-ghz).
has_processor('one-sv',1.2-ghz).
has_brand('one-v',htc).
has_brand('one-s',htc).
has_brand('m8',htc).
has_brand('one-sv',htc).
get_phone_details(X):-
has_brand(X,Y),
has_ram(X,Z),
has_processor(X,P),
write("Name :",X),nl,
write("Brand :",Y),nl,
write("Ram :",Z),nl,
write("Processor :",P).
错误我得到了:
ERROR: write/2: Domain error: `stream_or_alias' expected, found `[78,97,109,101,32,32,32,58]'
我想将手机的详细信息作为输出。
答案 0 :(得分:1)
写/ 1不能那样工作,你可以写:
write('Name ':X),nl,
write('Brand ':Y),nl,
write('Ram ':Z),nl,
write('Processor ':P).