Skip to main content
Pergunta reaberta por Marconcilio Souza, ramaral, Taisbevalle, Maniero
título editado
Link

Prolog recurrence problem Problema de recorrencia prolog

adicionou 60 caracteres ao conteúdo
Fonte Link

How do I solve thisComo resolver isto? I'm trying to makeEu estou a programm that recievestentar fazer um programa que receba um caminho e traduz em direcoes a list of coordenatesseguir (a path) and translates it to directions cima(Im trying to do it with recursion0), the neighbor clause unifies D with the direction needed , examples: test([ direita(5, 590),  esquerda(5, 6270),  baixo(6, 6180), (6, 7),. O predicado vizinha da a Dir uma das direcoes(7, 7)],L). would give L=[0,90,0,90], but i get L=[0]. The trace is in the image.The trace

These are my predicates90, my neighbors predicate is without problem.

´test([(,)]180,_270).

test([A|P]  ,List) exemplo:- B=(,), append([B],_,P),
neighbor(A,B,Dir), append(List,[Dir],List1), test(P test([ (5, 5), (5, 6), (6, 6), (6, 7), (7, 7)],L). devia dar L=[0,90,0,90],List1) mas da L=[0]. Fiz trace e esta ai o link da imagem O trace

test([(_,_)],_).

test([A|P],List):-
    B=(_,_),
    append([B],_,P),     
    vizinha(A,B,Dir), 
    append(List,[Dir],List1), 
    test(P,List1).

How do I solve this? I'm trying to make a programm that recieves a list of coordenates (a path) and translates it to directions (Im trying to do it with recursion), the neighbor clause unifies D with the direction needed , examples: test([ (5, 5),  (5, 6),  (6, 6), (6, 7), (7, 7)],L). would give L=[0,90,0,90], but i get L=[0]. The trace is in the image.The trace

These are my predicates, my neighbors predicate is without problem.

´test([(,)],_).

test([A|P],List):- B=(,), append([B],_,P),
neighbor(A,B,Dir), append(List,[Dir],List1), test(P,List1).

Como resolver isto? Eu estou a tentar fazer um programa que receba um caminho e traduz em direcoes a seguir (cima(0),direita(90),esquerda(270),baixo(180)). O predicado vizinha da a Dir uma das direcoes(0,90,180,270)  , exemplo: test([ (5, 5), (5, 6), (6, 6), (6, 7), (7, 7)],L). devia dar L=[0,90,0,90], mas da L=[0]. Fiz trace e esta ai o link da imagem O trace

test([(_,_)],_).

test([A|P],List):-
    B=(_,_),
    append([B],_,P),     
    vizinha(A,B,Dir), 
    append(List,[Dir],List1), 
    test(P,List1).
Pergunta fechada como "Não é adequada para este site" por Maniero
Fonte Link

Prolog recurrence problem

How do I solve this? I'm trying to make a programm that recieves a list of coordenates (a path) and translates it to directions (Im trying to do it with recursion), the neighbor clause unifies D with the direction needed , examples: test([ (5, 5), (5, 6), (6, 6), (6, 7), (7, 7)],L). would give L=[0,90,0,90], but i get L=[0]. The trace is in the image.The trace

These are my predicates, my neighbors predicate is without problem.

´test([(,)],_).

test([A|P],List):- B=(,), append([B],_,P),
neighbor(A,B,Dir), append(List,[Dir],List1), test(P,List1).