2

answers

0

watching

347

views

17 Jan 2018

# 5. 110 marks] Consider the card structure definition. (define-struct card (value suit)) ii Acara is a structure (make-card v s), where ji v is an integer in the range from 1 to 10 and iis is a symbo. for suit, from the set 'hearts, ii 'diamonds, 'spades, and 'clubs. a) [2 marks] Define a constant called four-of-hearts corresponding to the card with suit 'hearts and value 4. Consider the Scheme function merge-cards which consumes two card structures (cl and c2) and produces a new card, according to the following rules: . If the suits of the two cards are the same, the new card has that suit and its value is the sum of the values of cl and c2, up to a maximum value of 10 • Otherwise, the new card has the value of cl and the suit of c2. b) 12 marks Write the contract of merce-cards (the function header is given below). c) 12 marks Write a single example for merge-cards. d) 16 marks Complete the body of the function merge-cards. (define (mergo-cards c! 02)

5. 110 marks] Consider the card structure definition. (define-struct card (value suit)) ii Acara is a structure (make-card v s), where ji v is an integer in the range from 1 to 10 and iis is a symbo. for suit, from the set 'hearts, ii 'diamonds, 'spades, and 'clubs. a) [2 marks] Define a constant called four-of-hearts corresponding to the card with suit 'hearts and value 4. Consider the Scheme function merge-cards which consumes two card structures (cl and c2) and produces a new card, according to the following rules: . If the suits of the two cards are the same, the new card has that suit and its value is the sum of the values of cl and c2, up to a maximum value of 10 • Otherwise, the new card has the value of cl and the suit of c2. b) 12 marks Write the contract of merce-cards (the function header is given below). c) 12 marks Write a single example for merge-cards. d) 16 marks Complete the body of the function merge-cards. (define (mergo-cards c! 02)

poptropicaLv2

29 Nov 2021

Patrina SchowalterLv2

19 Jan 2018

Already have an account? Log in