How to make a variable appear in the write function in prolog

0

I'm doing a program that features several dogs, and I want to do it in a way that is faster to write down the characteristics of the dogs. For example, the following code

raca(pitbull).
raca(shiba).
raca(boxer).
raca(poodle).
raca(bullte_terrier).
sexo(macho).
sexo(femea).

cor(castanho).
cor(preto).
cor(branco).
cor(tricolor).
cor(pintado).
cor(malhado).

pelo(longo).
pelo(curto).

peso(15kg).




print(X):-
    write(X).

cao(trovao):-
    sexo(macho),
    raca(pitbull),
    cor(marrom),
    pelo(curto),
    write('raca: '),nl,
    write('nascimento: 1999'),nl,
    write('cor: marrom'),nl
    write('pelo: curto').

What I want is a way of not writing I can print the variable that is storing the information. Example

X = cor(marrom),

write(cor: X).

and there it would be printed in the terminal "color: brown", but it is not working, I do not know how to put the variable in write. Can you help me?

    
asked by anonymous 23.04.2018 / 00:18

1 answer

0

Hello,

Perhaps a simpler program will help you understand what to do. The program below writes the name of a person's parent:

homem(joao).
homem(jose).

mulher(maria).

pai(joao, jose).
pai(joao, maria).

imprime_pai(X):- homem(Y), pai(Y,X), write('o pai de '), write(X), write(' é '), write(Y),!.

Simply save to a file and load (with query) into Prolog. Then you can test with:

?- imprime_pai(maria).
o pai de maria é joao
true.

Or:

?- imprime_pai(jose).
o pai de jose é joao
true.
    
26.04.2018 / 17:56