Separando lista de fatos no prólogo
Oct 30 2020
Tenho uma lista de fatos no Prolog. Dizer:
L = [mother(sue), father(sam), mother(rachel), mother(izzie), father(leo)]
Eu quero separá-los em duas listas
L1 = [mother(sue), mother(rachel), mother(izzie)]
L2 = [father(sam), father(leo)]
Como faço isso no Prolog
Respostas
2 ChristianFritz Oct 30 2020 at 06:35
Espero não estar fazendo sua lição de casa para você, mas aqui está:
split([], [], []).
split([mother(X)|L], [mother(X)|L1], L2) :- split(L, L1, L2).
split([father(X)|L], L1, [father(X)|L2]) :- split(L, L1, L2).
Uso:
?- split([mother(sue), father(sam), mother(rachel), mother(izzie), father(leo)], L1, L2).
L1 = [mother(sue), mother(rachel), mother(izzie)],
L2 = [father(sam), father(leo)]
O que significa um erro “Não é possível encontrar o símbolo” ou “Não é possível resolver o símbolo”?
Christopher Nolan uma vez se arrependeu de ter lido o 'roteiro de Pulp Fiction' de Quentin Tarantino