Gobi San
Gobi San

Reputation: 21

Write error in prolog

My program(in 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 Which i got :

ERROR: write/2: Domain error: `stream_or_alias' expected, found `[78,97,109,101,32,32,32,58]'

I would like to get the details of the phone as output.

Upvotes: 2

Views: 1721

Answers (1)

joel76
joel76

Reputation: 5645

write/1 doesn't work like that, you can write :

write('Name      ':X),nl,    
write('Brand     ':Y),nl,    
write('Ram       ':Z),nl,    
write('Processor ':P).

Upvotes: 2

Related Questions