I have following program:
filter([],_What,[]).
filter(List,What,Output):-
not(select(What-Val,List,Rest)),
filter([],What,Output).
filter(List,What,[Val|Output]):-
select(What-Val,List,Rest),
filter(Rest,What,Output).
I don't understand why following query:
filter([age-90, age-80,age-80],age,Output).
outputs:
Output = "ZPP"
I have latest version of SWI-prolog ( 7.4.2 ), and have mac with El Captain (10.11.6).
I have tried guitracer, and it builds list [90,80,80] but outputs "ZPP" I have no idea why it does that.
SWISH online prolog outputs [90,80,80], so it must be something with SWI-Prolog.
EDIT
It seems that it converts number into characters 90=Z, 80=P, etc...
Why does it do this?
"ZPP"represents the "string" (list) of codes forZ,P, andP. So they're equivalent. Not sure what mode you have your SWI Prolog set to that causes it to default do displaying[90, 80, 80]as a string. Perhaps more importantly, you have at least two singleton variables and your query doesn't terminate (infinitely generates the solutionOutput = [90, 80, 80]). - lurker