Question: Code in Lisp programing language please Assume you are starting to work on a card game. Set the value of the global variable *standard-suits* to
Code in Lisp programing language please
Assume you are starting to work on a card game.
- Set the value of the global variable *standard-suits* to '(hearts diamonds clubs spades) and the global variable *standard-values* to '(ace king queen jack 10 9 8 7 6 5 4 3 2).
- Create a recursive function, MAKE-DECK, which takes two arguments, a list of suits and a list of values and creates a full deck from these (i.e., ((ace hearts) (king hearts) ...), and assigns it to the global variable *deck*. (Note: It's generally preferred to minimize the use of global variables to avoid unintended consequences, but this exercise uses them for demonstration purposes.)
- Create a recursive function, SHUFFLE, which takes a deck (as created above) as an argument and shuffles it by randomly selecting a card from the deck and building up a new deck (which it will return). You may want to use RANDOM, NTH (or ELT), and LENGTH.
"Cards" ((unless (boundp '*suits*) (setf *suits* '(hearts diamonds clubs spades)))) ((unless (boundp '*values*) (setf *values* '(ace king queen jack 10 9 8 7 6 5 4 3 2)))) ((make-deck *suits* *values*) (and (boundp '*deck*) (equal 52 (length *deck*)))) ((shuffle *deck*) (equal 52 (length *))))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
