Prolog - Hello You Program


Home

Author: Jeronimo Pellegrini
Date: October 22, 1997
Info:
% Predicates used may not exist in certain implementations of Prolog;
% Also, some predicates defined may exist (maybe with different names) 
% as built-in in some implementations.
% This program was tested using SWI.

helloyou:-
	write('What is your name? '),
	readln(N),
	write('Hello, '),
	write_list(N).

write_list(N):-
	toatom(N,A),
	write_ln(A).

toatom(N,Result):-
	N = [First,Second|Rest],
	concat(First,' ',A),
	concat(A,Second,Concat),
	concat(Concat,' ', Concatenated),
	toatom([Concatenated|Rest],Result).

toatom(N,Result):-
	N = [Inside],
	atom(Inside),
	Result = Inside.

Home