Re: Strange: listing of Character values instead of the characters themselves
Daniel Diaz <[email protected]> Thu, 27 Jan 2011 19:53:36 +0100
| Newsgroups | gmane.comp.gnu.prolog.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hello,
In GNU-Prolog a string is a simple notation of a list of character codes
(as in most Prolog implementations).
You should use atoms instead of string. For instance replace your
example/1 fact by:
example(['Peter','Diva','Ex','Newt','Xtra']).
And everything is OK. Alternatively you can use format('~s',[ "my
string" ]) to display a string (but you have to do it for each element
of the list Perm).
Daniel
Le 24/01/2011 14:36, Peter Karlsson a écrit :
> %
> % Testing permute& select
> %
>
> test :- example(Ex), permutation(Ex, Perm),
> write(Perm), nl, fail.
> test :- true.
>
> example(["Peter","Diva","Ex","Newt","Xtra"]).
>
>
> % Permutation& Select
>
> %permutation(Xs, [Z|Zs]) :- select(Z, Xs, Ys), %permutation(Ys, Zs).
> %permutation([],[]).
>
> %select(X, [X|Xs], Xs).
> %select(X, [Y|Ys], [Y|Zs]) :- select(X, Ys, Zs).
>
>