1
votes

it is possible make something like this?

--- knowledge base ---

linha( 5,[bobigny_pablo_picasso,bobigny_pantin_raymon_queneau,eglise_de_pantin,hoche,
          porte_de_pantin,ourcq,laumiere,jaures,stalingrad,gare_du_nord,gare_de_l_est,
          jacques_bonsergent,republique,oberkampf,richard_lenoir,breguet_sabin,bastille,
          quai_de_la_rapee, gare_dausterlitz,saint_marcel,campo_formio,place_ditalie],
         [10,2]).

route(71,[louis_blanc,jaures,bolivar,buttes_chaumont,botzaris,place_des_fetes,
          pre_saint_gervais],
         [10,2]).

--- knowledge base end ---

sameRoute(EI,NF):-
    findall(Y,findall(Z,member(EI,route(Y,Z,_)),NumRout),NumRouteF),
    append(NumRout,NumRouteF,NF).

EI is a station, and NF its supposed to return the number in the route the first parameter of the predicate route.

What am I doing wrong?

1
Can you explain exactly what you want to achieve? It's not clear from your code as it has a lot of problems. What relation should the predicate sameRoute/2 describe between EI and NF? - Tudor Berariu
i have a lot of routes, with route have a number, like abouve, route(7,[LIST of stations],[Frequenci time]), what i what is a list, and that list need to have all number of routes, for a particular station. - user3161343
This expression is a problem: member(EI,route(Y,Z,_),NumRout). member/2 expects two arguments: an element and a list. It's true if the element is a member of the list. - lurker
I had already corrected this problem, but the answer that now gives me is this: L = [_G626] if i try, sameRoute(jaures,L). and its suppose to give me : L = [5,71] - user3161343
member(EI, route(Y,Z,_)) is still not valid since route(Y,Z,_) isn't a list. - lurker

1 Answers

1
votes

From the comments it seems you need all the routes that pass through a given station S.

findall(R, (route(R, Stations, _), member(S, Stations)), Routes).

The goal is a conjunction of two conditions: that R is the number of some route that goes through the list of stations Stations and that the given station S is a member of that list.

?- S = louis_blanc, findall(R, (route(R, Stations, _), member(S, Stations)), Routes).
S = louis_blanc,
Routes = [7, 71].