-
I recently found myself writing some Prolog code like this: max_string_nonrepeatsubstring(Max, String, MaxSub) :-
findall(Substring, string_nonrepeatsubstring(String, Substring), Substrings),
maxlength(Substrings, MaxSub, Max). It did the job, but it made me curious if I was approaching this procedurally by using In general, assuming eventual termination, do/should aggregations be reified as I have done here or should they be tabulated cumulatively somehow? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Ideally, such code would be written in the pure subset. And in this case I think it is feasible although quite challenging. But often this is too complex, and the quick and dirty fix is to use some 2nd order constructs to fix it. The downside is that you have now to protect such a definition against uses that could reveal its weakness. In your case it seems necessary to guarantee that Assuming you refer to this, note that there are already some problems in |
Beta Was this translation helpful? Give feedback.
Ideally, such code would be written in the pure subset. And in this case I think it is feasible although quite challenging. But often this is too complex, and the quick and dirty fix is to use some 2nd order constructs to fix it. The downside is that you have now to protect such a definition against uses that could reveal its weakness. In your case it seems necessary to guarantee that
String
is ground.Assuming you refer to this, note that there are already some problems in
is_nonrepeating/1
. Maybe concentrate first on simpler examples.