I have a simple failure based loop that backtracks over all solutions of a predicate. The loop is part of an export routine with a header and the failure based loop exporting a table one row at a time.
I’d like to use DCG instead, but can’t figure out how to “advance” backtracked solution in DCG …
I am not sure how forall could be used in combination with DCG …
Also, I rather want to avoid loading all solutions into memory just to get it to work with DCG
One idea i had was to look at lazy lists to turn a fact look up into a lazy list, in the hope that every new get_line(Line) would retrieve a next fact from a lazy list … not sure if this can be done.
I think your scenario description is missing some pieces. Such as:
What’s the data source? A text file?
Why are you ending up with facts, to iterate through?
If your input is a text file, then presumably you want to write a DCG to parse the lines in that, and which also outputs the processed line, before moving on to the next line.