Did you know ... Search Documentation:
Pack with_memory_file -- README.md

prolog-with-memory-file

Like with_output_to but for memory files

?- with_memory_file(string(String), write, [Stream]>>write(Stream, foo)).
String = "foo".

License

See LICENSE