Re: Deck of Cards Question...
- Posted by Derek Parnell <derekp at solace.com.au> Nov 20, 2000
- 393 views
I like OOP so I'd tend towards that, but the second suggestion,... shuffled_deck = shuffle(deck) is okay too. Global variables, like GOTO, can easily be misused and cause weird bugs. Its a bit unfortunate that Euphoria encourages them, but until namespace and forward referencing issues are finalized, we have to live with this little "devil". Also, the function method makes it easier to implement non-standard decks (short or enlarged ones, for example.). shuffled_deck = shuffle(deck & deck) shuffled_deck = shuffle(deck[Spade04 .. SpadeAce] & deck[Club04 .. ClubAce]) ----- cheers, Derek Parnell >When "using a deck of cards," what's the best way to manipulate the deck? >For instance, is it best to let the functions operate on a global deck? > > shuffle(deck) > >I would think not... > >Should the deck sequence be passed to the function, then have the function >return the new deck? > > deck = shuffle(deck) > >I don't mind this approach. > >Should I go OOP? > > deck.shuffle