Talk:Palindrome detection: Difference between revisions

Line 53:
:I don't think this solution is very good anyway because it uses a list of characters rather than a string. I'd rather see one using string library functions. --[[User:Mwn3d|Mwn3d]] 15:54, 10 February 2009 (UTC)
The functions you used for strings are in SWI Prolog, but not in GNU Prolog, so I can't test it, but the "logic" seems logical to me:D --[[User:ShinTakezou|ShinTakezou]] 21:26, 10 February 2009 (UTC)
 
Reading here and there I've realized that what we call String in Prolog could be simply called atom, and it exists atom_length/2 and atom_concat/3; but using these instead of string_* in your code gives errors; atom_concat(A1,A2,A3) is true if A3 (unbound atom) is the concatenation of A1 and A2 (bound atoms, i.e. known atoms?).
 
The code compiles (with gplc, the GNU prolog compiler), but when I try pali('atom'), it says
 
<pre>uncaught exception: error(instantiation_error,atom_concat/3)</pre>
 
I still have to understand the debug part...; by guessing, I've thought the problem is that when trying the first atom_concat, the unbound atoms are three: X, Mid, and Str2; then I've tried to swap the two atom_concat, since at least the second "knows" Str, then bounds the other two and it makes sense for the second atom_concat the use of X and Str2... Done so, pali('hello') said "no"... but pali('aabbaa') asks True? meaning it can't determine if it is true or false... still needing work... Of course (?) pali('a') says yes because of the second rule. --[[User:ShinTakezou|ShinTakezou]] 22:02, 10 February 2009 (UTC)