user input , user inputs data into the list

75 Views Asked by At

I have a eval solution , that the user need to input the names of the people and give a certain value , i am trying to make it work but the input part is not working.

preferencia(ana,joana,1).
preferencia(ana,rui,-1).
preferencia(ana,maria,1).
preferencia(ana,jose,-1).
preferencia(ana,tiago,-1).
preferencia(ana,andre,1).
preferencia(joana,rui,2).
preferencia(joana,maria,1.5).
preferencia(joana,jose,-1).
preferencia(joana,tiago,1).
preferencia(joana,andre,-1).
preferencia(rui,maria,1).
preferencia(rui,jose,-1).
preferencia(rui,tiago,1).
preferencia(rui,andre,1).
preferencia(maria,jose,-1).
preferencia(maria,tiago,1).
preferencia(maria,andre,-1).
preferencia(jose,tiago,1).
preferencia(jose,andre,1).
preferencia(tiago,andre,-1).
preferencia(X,Y,D):-preferencia(Y,X,D),!. % reverse preferenciaance



% representation: S is a list of persons


% evaluation function:
eval([_],0).
eval([Name1,Name2|R],DS):- 
    preferencia(Name1,Name2,D),
    eval([Name2|R],DR),
    DS is D+DR.

start :- write('Pick 2 Person to make a group '), read(X), eval([X,X|R],DS).

i want the user to input 2 names via console , so i want is the console working like this , "Pick 2 Person to make a group" the user inputs the (ex. rui , maria) , and return the value of their preference. If i input eval([rui,mariaR],DS) it returns the value 1 , but this in only in static way , i want the user being able to select 2 names and return their preference level. I believe the main error is the start function , thanks

0

There are 0 best solutions below