Skip to content

Instantly share code, notes, and snippets.

@georgeoftown
Created May 5, 2019 16:41
Show Gist options
  • Save georgeoftown/86d4e1969610b3b7529386cb6c6711df to your computer and use it in GitHub Desktop.
Save georgeoftown/86d4e1969610b3b7529386cb6c6711df to your computer and use it in GitHub Desktop.
count number of yes
ask1('A menudo me disgusto por haber gastado el dinero tontamente.').
ask2('Cuando me siento triste o deprimido, suelo comprar cosas para animarme.').
ask3('Las personas que me conocen creen que gasto demasiado.').
ask4('Llevo control de mis gastos.').
ask5('Muchas veces me arrepiento de las compras que hago.').
ask6('Me gusta mucho entrar en las tiendas, aunque sólo sea a mirar.').
ask7('Muchas veces hago compras por impulso.').
ask8('Cuando veo en una tienda algo que me gusta, no me lo quito de la cabeza hasta que lo compro.').
is_yes(X, Y, Counter) :- Y is 0 , (X == yes, Counter is Y + 1 ) ; (X == no,
Counter is Y).
get_answers(Counter) :-
ask1(C), write(C), read(Ask1),
ask2(C), write(C), read(Ask2),
ask3(C), write(C), read(Ask3),
ask4(C), write(C), read(Ask4),
ask5(C), write(C), read(Ask5),
ask6(C), write(C), read(Ask6),
ask7(C), write(C), read(Ask7),
ask8(C), write(C), read(Ask8),
is_yes(Ask1, Y, Counter1), is_yes(Ask2, Y, Counter2),
is_yes(Ask3, Y, Counter3), is_yes(Ask4, Y, Counter4),
is_yes(Ask5, Y, Counter5), is_yes(Ask6, Y, Counter6),
is_yes(Ask7, Y, Counter7), is_yes(Ask8, Y, Counter8),
Counter is Counter1 + Counter2 + Counter3 + Counter4 + Counter5 + Counter6 + Counter7 + Counter8 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment