Earn Higher Grades With Instant Assignment Help.Ask Question!

Computer Science
(5/5)

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

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

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. The LineItem class will represent an individual

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

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
871 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
969 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
605 Answers Hire Me