logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Sabir AhmadFinance
(5/5)

913 Answers

Hire Me
expert
Vijendra Kumar yadavMathematics
(/5)

865 Answers

Hire Me
expert
Martin BlumbergFinance
(5/5)

670 Answers

Hire Me
expert
David AvitiaManagement
(5/5)

881 Answers

Hire Me
Computer Science

Reimplement the programs below in the CPS style Convert helloUp, doubleUp and mainFun into the CPS functions helloUp_k , doubleUp_k , mainFun_k .

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Name: WRITE YOUR NAME HERE
1 / TEST HELPER
2 def passed(points: Int) {
3 require(points >=0)
4 if (points == 1) print(s"\n*** Tests Passed (1 point) ***\n")
5 else print(s"\n*** Tests Passed ($points points) ***\n") 6 }


Problem 1 (20 points): CPS Style Transformation
Reimplement the programs below in the CPS style.

A (10 points)
Convert helloUp, doubleUp and mainFun into the CPS functions helloUp_k , doubleUp_k , mainFun_k . They should take continuations that are of type String => String .

def helloUp(x: String): String = { "Hello " + x
}

def doubleUp(x: String): String = { x + x
}

def mainFun(x: String): String = { doubleUp(helloUp(x) + "World")
}

1 ??? // YOUR CODE HERE

I
1 //BEGIN TEST
2 assert(helloUp_k("World", x => x) == "HelloWorld", "Test 1, Set  1
3 assert(doubleUp_k("World", x => x) == "WorldWorld", "Test 2 Set  1
4 assert(mainFun_k("Donkey", x => x) == "HelloDonkeyWorldHelloDonke
5 passed(5)
6 //END TEST


1 //BEGIN TEST
2 assert(helloUp_k("Hello", x => ("*"+x+"*")) == "*HelloHello*", "T
3 assert(doubleUp_k("HelloWorld", x => ("*"+x+"*")) == "*HelloWorld
4 assert(mainFun_k("Cruel", x => ("*"+x+"*")) == "*HelloCruelWorldH
5 passed(5)
6 //END TEST

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme