One can easily consult a Prolog file using consult/1
or [filename].
.
Suppose I generate Prolog code as an atom. I can in a predicate write that code to a file and then consult it, and query a predicate from that code, e.g.
example :-
generate_stuff(X),
write_to_file(X,'filename.pl'),
consult('filename.pl'),
predicate_in_filename.
How would I go about doing the same thing but without writing X
(the code) to a file? I'm having no luck with assert
which takes a term as input whereas here I have complete code in an atom.