%%% Test of implode, concat, unescape, and embedded double quotes in strings
%%% Updated for version 1.8 
 
:- eval(test016()).

test016() :-
	% Shows how alternating single and double quotes can be used
	println(["AAA'BBB"CCC'DDD'EEE"FFF'GGG"]),
	% Since version 1.8, unescape allows correctly embedding '\' in strings  
	unescape("\t\\",Unescaped),
	println([Unescaped]).
test016() :-
	% Note an embedded single quote
	unescape("\'",Unescaped),
	println([Unescaped]).
test016() :-
	Dir=java.io.File("."),
	Files=Dir.list(),
	% Both Java List and Prolog lists are accepted by implode
	% In general, if any Java method accepts a Java List
	%    then in our language it also accepts a Prolog list.
	%% Files is a Java List
	implode(" OR ",Files,Result),
	concat(["{",Result,"}"],Final1),
	println([Final1]),
	%% [1,2,3] is a Prolog list
	implode(" AND ",[1,2,3],Final2),
	println([Final2]),
	% Note embedded double quotes in the string to be unescaped 
	unescape("\tline 1\'\n\t\t\"line 2\"\n\tline 3",Unescaped),
	println([Unescaped]).
test016() :-
	HS=java.util.HashSet(),
	type(HS,TypeHS),
	println([TypeHS]),
	R1=HS.addAll([1,"2"]),
	R2=HS.add("1"),
	% Note that we need a return variable as this method can return
	% 	false, as in the case above, causing it to fail, unless
	%  we have a return variable.
	R3=HS.add("2"),
	println(["HS=",HS]),
	% implode works also with objects implementing the Collection interface 
	implode("+",HS,Result),
	println([Result]),
	% Moreover, print and println also work with Collection
	println(HS,"->").
