Skip to content
Discussion options

You must be logged in to vote

Whenever you want to process large files start with small ones. So small, that their content fits conveniently into a single line. For this, just use phrase/2 alone:

?- phrase(log_file(0,N),"1\n2\n3\n").
   N = 3
;  N = 2, unexpected
;  N = 2, unexpected
;  N = 1, unexpected
;  false. % leftover choicepoint

So your non-terminal log_file//2 is ambiguous. Not only does it determine the number of newlines in a string but also all numbers smaller than this number.

In your definition you used the non-terminal ... //0 which means any sequence, starting with the empty sequence and including also sequences with newlines. You need to reformulate your query such that you get exactly one solution a…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@david-sitsky
Comment options

@UWN
Comment options

@UWN
Comment options

@UWN
Comment options

Answer selected by david-sitsky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants