Edit: Solved it by first turning the String into a list with string_chars/2. Still not sure why that was needed. I thought strings were already char lists in prologs mind.
Not the best at prolog but I have to use it for this task. I want to write a predicate that will remove characters from a string untill the string is an palindrome. I have palindrome/1, which seems to work correctly.
I've tried this:
predicate(String):-
palindrome(String).
predicate(String):-
select(_, String, NewString), % Idea: Removing a character from String will give NewString
predicate(NewString).
So something like predicate("addal")
should give true, but gives me false.
In fact, adding some break-points in the code, like writing "Reached" at different points in the program shows that the program fails at select(_, String, NewString)
Why doesn't select/3 work? The idea is to just remove a random character.
Edit: Its a palindrome, not an anagram like i said at first.