bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange: listing of Character values instead of the characters thems


From: Daniel Diaz
Subject: Re: Strange: listing of Character values instead of the characters themselves
Date: Thu, 27 Jan 2011 19:53:36 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

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).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]