prolog predicates



This should be an easy question. I'm writing this predicate:

high_card(Hand, Card) is true iff
Hand is a list of length > 0 containing any
of the terms: ace, king, queen, jack,
and Card is the term in Hand that has the
highest value (ace > king > queen > jack).
Test cases:
?- high_card([ace], C).
C=ace.
?- high_card([ace, jack, jack], C).
C=ace.
?- high_card([queen, jack, king, jack], C).
C=king.
?- high_card([jack, queen], C).
C=queen.

I've got this so far:

high_card([],C):-
C=none.

high_card([ace|Y],C):-
C=ace.

high_card([X|ace],C):-
C=ace.


With this I'm not sure how to check for the end of the list for an ace
and if one exists set C to = ace but if not then C = king:

high_card([king|Y],C):-
high_card(Y,D),
C=king.

Any help is greatly appriciated.

.



Relevant Pages

  • Re: prolog predicates
    ... > and Card is the term in Hand that has the ... > ?- high_card([ace, jack, jack], C). ... > ?- high_card([queen, jack, king, jack], C). ... > With this I'm not sure how to check for the end of the list for an ace ...
    (comp.lang.prolog)
  • Re: Simple combinatoric problem
    ... is adjacent to a king? ... You want the probability that at least one ace is adjacent to at least ... card is an ace, and Rthe probability given that the top card is a ... Then add back in all the ways 3 adjacency events can take place, ...
    (sci.math)
  • Re: Simple combinatoric problem
    ... is adjacent to a king? ... You want the probability that at least one ace is adjacent to at least ... card is an ace, and Rthe probability given that the top card is a ...
    (sci.math)
  • Re: Texas Holdem Plus
    ... seems an ace with a bad, unsuited kicker would justify it in late ... extra card more often than it is justified. ... King or Queen ...
    (rec.gambling.poker)
  • Re: Understanding Quantum Entanglement
    ... there's a song called the Quantum Entanglement Tango on page six ... :say the ace of spades and the king of hearts. ... :the king, but you don't know which one is which until you look. ... :you look at one, you immediately know which card the other one is, and ...
    (rec.arts.sf.science)