Reputation: 178
Given the code a2.pl:
%% prolog (swipl) command line arguments
%% swipl -s a2.pl -t a --quiet -- "b" "c" "D"
%% which outputs to screen: ['D']
writeln1(Term) :-
term_to_atom(Term,Atom),
writeln(Atom),!.
a:-
current_prolog_flag(argv, AllArgs),
AllArgs=[_,_ | Args],
writeln1(Args),halt.
How can I make my query swipl -s a2.pl -t a --quiet "b" "c" "[[v,b],":-",[[[n,=]]]]"
which returns
['[[v,b],:-,[[[n,=]]]]']
return
[[v,b],":-",[[[n,=]]]]
?
Upvotes: 1
Views: 67
Reputation: 178
I found that the following method could be used to process the term, transforming it to a list, calling a2.pl's a predicate and then transforming it back to a term.
%% term_to_atom([[v,b],":-",[[[n,=]]]],B).
%% B = '[[v,b],":-",[[[n,=]]]]'.
%% ?- string_atom(A,'[[v,b],":-",[[[n,=]]]]').
%% A = "[[v,b],\":-\",[[[n,=]]]]".
%% swipl -s a2.pl -t a --quiet "b" "c" "[[v,b],\":-\",[[[n,=]]]]"
%% ['[[v,b],":-",[[[n,=]]]]']
%% ?- term_to_atom(A,'[[v,b],":-",[[[n,=]]]]').
%% A = [[v, b], ":-", [[[n, =]]]].
Upvotes: 2