0
I’m doing a show that features several dogs, and I want to do it in a way that’s faster to write the characteristics of 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 in write I can print the variable that is saving ifnromation. Example
X = cor(marrom),
write(cor: X).
and then it would be printed in the terminal "color: brown", but it’s not working, I don’t know how to put the variable in write. Can help me?
Prolog is a functional language, different from the imperative language like most languages (C, Java, Javascript, ...). In this type of language there are no explicit variables.
– Sveen
What you want to return from the function color (brown) ? This function has no return, just like any function of Prolog. It only retouch true or false
– Sveen
= does not mean attribution, but equality (in some compilers)
– Sveen