scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

library(pio): phrase_to_file does not accept the file mode

Open stevemolloy opened this issue 1 year ago • 3 comments

Could phrase_to_file in library(pio) be extended to also accept the file mode? I would like the option to open the file in append mode.

stevemolloy avatar Jun 27 '24 09:06 stevemolloy

I think it's possible to add this, though could you please first expand on the intended use case? There may be a better solution for it that uses only existing constructs.

triska avatar Jun 27 '24 17:06 triska

Hi triska. My use case is as follows. I am parsing a json file into a number of prolog predicates, and I would like to write these to file. It would be simpler to append each of these as they are encountered, rather than having to build the entire character string and save that to file.

stevemolloy avatar Jun 29 '24 16:06 stevemolloy

As one way to implement this with the current facilities, you can collect all predicates into a list (for instance, with findall/3), and describe the list of characters corresponding to that list.

triska avatar Jun 29 '24 17:06 triska