Subject: List

From: "Justice, Randy -CONT" <[email-masked]>
Date: Fri, 1 Sep 2000 13:17:13 -0500

How would like to give me a hand and teach me something?

I have the following setup.
/*  
     Face,
     Rank
*/
card(a,  1).
card(2,  2). 
card(3,  3).
card(4,  4). 
card(5,  5).
card(6,  6). 
card(7,  7).
card(8,  8). 
card(9,  9).
card(10, 10).
card(j,  11). 
card(q,  12).
card(k,  13). 

/* Card name,
   stack */   
    
topcard(2, 1).
topcard(8, 2).
topcard(5, 3).
topcard(9, 4).
topcard(2, 5).
topcard(10, 6).
topcard(3, 7).
topcard(j, 8).
topcard(5, 9).
topcard(3, 10).
topcard(q, 11).
topcard(4, 12).

/* Test where two cards equals 14. */

is_fourteen(ICard1, ICard2):- 
   card(ICard1,ICard1_Value), 
   !,    
   card(ICard2,ICard2_Value),
   !,
   14 =:= ICard1_Value + ICard2_Value.

/* Returns a list of cards that equals 14. */
 
check_fourteen(Card1,Card2,StackCard1,StackCard2):-
    topcard(Card1,StackCard1),
    topcard(Card2,StackCard2),
    is_fourteen(Card1,Card2).

When I run this I get dups.
?- check_fourteen(A,B,C,D).

A = 2
B = q
C = 1
D = 11 ;

A = 5
B = 9
C = 3
D = 4 ;

A = 9
B = 5
C = 4
D = 3 

I want a list of cards that equls fourteen (14). Where (5,9,3,4){ Stack 3
contains card 5, Stack 4 contains card 9 } are (9,5,4,3){ Stack 4 contains
card 9, Stack 3 contains card 5 }the same and only one should be displayed. 

Thanks for any help
Randy