Question: Scala language (functional lang.) Problem 2 [45 Points). The following set of problems is about shuffling of cards, particularly something called the Faro shuffle, where
Scala language (functional lang.)

Problem 2 [45 Points). The following set of problems is about shuffling of cards, particularly something called the Faro shuffle, where the stack is broken up into two, and then combined so that a card from one sub-stack is followed by one from the other, and so on. A perfect Faro shuffle breaks up the stack into two sub-stacks of exactly the same size, and then combines them in the manner described above. An out-shuffle results in the top and the bottom cards of the stack remaining the same after the shuffle; an in-shuffle results in these cards becoming the second and the second last cards of the shuffled stack. [Note: Do not use built-in higher-order functions for this problem] (a) [10 Points). Write a polymorphic function, shuffle, which takes two lists 11 and 12 representing decks of cards, and returns the result of a combining of the lists. Particularly, the returned list contains the first element of 11, followed by the first element of 12, followed by the second element of I1, and so on. If one of the lists ends before the other, the other list's remaining elements are simply added to the end. Problem 2 [45 Points). The following set of problems is about shuffling of cards, particularly something called the Faro shuffle, where the stack is broken up into two, and then combined so that a card from one sub-stack is followed by one from the other, and so on. A perfect Faro shuffle breaks up the stack into two sub-stacks of exactly the same size, and then combines them in the manner described above. An out-shuffle results in the top and the bottom cards of the stack remaining the same after the shuffle; an in-shuffle results in these cards becoming the second and the second last cards of the shuffled stack. [Note: Do not use built-in higher-order functions for this problem] (a) [10 Points). Write a polymorphic function, shuffle, which takes two lists 11 and 12 representing decks of cards, and returns the result of a combining of the lists. Particularly, the returned list contains the first element of 11, followed by the first element of 12, followed by the second element of I1, and so on. If one of the lists ends before the other, the other list's remaining elements are simply added to the end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
