I am trying to solve a problem (description). Kattio is the custom reader for prolog. I am reading in a word that comes in unicode characters, that is, a list of numbers.
I permute the list, split it in two and get prolog to find all the possible palindroms over List1. I need the length of the list that is not used to write the palindrom, that is to say List2. The length of List2 is N.
But when I try to append all the N to a new list of Ns, I get an error because the list is not instantiated. I tried to write it before in main, make a custom append, but nothing works so far.
[kattio]. main :- % reading input read_atom(X), (X == end_of_file ; atom_codes(X, X2), % solving for X2 because it needs conversion, receiving N everytime a solution is found, % trying to add this N to a list of Ns. % to do next is to find the smallest element of the list Ns, that is the solution to the problem solve(X2,N), write(N), append(Ns, N), fail ). % make all possible permutations, split in 2 lists such as List1 is a palindrom, and return the % length of the list of the letters not used in the solution solve(Y,N):- permutation(Y,X), append(List1,List2, X), is_palindrome(List1), writeln(List1), writeln(List2), length(List2,N). is_palindrome(L) :- reverse(L,L).
I get the error:
ERROR: -g main: Arguments are not sufficiently instantiated ERROR: In: ERROR:  throw(error(instantiation_error,_1210))
So I understand that I need to instantiate the list Ns before I use it, but I cannot find a way. I would be very grateful for any help!