[plt-scheme] structure consist of list.

From: John Clements (clements at brinckerhoff.org)
Date: Tue Nov 24 22:54:04 EST 2009

On Nov 23, 2009, at 5:58 AM, Mona wrote:

> Hi everybody
> I have one question about define struct that consist of list.
>
> (define-struct trading-card (card-number name role))
> ;trading-card is a structure (make-trading-card c-n n r)
> ;where c-n is number and n , r are string.
>
> ;Example
> (define trading-card1(make-trading-card 1 'PEZZE 'FULL))
> (define trading-card2(make-trading-card 7 'LANZA 'ASSOCIATE))
> (define trading-card3(make-trading-card 16 'POZZI 'ASSISTNT))
>
>
> (define-struct pack (tradinging-card))
> ;pack is a structure (make-pack t-c)
> ;where t-c is a list of trading-card.
>
> (define pack1(make-pack (list trading-card1 trading-card2 trading-
> card3)))
>
>
> I want to say  get the structure of the pack (that consist of the
> list) and if trading-card-card-number < 5 return true but I dont know
> how to do in SCheme?
>
> (make-pack
> (list
>  (make-trading-card 1 'PEZZE 'FULL)
>  (make-trading-card 7 'LANZA 'ASSOCIATE)
>  (make-trading-card 16 'POZZI 'ASSISTNT)))
>

Nice examples!

Unfortunately, you're missing the one example that would help figure  
out what it is that you want.  In particular, are you trying to  
determine whether the *first* card in the deck has a number less than  
five, or whether *all* of the cards have numbers less than five, or  
whether *any* of the cards have a number less than five, or...?

Put differently: it looks like you're following the design recipe:  
keep following it!

John Clements



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20091124/302557ae/attachment.p7s>

Posted on the users mailing list.