I can not say anything: if I give Prolog reverse([], A)., it works fine, if I give it reverse(A, []).and answer it ;on the first assumption that it freezes!
reverse([], A).
reverse(A, []).
;
Why? (The same result for both GNU Prolog and SICStus Prolog!)
aioobe@r60:~$ prolog GNU Prolog 1.3.0 By Daniel Diaz Copyright (C) 1999-2007 Daniel Diaz | ?- reverse([], A). A = [] yes | ?- reverse(A, []). A = [] ? ; Fatal Error: global Qaru (size: 32768 Kb, environment variable used: GLOBALSZ) aioobe@r60:~$
Looks like over optimization for the inline predicate for me. The same problem occurs regardless of the contents of the list in the second argument. Based on the GProlog manual, this is a mistake. Please note that the pattern forreverse -
reverse
reverse(?list, ?list)
And further, which ?means that an argument can be created or a variable.
?
SWI-Prolog version 5.6.64 gives the expected result.
?- reverse([], A). A = []. ?- reverse(A, []). A = [] ; false.
, , 1 (.. (+,)), ), , . :
reverse(L, R) :- reverse_1(L, [], R). reverse_1([], X, X). % <-- doesn't loop on unbound arg #1 if this clause cuts reverse_1([A|As], X, R) :- reverse_1(As, [A|X], R).
Source: https://habr.com/ru/post/1764157/More articles:How to extract words in braces using regular expressions? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1764153/ways-to-offer-app-as-free-and-still-charge-users-to-pay-for-the-serviceusage&usg=ALkJrhh9V6HlsBGYZdaoq-IJd2gAVt-QXwJQuery swap plugin that works with an odd page structure - javascripttrying to install MySQL-python-1.2.3, but I get an error message - pythonMagento email address? - emailCannot Find JavaScript Syntax Error - javascriptJavaScript history.back () shareware - javascripthow to set namespace prefix to attribute value using lxml? - pythonEmpty login ID after using GetMessageFromMsgFile in Outlook Redemption - delphiSSIS 2005 and 2008 packages are edited using which versions of Visual Studio? - visual-studio-2010All Articles