Success: concat_atoms(abc,def,abcdef). [eclipse]: [user]. filename(File,Full) :- name(File,L), member(0'.,L) -> Full = File ; concat_atoms(File,'.pl',Full). user compiled 208 bytes in 0.00 seconds yes. [eclipse]: filename(a,P), filename('b.pl',F). P = 'a.pl' F = 'b.pl' yes. Fail: concat_atoms(ab,bc,abc). Error: concat_atoms(art,X,artpaul). (Error 4). concat_atoms(art,"paul",X). (Error 5).