:- module(concat_atoms,[concat_atoms/2,
			add_prefix/3
			]).

%
% concat a list of nested atoms
%

:- [prolog_detect].
:- prolog_detect:prolog(Prolog),
	(	(	Prolog=sicstus,
			use_module(library(lists))
		);
		(	Prolog=pfdm,
			use_module(library(lists))
		);
		true
	).


concat_atoms([],X) :-
	name(X,[]).
concat_atoms([A|As],Atom) :-
	name(A,S),
	concat_atoms(As,Temp_a),
	name(Temp_a,Ss),
	append(S,Ss,String),
	name(Atom,String).


%
% add_prefix(?Prefix,?Atom,?Result)
%
% ?Prefix	=	prefix (an atom) to be added to Atom
% ?Atom		=	atom to which Prefix is to be added
% ?Result	=	the resulting atom

% add a prefix to an atom
%
add_prefix(Prefix,Atom,Result) :-
	var(Result),
	name(Atom,Atom_string),
	name(Prefix,Prefix_string),
	append(Prefix_string,Atom_string,Result_string),
	name(Result,Result_string),
	!.

add_prefix(Prefix,Atom,Result) :-
	nonvar(Result),
	name(Result,Result_string),
	append(Prefix_string,Atom_string,Result_string),
	name(Atom,Atom_string),
	name(Prefix,Prefix_string).


