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

... / 2 appears to run in O(N) when it could run in O(1)

Open stefan-kral opened this issue 2 years ago • 4 comments

?- use_module(library(iso_ext)), use_module(library(pio)), use_module(library(dcgs)), use_module(library(time)).
   true.
?- time(countall(phrase_from_file((...,[_],...),'scryer-prolog.wxs'),N)).
   % CPU time: 1.056s
   N = 2065.

I seems to me that ... / 2 does not yet quite exploit the properties of the internal partial string representation.

stefan-kral avatar Nov 11 '23 16:11 stefan-kral

As long as #1714 is open,...

But at least you could consider '$max_skip_list'/3 for this purpose (of the last ... //0)

UWN avatar Nov 11 '23 18:11 UWN

As long as #1714 is open,...

What happens as long as #1714 is open?

But at least you could consider '$max_skip_list'/3 for this purpose (of the last ... //0)

That's up to the implementer of library(dcgs), not to a simple user of Scryer Prolog, wouldn't you agree?

stefan-kral avatar Nov 12 '23 10:11 stefan-kral

As long as #1714 is open,...

What happens as long as #1714 is open?

... there is some space overhead just for reading a partial string with Prolog clauses. Any further consideration is moot.

UWN avatar Nov 12 '23 11:11 UWN

Right.

Still, properly using '$max_skip_list'/3 in the implementation of ... /2 in library(dcgs) would not hurt though...

stefan-kral avatar Nov 12 '23 15:11 stefan-kral