Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.)

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions