MP 4 – Continuation-Passing Style
CS 421 – Fall 2012
Revision 1.0
Assigned September 17, 2013
Due September 24, 2013 21:59
Extension 48 hours (20% penalty)
1 Change Log
1.0 Initial Release.
2 Objectives and Background
The purpose of this MP is to help the student learn the basics of continuation-passing style, or CPS, and CPS transfor-
mation. Next week, you will be using your knowledge learned from this MP to construct a general-purpose algorithm
for transforming code in direct style into continuation-passing style.
3 Instructions
The problems below are all similar to the problems in MP2 and MP3. The difference is that you must implement each
of these function in continuation-passing style. In some cases, you must first write a function in direct style (according
to the problem specification), then transform the function definition into continuation-passing style.
The problems below have sample executions that suggest how to write answers. Students have to use the same
function name, but the name of the parameters that follow the function name need not be duplicated. That is, the
students are free to choose different names for the arguments to the functions from the ones given in the example
execution. We also will use let rec to begin the definition of some of the functions that are allowed to use recursion.
You are not required to start your code with let rec. Similarly, if you are not prohibited from using explicit
recursion in a given problem, you may change any function definition from starting with just let to starting with let
rec.
For all these problems, you are allowed to write your own auxiliary functions, either internally to the function
being defined or externally as separate functions. All such helper functions must satisfy any coding restrictions (such
as being in tail recursive form, or not using explicit recursion) as the main function being defined for the problem must
satisfy.
Here is a list of the strict requirements for the assignment.
• The function name must be the same as the one provided.
• The type of parameters must be the same as the parameters shown in sample execution.
• Students must comply with any special restrictions for each problem. For several of the problems, you will be
required to write a function in direct style, possibly with some restrictions, as you would have in MP2 or MP3,
and then transform the code you wrote in continuation-passing style.
1
4 Problems
These exercises are designed to give you a feel for continuation-passing style. A function that is written in continuation-
passing style does not return once it has finished computing. Instead, it calls another function (the continuation) with
the result of the computation. Here is a small example:
# let report x =
print_string "Result: ";
print_int x;
print_newline();;
val report : int -> unit = <fun>
# let inck i k = k (i+1)
val inck : int -> (int -> ’a) -> ’a = <fun>
The inck function takes an integer and a continuation. Aft.
The document is a report on the topic of computer programming and utilization prepared by group C. It discusses functions, including the definition of a function, function examples, benefits of functions, function prototypes, function arguments, and recursion. It provides examples of math library functions, global and local variables, and external variables. It also includes examples of recursive functions to calculate factorials and the Fibonacci series recursively.
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition pg. 25
An Introduction to
Computer Science with Java, Python and C++
Community College of Philadelphia edition
Copyright 2017 by C.W. Herbert, all rights reserved.
Last edited October 8, 28, 2019 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2019 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Chapter 5 – Python Functions and Modular Programming
Contents
Lesson 5.1User Created Functions in Python2
Python Function Parameters2
Value returning functions3
Example – Methods and Parameter Passing5
9
Lesson 5.2Top-Down Design and Modular Development10
Chapter Exercises13
User Created Functions in Python
So far we have only created software with one continuous Python script. We have used functions from other python modules, such as the square root method from the math class math.sqrt(n). Now we will begin to create our own functions of our own.
A Python function is a block of code that can be used to perform a specific task within a larger computer program. It can be called as needed from other Python software. Most programming languages have similar features, such as methods in Java or subroutines in system software.
The code for user-defined functions in Python is contained in a function definition. A Python function definition is a software unit with a header and a block of Python statements. The header starts with the keyword def followed by the name of the function, then a set parenthesis with any parameters for the function. A colon is used after the parentheses to indicate a block of code follows, just as with the if and while statements. The block of code to be included within the function is indented.
Here is an example of a Python function:
# firstFunction.py
# first demonstration of the use of a function for CSCI 111
# last edited 10/08/2o19 by C. Herbert
function
definition
def myFunction():
print ( "This line being printed by the function MyFunction.\n")
# end myFunction()
### main program ###
function used by the main part of the script
print("Beginning\n")
myFunction()
print("End\n")
# end main program
Functions can used for code that will be repeated within a program, or for modular development, in which long programs are broken into parts and the parts are developed independently. The parts can be developed as Python functions, then integrated to work together by being called from other software.
Python Function Parameters
Data can be passed to a Python function as a parameter of the function. Function parameters are variables listed in parentheses foll ...
This document discusses functions in C programming. It defines functions as blocks of code that perform specific tasks. It explains the key components of functions - function declaration, definition, and call. It provides examples of defining, declaring, and calling functions. It also discusses recursion, system-defined library functions, and user-defined functions.
This document provides a quick tour of the Python programming language. It introduces basic Python concepts like data types, variables, operators, conditional statements, loops, and functions. It explains how to get user input, perform type conversions, and work with common data types like integers, floats, strings, and booleans. It also demonstrates how to define functions, use default arguments and keyword arguments, and handle global variables. The document uses examples to illustrate concepts like arithmetic operations, string slicing, indexing, concatenation, and repetition.
This document discusses various topics related to processing and interactive input in C programming, including:
- Assignment statements and implicit/explicit type conversions
- Mathematical library functions like sqrt()
- Using scanf() for interactive input and ensuring valid user input
- Formatted output using printf() and format modifiers
- Common errors like failing to initialize variables or using incorrect data types.
The document discusses different types of storage classes in C++ that determine the lifetime and scope of variables:
1. Local variables are defined inside functions and have scope limited to that function. They are destroyed when the function exits.
2. Global variables are defined outside all functions and have scope in the entire program. They are destroyed when the program ends.
3. Static local variables are local variables that retain their value between function calls. Register variables are local variables stored in processor registers for faster access.
4. Thread local storage allows defining variables that are local to each thread and retain their values similar to static variables. The document provides examples to illustrate local, global, and static variables.
I am Samuel H. I am a Mechanical Engineering Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. Matlab, University of Alberta, Canada. I have been helping students with their homework for the past 12 years. I solve assignments related to Mechanical Engineering.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Mechanical Engineering Assignments.
The document is a report on the topic of computer programming and utilization prepared by group C. It discusses functions, including the definition of a function, function examples, benefits of functions, function prototypes, function arguments, and recursion. It provides examples of math library functions, global and local variables, and external variables. It also includes examples of recursive functions to calculate factorials and the Fibonacci series recursively.
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition pg. 25
An Introduction to
Computer Science with Java, Python and C++
Community College of Philadelphia edition
Copyright 2017 by C.W. Herbert, all rights reserved.
Last edited October 8, 28, 2019 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2019 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Chapter 5 – Python Functions and Modular Programming
Contents
Lesson 5.1User Created Functions in Python2
Python Function Parameters2
Value returning functions3
Example – Methods and Parameter Passing5
9
Lesson 5.2Top-Down Design and Modular Development10
Chapter Exercises13
User Created Functions in Python
So far we have only created software with one continuous Python script. We have used functions from other python modules, such as the square root method from the math class math.sqrt(n). Now we will begin to create our own functions of our own.
A Python function is a block of code that can be used to perform a specific task within a larger computer program. It can be called as needed from other Python software. Most programming languages have similar features, such as methods in Java or subroutines in system software.
The code for user-defined functions in Python is contained in a function definition. A Python function definition is a software unit with a header and a block of Python statements. The header starts with the keyword def followed by the name of the function, then a set parenthesis with any parameters for the function. A colon is used after the parentheses to indicate a block of code follows, just as with the if and while statements. The block of code to be included within the function is indented.
Here is an example of a Python function:
# firstFunction.py
# first demonstration of the use of a function for CSCI 111
# last edited 10/08/2o19 by C. Herbert
function
definition
def myFunction():
print ( "This line being printed by the function MyFunction.\n")
# end myFunction()
### main program ###
function used by the main part of the script
print("Beginning\n")
myFunction()
print("End\n")
# end main program
Functions can used for code that will be repeated within a program, or for modular development, in which long programs are broken into parts and the parts are developed independently. The parts can be developed as Python functions, then integrated to work together by being called from other software.
Python Function Parameters
Data can be passed to a Python function as a parameter of the function. Function parameters are variables listed in parentheses foll ...
This document discusses functions in C programming. It defines functions as blocks of code that perform specific tasks. It explains the key components of functions - function declaration, definition, and call. It provides examples of defining, declaring, and calling functions. It also discusses recursion, system-defined library functions, and user-defined functions.
This document provides a quick tour of the Python programming language. It introduces basic Python concepts like data types, variables, operators, conditional statements, loops, and functions. It explains how to get user input, perform type conversions, and work with common data types like integers, floats, strings, and booleans. It also demonstrates how to define functions, use default arguments and keyword arguments, and handle global variables. The document uses examples to illustrate concepts like arithmetic operations, string slicing, indexing, concatenation, and repetition.
This document discusses various topics related to processing and interactive input in C programming, including:
- Assignment statements and implicit/explicit type conversions
- Mathematical library functions like sqrt()
- Using scanf() for interactive input and ensuring valid user input
- Formatted output using printf() and format modifiers
- Common errors like failing to initialize variables or using incorrect data types.
The document discusses different types of storage classes in C++ that determine the lifetime and scope of variables:
1. Local variables are defined inside functions and have scope limited to that function. They are destroyed when the function exits.
2. Global variables are defined outside all functions and have scope in the entire program. They are destroyed when the program ends.
3. Static local variables are local variables that retain their value between function calls. Register variables are local variables stored in processor registers for faster access.
4. Thread local storage allows defining variables that are local to each thread and retain their values similar to static variables. The document provides examples to illustrate local, global, and static variables.
I am Samuel H. I am a Mechanical Engineering Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. Matlab, University of Alberta, Canada. I have been helping students with their homework for the past 12 years. I solve assignments related to Mechanical Engineering.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Mechanical Engineering Assignments.
The document discusses different ways that functions can handle arguments in C++, including passing by value, passing by reference, and function overloading. It provides examples to illustrate each concept. Specifically:
1) Arguments are normally passed by value by default, meaning the function receives a copy of the argument rather than the actual variable.
2) Arguments can also be passed by reference using ampersands, allowing changes to the arguments inside the function to affect the original variables.
3) Functions can be overloaded when they have the same name but different parameters, allowing different implementations based on argument types.
Complete Information till 2D arrays. In this slides you can also find information about loops and control decision....
Best slides for beginners who wants to learn about C programming language..
This document provides an overview of imperative programming and nested loops in Python. It discusses strategies for writing nested loops, including using for loops with if conditions. It also covers the range() function for iterating over sequences of numbers, user-defined functions, parameters, return statements versus print statements, multiline comments, and docstrings. The document concludes with assigning practice problems to help reinforce these concepts.
This document discusses control flow statements and loops in Python programming. It covers decision control statements like if, if-else and if-elif-else and loops like for and while loops. It provides examples of using these statements to make decisions and iterate over sequences. It also discusses concepts like break, continue and pass statements used to control program flow. The document concludes with some lab assignments involving applying control flow statements and loops to solve problems.
This document discusses arrays and functions in C++. It explains that arrays allow storing multiple values in a single variable to avoid declaring many individual variables. Arrays can store values of different data types like integers, floats, characters. Functions are blocks of code that perform a specific task and can optionally return a value. Functions make code reusable and avoid repetition. The document provides examples of one-dimensional and two-dimensional arrays, and functions with and without parameters. It also assigns practice problems of writing functions to calculate the summation of numbers from 1 to 1000, find the factorial of a given number, and calculate a number to the power of a given exponent.
02 functions, variables, basic input and output of c++Manzoor ALam
This document discusses computer programming functions, variables, and basic input/output in C and C++. It covers:
- Defining and calling functions, function parameters and return values.
- Declaring and assigning values to variables of different data types like int, float, and double.
- Using basic input/output functions like cout and cin to display output and get user input.
- The scope of variables and how they work within and outside of functions.
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
Writer Monad for logging execution of functionsPhilip Schwarz
download for better quality - Learn how to use the Writer monad to log (trace) the execution of functions through the work of Bartosz Milewski and Alvin Alexander
The document discusses C++ functions. It defines what functions are and their uses in breaking down problems into smaller tasks. There are two types of functions: standard functions that are part of the C++ language and user-defined functions. A function has a signature defining its return type and parameters. Functions are declared and defined in two steps - declaration and implementation. Data can be shared between functions through parameters, which come in two varieties: value parameters that copy argument values, and reference parameters that can modify the original argument values.
The document provides an overview of various C++ concepts including control statements, functions, scope, storage classes, and more. It defines concepts like break, continue, switch, and goto statements. It describes function definitions, prototypes, parameters, return types, and how to call functions. It discusses global and local scope, and how the scope operator can access global variables from local scope. It also outlines the different storage classes in C++ including auto, register, extern, and static.
This first assignment will focus on coding in Python, applying kno.docxabhi353063
This first assignment will focus on coding in Python, applying knowledge students should already have about programming with functions and arrays. When the assignment is complete, there will in fact be some indirect recursion, but that needs not complicate the assignment, if each function is allowed to assume that all other functions are implemented correctly.
Problem Description
Several years of experience in algebra probably yields a consistent interpretation of the expression
12 - 2 * 5 +3
Most would expect that the multiplication would be the first operation, followed by a subtraction, and then an addition, yielding a value of 5. Performing those three operations in any other order would yield very different results.
When a programmer places such an expression into a program, they would expect it to perform the same series of operations. The interpreter or compiler making sense of the expression then must be able to construct the correct meaning of the input. Often one will hear of this behavior called
parsing
.
Assignment Specifications
The input for this assignment will arrive as an instantiated
Python list
consisting of
tokens
, where each token is either an integer numeral or an operator. An additional symbol (such as a semicolon) will appear at the end of the list to mark the end of the input.
The Python list has a great deal in common with the C++ array, and this assignment will treat it as such. One will be able to use an integer subscript to examine each element of the list, just as one could examine consecutive array elements. The next assignment will use a different approach to visit the elements of the list.
Implementation Hints
One very simple method of parsing input is termed
predictive parsing
in which each function has an idea of what it expects to see next (or what alternatives it will encounter). For example, we would expect a numeric expression like the one above to include a series of values to be added or subtracted. Whether those values are explicit numbers (such as 12 and 3) or the results of other operations (such as 2*5) might sound like a complication, but that can just be addressed by some other function.
The pseudocode for parsing a sum expression would therefore look something like this:
to evaluate a sum expression (series of zero or more additions and subtractions): evaluate a product expression (zero or more multiplications and divisions) while the next token is a + or - operator evaluate the product expression that follows the operator perform the addition or subtraction
For the given example, the first product expression would simply be the value 12. This is followed by a minus sign, so the next product is evaluated to be 10, which is subtracted from 12 to yield 2. Since this is followed by a plus sign, the loop would repeat to evaluate and add the 3. No more operators appear, so the final result is 5.
The above specifications said that some other symbol would appear at the very end of the input. Thi ...
The document discusses functions in C++. It defines a function as a self-contained program that performs a specific task. Functions help break large programs into smaller, modular pieces. The key parts of a function include the prototype, definition, arguments, return statement, and calling a function. Functions make programs easier to understand, maintain and debug.
The document discusses functions in C++. It defines functions as modular pieces that divide programs into more manageable components. It describes function components like modules, functions, classes, and function calls. It provides examples of math library functions and how to define, call, and prototype functions. It also covers function parameters, return types, and scope rules for local variables and storage classes.
CSC8503 Principles of Programming Languages Semester 1, 2015.docxfaithxdunce63732
CSC8503 Principles of Programming Languages Semester 1, 2015
Assignment 2
Due Date: 11:55pm AEST (13:55 UTC/GMT) Monday 10 May 2015
Weighting: 20%
Total marks: 20
Please submit this assignment using the assignment submission facility on the course
Study Desk. Submit a single file, either a ZIP or TAR archive. The archive
should contain (1) for Part A, a Haskell source file containing the function definitions,
and (2) for Part B, your version of all the files that are in the SPL distribution that you
downloaded.
Just add the Haskell file (call it say ass2.hs) to your collection of SPL files and zip or
tar them into an archive that you submit.
Part A – Haskell – 12 marks
Complete the following Haskell function definitions. Unless stated otherwise do not use library
functions that are not in the Haskell standard prelude. This constraint is so that you
gain practice in simple Haskell recursive programming. The Haskell 2010 standard prelude
definition is available at
https://www.haskell.org/onlinereport/haskell2010/haskellch9.html
Place all definitions in a single file. Submit just this text file electronically as
directed on the course Study Desk page. Use the specified function name as your
code will be tested by a Haskell function expecting that function name.
The testing program may use many more test cases than the ones shown in the specification.
So, please test your functions extensively to ensure that you maximise your marks.
1. [2 marks]
Write the function insertAt :: Int -> a -> [a] -> [a].
insertAt n x xs will insert the element x into the list xs at position n items from the
beginning of xs. In other words, skip n items in xs, then insert the new element.
You can assume that n will be a non-negative number. If n is greater than the length of
the list xs then add it to the end of the list.
For example
insertAt 3 ’-’ "abcde" ⇒ "abc-de"
insertAt 2 100 [1..5] ⇒ [1,2,100,3,4,5]
Hint: Use standard prelude functions ++ and splitAt.
2. [2 marks] Write a function uniq :: Eq a => [a] -> [a] that removes duplicate entries
from a sorted (in ascending order) list. The resulting list should be sorted, and no value
in it can appear elsewhere in the list.
For example:
1
https://www.haskell.org/onlinereport/haskell2010/haskellch9.html
uniq [1,2,2] ⇒ [1,2]
uniq [1,2,3] ⇒ [1,2,3]
3. [1 mark] Write a function
join :: Eq a => [(a,b)] -> [(a,c)] -> [(a,b,c)].
join takes two lists of pairs, and returns a single list of triples. A triple is generated only
when there exists a member of both argument lists that have the same first element. The
list elements are not sorted. This is the same semantics as the relational algebra natural
join operation.
For example:
join [(2,"S"),(1,"J")] [(2,True),(3,False)]
⇒ [(2,"S",True)]
join [(2,"S"),(1,"J")] [(2,1),(2,2),(3,4)]
⇒ [(2,"S",1),(2,"S",2)]
Hint: use list a comprehension.
4. [1 mark] This question extends the join function from question 3. Write the function
ljoin :: Eq a => [(a,b)] -> [(a,c.
The document discusses different types of loops in Python including while loops, for loops, and infinite loops. It provides examples of using while loops to iterate until a condition is met, using for loops to iterate over a set of elements when the number of iterations is known, and how to terminate loops early using break or skip iterations using continue. It also discusses using the range() function to generate a sequence of numbers to iterate over in for loops.
This document discusses different types of functions in C++, including user-defined functions, library functions, function parameters, return values, function prototypes, and function overloading. It provides examples to illustrate key concepts like defining functions with different parameters and return types, passing arguments to functions, and returning values from functions. Storage classes like local, global, static local and register variables are also briefly covered. The document is an introduction to functions in C++ programming.
The document discusses C++ functions. It explains that functions allow code to be reused by grouping common operations into reusable blocks of code called functions. Functions have three parts: a prototype that declares the function, a definition that implements it, and calls that execute the function. Functions can take parameters as input and return a value. Grouping common code into well-named functions makes a program more organized and maintainable.
The document discusses various operators in Java including mathematical, assignment, increment/decrement, relational, logical, ternary, string and casting operators. It provides examples of using each operator and notes precedence rules and other behaviors like type promotion and truncation versus rounding during casting.
This is continuation of the slide Advanced C part 1. In part 1 you learnt about fundamentals of C - How to build an algorithm, operators. In this module - Advanced C part 2 you will be learning about functions, pointers and standard Input Output functions. This slide will help you to move a further ahead in Advanced C and gain deeper knowledge on it.
Young Adulthood begins with the individual being on the verge of att.docxrosemarybdodson23141
Young Adulthood begins with the individual being on the verge of attaining several major life tasks. By the end of the Young Adulthood period, the individual should have successfully attained:
Work
: Higher Education, Obtaining a Job, Developing a sense of work ethic and your place in the workforce
Independent Living
: Dorm-life, Find an apartment, buy a home, merge finances with marriage, support spouse and children
Marriage
: Form intimate relationships, make a commitment, find a life-partner
Child Rearing
: bearing and raising children
What happens to the development of the Young Adult if these life tasks are not attained? Include a discussion of how development will be affected by not attaining these life tasks with respect to the developmental theorists discusses in your class notes and text (K.Warner Schae, Erikson, Levinson and Sternberg). Also, include a discussion of current economic or societal reasons as to why Young Adults may not be achieving these life tasks? Use APA citations for all resources used; including your course text.
3 pages
.
Your abilities in international management have been recognize.docxrosemarybdodson23141
Your abilities in international management have been recognized, and your consulting assistance has been requested. The company Quasimoto Enterprises has been approached by a reputed Chinese firm that wants exclusive production and selling rights for one of its new high-tech products. The company has been looking for a strategic partner for the production of this product to reduce costs. Hence, Quasimoto Enterprises is very interested in exploring the possibility of developing relationships with this Chinese firm. This deal is very critical to growth of Quasimoto in the international market. Both parties are anxious and preparing for their first meeting in a month’s time to move this deal forward. This is the first time Quasimoto is doing business with China, and this is also the case with the Chinese firm.
The bold question below is my part of the project That i need you to complete. It has to be 5 double space written pages plus reference page Disregard the other two question and, its not my responsibility. I just added it to the email for you to have a full understanding of the what assignment is.
What does Quasimoto Enterprises need to know about Chinese bargaining behaviors to strike the best possible deal with this company? What should the Chinese firm know about American bargaining behaviors to strike the best possible deal with your company?
In your small group, develop a strategic plan for the negotiation and conflict resolution for Quasimoto's executive team for its first meeting with the Chinese. Also, develop a negotiation and conflict resolution plan for the Chinese firm for its first meeting with the Americans. Please note that because this is an important business deal for both companies, both of your plans should include the bargaining behaviors of both countries. Are there any similarities between their bargaining behaviors? Can they have a win-win deal?
APA format is mandatory (in text and in the reference section).
There are two main types of databases accessible in the library, through “FIND ARTICLES & BOOKS.” Keep in mind that the most popular databases are: ABI Inform Global, Academic Search Premier, and Business Source Premier. As a student, you must steer away from inferior Web sites with anonymous writers, articles found on consultant Web sites, materials on sites like QuickMBA.com, MarketingProfs.com, etc. Dictionaries and Encyclopedias most often repeat the information from your text. Acceptable Internet resources include among others government sites (especially for statistics). You are not permitted to use any open-source Web site in this course.
Present your findings as a 5 -7 pages Word document formatted in APA style.
Submitting your assignment in APA format means, at a minimum, you will need the following:
1. TITLE PAGE. Remember the Running head: AND TITLE IN ALL CAPITALS
2. ABSTRACT. A summary of your paper…not an introduction. Begin writing in third person voice.
3. BODY. The body of your paper begins on t.
More Related Content
Similar to MP 4 – Continuation-Passing StyleCS 421 – Fall 2012Revis.docx
The document discusses different ways that functions can handle arguments in C++, including passing by value, passing by reference, and function overloading. It provides examples to illustrate each concept. Specifically:
1) Arguments are normally passed by value by default, meaning the function receives a copy of the argument rather than the actual variable.
2) Arguments can also be passed by reference using ampersands, allowing changes to the arguments inside the function to affect the original variables.
3) Functions can be overloaded when they have the same name but different parameters, allowing different implementations based on argument types.
Complete Information till 2D arrays. In this slides you can also find information about loops and control decision....
Best slides for beginners who wants to learn about C programming language..
This document provides an overview of imperative programming and nested loops in Python. It discusses strategies for writing nested loops, including using for loops with if conditions. It also covers the range() function for iterating over sequences of numbers, user-defined functions, parameters, return statements versus print statements, multiline comments, and docstrings. The document concludes with assigning practice problems to help reinforce these concepts.
This document discusses control flow statements and loops in Python programming. It covers decision control statements like if, if-else and if-elif-else and loops like for and while loops. It provides examples of using these statements to make decisions and iterate over sequences. It also discusses concepts like break, continue and pass statements used to control program flow. The document concludes with some lab assignments involving applying control flow statements and loops to solve problems.
This document discusses arrays and functions in C++. It explains that arrays allow storing multiple values in a single variable to avoid declaring many individual variables. Arrays can store values of different data types like integers, floats, characters. Functions are blocks of code that perform a specific task and can optionally return a value. Functions make code reusable and avoid repetition. The document provides examples of one-dimensional and two-dimensional arrays, and functions with and without parameters. It also assigns practice problems of writing functions to calculate the summation of numbers from 1 to 1000, find the factorial of a given number, and calculate a number to the power of a given exponent.
02 functions, variables, basic input and output of c++Manzoor ALam
This document discusses computer programming functions, variables, and basic input/output in C and C++. It covers:
- Defining and calling functions, function parameters and return values.
- Declaring and assigning values to variables of different data types like int, float, and double.
- Using basic input/output functions like cout and cin to display output and get user input.
- The scope of variables and how they work within and outside of functions.
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
Writer Monad for logging execution of functionsPhilip Schwarz
download for better quality - Learn how to use the Writer monad to log (trace) the execution of functions through the work of Bartosz Milewski and Alvin Alexander
The document discusses C++ functions. It defines what functions are and their uses in breaking down problems into smaller tasks. There are two types of functions: standard functions that are part of the C++ language and user-defined functions. A function has a signature defining its return type and parameters. Functions are declared and defined in two steps - declaration and implementation. Data can be shared between functions through parameters, which come in two varieties: value parameters that copy argument values, and reference parameters that can modify the original argument values.
The document provides an overview of various C++ concepts including control statements, functions, scope, storage classes, and more. It defines concepts like break, continue, switch, and goto statements. It describes function definitions, prototypes, parameters, return types, and how to call functions. It discusses global and local scope, and how the scope operator can access global variables from local scope. It also outlines the different storage classes in C++ including auto, register, extern, and static.
This first assignment will focus on coding in Python, applying kno.docxabhi353063
This first assignment will focus on coding in Python, applying knowledge students should already have about programming with functions and arrays. When the assignment is complete, there will in fact be some indirect recursion, but that needs not complicate the assignment, if each function is allowed to assume that all other functions are implemented correctly.
Problem Description
Several years of experience in algebra probably yields a consistent interpretation of the expression
12 - 2 * 5 +3
Most would expect that the multiplication would be the first operation, followed by a subtraction, and then an addition, yielding a value of 5. Performing those three operations in any other order would yield very different results.
When a programmer places such an expression into a program, they would expect it to perform the same series of operations. The interpreter or compiler making sense of the expression then must be able to construct the correct meaning of the input. Often one will hear of this behavior called
parsing
.
Assignment Specifications
The input for this assignment will arrive as an instantiated
Python list
consisting of
tokens
, where each token is either an integer numeral or an operator. An additional symbol (such as a semicolon) will appear at the end of the list to mark the end of the input.
The Python list has a great deal in common with the C++ array, and this assignment will treat it as such. One will be able to use an integer subscript to examine each element of the list, just as one could examine consecutive array elements. The next assignment will use a different approach to visit the elements of the list.
Implementation Hints
One very simple method of parsing input is termed
predictive parsing
in which each function has an idea of what it expects to see next (or what alternatives it will encounter). For example, we would expect a numeric expression like the one above to include a series of values to be added or subtracted. Whether those values are explicit numbers (such as 12 and 3) or the results of other operations (such as 2*5) might sound like a complication, but that can just be addressed by some other function.
The pseudocode for parsing a sum expression would therefore look something like this:
to evaluate a sum expression (series of zero or more additions and subtractions): evaluate a product expression (zero or more multiplications and divisions) while the next token is a + or - operator evaluate the product expression that follows the operator perform the addition or subtraction
For the given example, the first product expression would simply be the value 12. This is followed by a minus sign, so the next product is evaluated to be 10, which is subtracted from 12 to yield 2. Since this is followed by a plus sign, the loop would repeat to evaluate and add the 3. No more operators appear, so the final result is 5.
The above specifications said that some other symbol would appear at the very end of the input. Thi ...
The document discusses functions in C++. It defines a function as a self-contained program that performs a specific task. Functions help break large programs into smaller, modular pieces. The key parts of a function include the prototype, definition, arguments, return statement, and calling a function. Functions make programs easier to understand, maintain and debug.
The document discusses functions in C++. It defines functions as modular pieces that divide programs into more manageable components. It describes function components like modules, functions, classes, and function calls. It provides examples of math library functions and how to define, call, and prototype functions. It also covers function parameters, return types, and scope rules for local variables and storage classes.
CSC8503 Principles of Programming Languages Semester 1, 2015.docxfaithxdunce63732
CSC8503 Principles of Programming Languages Semester 1, 2015
Assignment 2
Due Date: 11:55pm AEST (13:55 UTC/GMT) Monday 10 May 2015
Weighting: 20%
Total marks: 20
Please submit this assignment using the assignment submission facility on the course
Study Desk. Submit a single file, either a ZIP or TAR archive. The archive
should contain (1) for Part A, a Haskell source file containing the function definitions,
and (2) for Part B, your version of all the files that are in the SPL distribution that you
downloaded.
Just add the Haskell file (call it say ass2.hs) to your collection of SPL files and zip or
tar them into an archive that you submit.
Part A – Haskell – 12 marks
Complete the following Haskell function definitions. Unless stated otherwise do not use library
functions that are not in the Haskell standard prelude. This constraint is so that you
gain practice in simple Haskell recursive programming. The Haskell 2010 standard prelude
definition is available at
https://www.haskell.org/onlinereport/haskell2010/haskellch9.html
Place all definitions in a single file. Submit just this text file electronically as
directed on the course Study Desk page. Use the specified function name as your
code will be tested by a Haskell function expecting that function name.
The testing program may use many more test cases than the ones shown in the specification.
So, please test your functions extensively to ensure that you maximise your marks.
1. [2 marks]
Write the function insertAt :: Int -> a -> [a] -> [a].
insertAt n x xs will insert the element x into the list xs at position n items from the
beginning of xs. In other words, skip n items in xs, then insert the new element.
You can assume that n will be a non-negative number. If n is greater than the length of
the list xs then add it to the end of the list.
For example
insertAt 3 ’-’ "abcde" ⇒ "abc-de"
insertAt 2 100 [1..5] ⇒ [1,2,100,3,4,5]
Hint: Use standard prelude functions ++ and splitAt.
2. [2 marks] Write a function uniq :: Eq a => [a] -> [a] that removes duplicate entries
from a sorted (in ascending order) list. The resulting list should be sorted, and no value
in it can appear elsewhere in the list.
For example:
1
https://www.haskell.org/onlinereport/haskell2010/haskellch9.html
uniq [1,2,2] ⇒ [1,2]
uniq [1,2,3] ⇒ [1,2,3]
3. [1 mark] Write a function
join :: Eq a => [(a,b)] -> [(a,c)] -> [(a,b,c)].
join takes two lists of pairs, and returns a single list of triples. A triple is generated only
when there exists a member of both argument lists that have the same first element. The
list elements are not sorted. This is the same semantics as the relational algebra natural
join operation.
For example:
join [(2,"S"),(1,"J")] [(2,True),(3,False)]
⇒ [(2,"S",True)]
join [(2,"S"),(1,"J")] [(2,1),(2,2),(3,4)]
⇒ [(2,"S",1),(2,"S",2)]
Hint: use list a comprehension.
4. [1 mark] This question extends the join function from question 3. Write the function
ljoin :: Eq a => [(a,b)] -> [(a,c.
The document discusses different types of loops in Python including while loops, for loops, and infinite loops. It provides examples of using while loops to iterate until a condition is met, using for loops to iterate over a set of elements when the number of iterations is known, and how to terminate loops early using break or skip iterations using continue. It also discusses using the range() function to generate a sequence of numbers to iterate over in for loops.
This document discusses different types of functions in C++, including user-defined functions, library functions, function parameters, return values, function prototypes, and function overloading. It provides examples to illustrate key concepts like defining functions with different parameters and return types, passing arguments to functions, and returning values from functions. Storage classes like local, global, static local and register variables are also briefly covered. The document is an introduction to functions in C++ programming.
The document discusses C++ functions. It explains that functions allow code to be reused by grouping common operations into reusable blocks of code called functions. Functions have three parts: a prototype that declares the function, a definition that implements it, and calls that execute the function. Functions can take parameters as input and return a value. Grouping common code into well-named functions makes a program more organized and maintainable.
The document discusses various operators in Java including mathematical, assignment, increment/decrement, relational, logical, ternary, string and casting operators. It provides examples of using each operator and notes precedence rules and other behaviors like type promotion and truncation versus rounding during casting.
This is continuation of the slide Advanced C part 1. In part 1 you learnt about fundamentals of C - How to build an algorithm, operators. In this module - Advanced C part 2 you will be learning about functions, pointers and standard Input Output functions. This slide will help you to move a further ahead in Advanced C and gain deeper knowledge on it.
Similar to MP 4 – Continuation-Passing StyleCS 421 – Fall 2012Revis.docx (20)
Young Adulthood begins with the individual being on the verge of att.docxrosemarybdodson23141
Young Adulthood begins with the individual being on the verge of attaining several major life tasks. By the end of the Young Adulthood period, the individual should have successfully attained:
Work
: Higher Education, Obtaining a Job, Developing a sense of work ethic and your place in the workforce
Independent Living
: Dorm-life, Find an apartment, buy a home, merge finances with marriage, support spouse and children
Marriage
: Form intimate relationships, make a commitment, find a life-partner
Child Rearing
: bearing and raising children
What happens to the development of the Young Adult if these life tasks are not attained? Include a discussion of how development will be affected by not attaining these life tasks with respect to the developmental theorists discusses in your class notes and text (K.Warner Schae, Erikson, Levinson and Sternberg). Also, include a discussion of current economic or societal reasons as to why Young Adults may not be achieving these life tasks? Use APA citations for all resources used; including your course text.
3 pages
.
Your abilities in international management have been recognize.docxrosemarybdodson23141
Your abilities in international management have been recognized, and your consulting assistance has been requested. The company Quasimoto Enterprises has been approached by a reputed Chinese firm that wants exclusive production and selling rights for one of its new high-tech products. The company has been looking for a strategic partner for the production of this product to reduce costs. Hence, Quasimoto Enterprises is very interested in exploring the possibility of developing relationships with this Chinese firm. This deal is very critical to growth of Quasimoto in the international market. Both parties are anxious and preparing for their first meeting in a month’s time to move this deal forward. This is the first time Quasimoto is doing business with China, and this is also the case with the Chinese firm.
The bold question below is my part of the project That i need you to complete. It has to be 5 double space written pages plus reference page Disregard the other two question and, its not my responsibility. I just added it to the email for you to have a full understanding of the what assignment is.
What does Quasimoto Enterprises need to know about Chinese bargaining behaviors to strike the best possible deal with this company? What should the Chinese firm know about American bargaining behaviors to strike the best possible deal with your company?
In your small group, develop a strategic plan for the negotiation and conflict resolution for Quasimoto's executive team for its first meeting with the Chinese. Also, develop a negotiation and conflict resolution plan for the Chinese firm for its first meeting with the Americans. Please note that because this is an important business deal for both companies, both of your plans should include the bargaining behaviors of both countries. Are there any similarities between their bargaining behaviors? Can they have a win-win deal?
APA format is mandatory (in text and in the reference section).
There are two main types of databases accessible in the library, through “FIND ARTICLES & BOOKS.” Keep in mind that the most popular databases are: ABI Inform Global, Academic Search Premier, and Business Source Premier. As a student, you must steer away from inferior Web sites with anonymous writers, articles found on consultant Web sites, materials on sites like QuickMBA.com, MarketingProfs.com, etc. Dictionaries and Encyclopedias most often repeat the information from your text. Acceptable Internet resources include among others government sites (especially for statistics). You are not permitted to use any open-source Web site in this course.
Present your findings as a 5 -7 pages Word document formatted in APA style.
Submitting your assignment in APA format means, at a minimum, you will need the following:
1. TITLE PAGE. Remember the Running head: AND TITLE IN ALL CAPITALS
2. ABSTRACT. A summary of your paper…not an introduction. Begin writing in third person voice.
3. BODY. The body of your paper begins on t.
your 14 years daughter accidently leaves her purse open in the fam.docxrosemarybdodson23141
A parent finds their 14-year-old daughter's purse open and sees a package of birth control pills inside. There are two questions asking for discussion of this situation. The first asks for a brief description and definition. The second asks to discuss at least one major theoretical approach to explaining and resolving the situation.
Young people are ruining the English languageIn your reflectio.docxrosemarybdodson23141
"Young people are ruining the English language"
In your reflection, respond to the following sub-prompts:
What are the underlying language ideologies of this statement?
What would be a linguist’s take on this statement?
What type of evidence would one need to support the statement?
Do you have a personal position on this statement? Explain.
Has this course (or a related course) influenced your understanding of the issue around this statement? Explain
.
Young man drops out of school in seventh grade and becomes his mothe.docxrosemarybdodson23141
Young man drops out of school in seventh grade and becomes his mothers most wealthiest child. Obtaining a car dealership, a club , and real estate.
How he overcame. The mistakes he made. How the people closest people closest to him helped or hindered him. 3 scenes as an adolescen 3 sscenes as a middle age adult and 3 scenes as an older adult,
.
Young and the RestlessWeek 11 Couples Therapy Movie Experience .docxrosemarybdodson23141
Young and the Restless
Week 11: Couples Therapy Movie Experience & Paper (28 points)
Couples Therapy Movie/TV Experience & Analysis Paper (Due week 11): 28 points
Couples Therapy Movies Experience & Analysis Paper based is based on the UCLA Marriage Enrichment Program & Happily Ever After The Movies & Relationship Study (A research study that is being conducted by Professor Ronald D. Rogge from the University of Rochester’s Department of Clinical and Social Sciences in Psychology) as well as the “PAIR Program” Promoting Awareness and Improving Relationships with Movies, my experience as a LMHC, LPC and LMFT Clinical Supervisor, Prepare/Enrich Certified Marital Counselor, Certified Supreme Court Mediator, and Certified Parent Coordinator.
http://www.courses.rochester.edu/surveys/funk/ (Links to an external site.)Links to an external site.
“A recent study at UCLA of Couples after the first 3 years of marriage (Roggie, et al., 2014) suggested that couples felt enriched by watching movies together and then “engaging in relationship focused” discussions after each movie. In these conversations the couple would discuss how their relationship was similar to different from the intimate relationship portrayed in each movie.’
This is a self-growth and Movie/TV analysis experience activity. Ideally doing this with a partner would be fun however not required. You can do this alone and base it on a relationship you had or one you hope to have or your family. It is not important to disclose if it is your relationship that you are using if you do not want to however be consistent with who you are using in your reflections.
The best approach to this assignment is to pick a show or a movie and watch it the beginning of the term and then at the end unless you choose a TV show to “binge” watch as part of this class or over the 3 months of class to immerse yourself into the show and couples you will be assessing and exploring in this project and take notes based on the assessment questions each time you watch the movie/show.
You will be looking at the following objectives for the couple:
• Explore strength and growth areas
• Strengthen communication skills
• Identify and manage major stressors
• Conflict resolution abilities
• Develop a more balanced relationship
• Explore family of origin issues
• Discuss financial planning and budgeting
• Establish personal, couple and family goals
• Understand and appreciate personality differences
Your Task (Cut and Paste these questions into a WORD document and create a template to use while watching movies/TV shows of your choice):
1) Pick 1 movie or “binge” watch a TV show (at least 4-6 episodes) related to Couples and Family.
2) Answer the following questions in a journal format or paper if you choose referencing the TV show/movies you watch, your text and other Couple and Family Therapy resources you use to support your thoughts/ideas.
1. What movie/TV shows did you watch? List.
You may have seen how financial news outlets provide real-time .docxrosemarybdodson23141
You may have seen how financial news outlets provide real-time financial market reporting. They often produce stock-market news feeds for traders; these news feeds include a stock chart. The stock chart may include different filters that allow you to see how the stock is performing today or has performed over one or more years.
There are many factors that will influence pricing that can’t be controlled or predicted accurately. The approaches used to value stocks (determine what the stock is truly worth) are usually theoretical. You should consider what drives stock prices and why.
For this discussion, first go to Mergent Online. Find the pricing chart under the “Company Details” tab, then click on
Pricing Summary
for your selected company. This is the company you have selected for your Project Two assignment. Filter the time period to one year.
In your initial post, address the following:
Discuss how the stock for your company is trending. Explain why the stock is in either an uptrend or downtrend.
Discuss some of the factors, including environmental, sustainable, and governance (ESG) factors, that you believe have impacted the stock performance and why.
Convince your peers to either invest in your chosen company or to not invest in the company. Explain your reasoning.
In your response posts to at least two peers, discuss the following:
Do you agree with your peer’s argument to either invest or not invest in their company? Explain why or why not, making sure to also include information not previously shared by your peer
Post by Joshue Brown
Discuss how the stock for your company is trending. Explain why the stock is in either an uptrend or downtrend.
Tesla's stock has a positive trend over the past year. The stock has ranged from a low of $187.06 a year ago to a high of $883.09 on January 26, 2021 (Yahoo, 2021a). Tesla's shares have skyrocketed more than 20,000% since it went public in 2010, with its price rising more than 700% over the last year (Levin, 2021). This growth has made Tesla the most valuable car company in the world. There are many reasons for this epic growth. After years of not turning a profit for years, Tesla has finally shown a profit for the last 6 quarters. Tesla also beat estimates by producing more than 500,000 vehicles and selling its fifth vehicle, Modle Y, ahead of schedule (Levin, 2021). In addition, Tesla was added to the S&P 500 on November 16th, 2020, which helped the share price spike. These are the main drivers of the success of Teslas stock over the past 12 months. Another positive trend that has factored into the growth of Tesla's stock is the growing demand for EV stocks in general. Tightening emission regulations and the government's continued push towards renewable energy have also help Tesla's shares rise.
Discuss some of the factors, including environmental, sustainable, and governance (ESG) factors, that you believe have impacted the stock p.
You are responsible for putting together the Harmony Day celebr.docxrosemarybdodson23141
You are responsible for putting together the Harmony Day celebration for Darcy Consulting, this years’ theme is Everyone Belongs.
There will be the following events:
Morning tea (internal)
Art Exhibition opening (Darcy Consulting is the main sponsor of this event)
Put together a communication/project plan for Harmony Day. Communication types to be included are:
Posters promoting both (internally)
Emails promoting both (internally)
Email to clients inviting them to Art Exhibition
Scripted remarks for CEO for the Art Exhibition opening
Scripted remarks for HR Manager for Morning Tea
In your plan you will need to:
Timeline the planning of the events
Timeline the communication
Identify key messages
.
You wrote this scenario from the perspective of Behaviorism learni.docxrosemarybdodson23141
You wrote this scenario from the perspective of Behaviorism learning theory Now I want two scenarios same this scenario but from two different perspectives that they are Cognitivism Learning theory and Social learning theory
For further clarification see attached example
Learning Situation from Behaviorism Learning Theory
The class of 20 students is divided into two teams, having 10 students in each team. The teacher makes two columns on the board for team A and team B. Teacher points out, Yesterday in our history class we studied about the civil rights movement I hope you have well-prepared that topic. Let’s start an informal quiz based on yesterday’s topic. Are you guys ready? Students say, “Yes”! Teacher starts asking questions. Team A! Which sports Jackie Robinson played? Students raised their hands. Robert? Can you give the answer? Robert says soccer. Teacher appreciating Robert’s effort says very good Robert and write 10 under the column of Team A. Next question for Team B, Dr. Martin Luther King Jr. went to the college to become? Students raise their hands. James, can you answer? James says, “Minister”. Teacher appreciates the attempt but the answer is not correct. Ok! Now, what you guys think what was the main contribution of Abraham Lincoln?Timothy raised his hand and replied, he brought freedom and abolish slavery. Rosie raised her hand and replied, he ran the country being a president of the country. Teacher says, when we freedom was attained by the African American it was not solely due to Abraham Lincoln. Who played the actual role? Joseph replies, African Americans themselves. Teacher appreciated Joseph’s answer saying absolutely right. No leader can bring freedom from slavery or racism until its people are themselves not ready to put their efforts. Nation needs to be united to get rid of inequality.
Learning Situation from Cognitivism Learning Theory:
Learning Situation from Social Learning Theory:
3 | Page
Chapter 2 terminology
Psych260
Nervous System-
A network of billions of cells in the brain and the body responsible for all aspects of what we feel, think, and do.
Central nervous system-
The part of the nervous system that consists of the brain and the spinal cord.
Peripheral nervous system-
The part of the nervous central nervous system with the muscles, organs and glands.
Neurons-
The basic units of the nervous system cells that receive integrate and transmit information in the nervous system. Neurons operate through electrical impulses communicate with other neurons through electrical impulses communicate with other neurons through chemical signals and form neural networks.
Dendrites –
Branchlike extensions of the neuron with receptors that detect information from other neurons.
Cell Body-
Part of the neuron where information from thousands of other neurons is collected and integrated.
Axon-
A long narrow outgrowth of a neuron that enables the neuron to transmit information to other neurons..
You worked closely with your IT managers to develop a complementing .docxrosemarybdodson23141
You worked closely with your IT managers to develop a complementing IT strategic plan. Your team identified the new technologies to be implemented in the next 2 years.
In 175 words or more discuss how you would proceed in advancing these technologies from the planning phase to executing and utilizing them in the company.
.
You work in the office of a personal financial planner. He has asked.docxrosemarybdodson23141
The document provides instructions for a financial planner to develop an initial power point presentation and speaker notes to educate a company about hedge funds as alternatives for fund acquisition and the associated risks. The presentation should include 8-10 slides and 600-800 words of speaker notes and is due in two days, on June 29th at 11:59 PM for a total of 125 points. The planner should use the provided course materials and resources to complete the assignment.
You work in the IT department of a financial services company that s.docxrosemarybdodson23141
You work in the IT department of a financial services company that sells investments to, and manages investment portfolios for, high net worth individuals. Your organization uses custom-built legacy software applications and systems to support its sales processes. The sales software applications and systems are not integrated, and they do not support an enterprise view of the sales processes throughout the organization. Management is frustrated because the sales applications and systems do not provide the information and reports necessary for them to measure, monitor, and manage sales production in the organization. Sales executives and account managers are frustrated because the sales software applications and systems do not support the sales cycle for the products and services that the organization sells.
You have been assigned to analyze your organization’s sales processes and identify an IT system capable of improving the sales processes of your organization. In addition, your organization is looking for an easy-to-use, cloud-based Customer Relationship Management (CRM) solution to generate more leads, increase sales, improve customer service, reduce the cost of sales for the organization, and increase revenue.
The project proposal must include the following items:
· A project definition and scope that defines the project and articulates the business context for the project
· The problems that the proposed system is expected to solve (or opportunities the proposed project is expected to produce)
· The project objectives
· The project methodology or "game plan"
· A high-level schedule for completing the project scope
Instructions
: Fill out each of the sections below with information relevant to your project, and add your company’s name.
Company Name
Project Proposal
Project Scope statement
Project Title:
Project Sponsor(s):
Business Context for the System:
Project Scope Description:
Date Prepared:
Prepared By:
Problems/Issues/opportunities the proposed system expected to Solve
Problems
Issues
Opportunities
·
·
·
project objectives
Project Objective Name
Project Objective Description
project deliverables
Project Deliverable Name
Project Deliverable Description
project acceptance criteria
Project Acceptance Criteria Name
Project Acceptance Criteria Description
project exclusions
Project Exclusion Name
Project Exclusion Description
project constraints
Project Constraint Name
Project Constraint Description
project assumptions
Project Assumption Name
Project Assumption Description
PROJECT METHODOLOGY
high-level work schedule: Project Scope
Description of Work
Assumptions and Constraints
Milestones
Due Dates
ID
Activity
Resource
Labor
Hours
Labor
Rate
Labor
Total
Material
Units
Material
Cost
Material
Total
Total
Cost
.
You work for the Jaguars Bank as the Chief Information Officer. It .docxrosemarybdodson23141
You work for the Jaguars Bank as the Chief Information Officer. It has been brought up to your attention that a security model is needed for protection of information. Using the NSTISSC model, examine each of the cells and write a brief statement on how you would address the three components represented in that cell.
.
You work for OneEarth, an environmental consulting company that .docxrosemarybdodson23141
You work for OneEarth, an environmental consulting company that specializes in building-condition assessments, contaminated-site remediation, and energy audits. Founded by an environmentally concerned citizen in 2010, OneEarth has emerged as the highest-quality and most comprehensive environmental services company in the northern region of the United States.
Recently, ardent local representative Sy Bill Wright contacted OneEarth for assistance evaluating the validity of arguments related to fracking. He agreed to meet with any interest or advocacy groups that wanted to discuss their positions to ensure that he was well-informed about the controversial topic. Now, he needs OneEarth’s help examining the arguments and the evidence they provided to ensure that he makes a sound decision. He believes that OneEarth, a highly-respected environmental firm with strong connections to the local community, could provide critical insights to his evaluation of the advocacy groups’ evidence. Aware of your previous work advising on fossil fuel management, your manager Claire DeAir has asked you to serve as a liaison to representative Wr
Directions
Representative Wright has provided you with all of the information he received from the advocacy or interest groups that he entertained the previous week. This information in available in his email in the Supporting Materials section. In your position paper (750–1,250 words), you will evaluate the arguments of each group, specifically examining their conclusions, premises, assumptions, and evidence. Using your analysis, representative Wright will be able to determine how to take the soundest position on the controversial topic. In your paper, include the following components:
A discussion of the common conceptions and misconceptions about the topic
What is the topic? What are the
common conceptions and misconceptions
about this topic?
What is the context of the topic?
Why is the topic a significant issue?
What was your own opinion as a consultant prior to conducting research?
An identification and description the components of the argument
What is the
main point or conclusion
about the topic?
What are the
main arguments and subarguments
about the topic?
What are the
premises
(reasons for thinking the conclusion is true)? Are there any
missing premises
?
What are the
assumptions
and
biases
?
A recognition and evaluation of the deductive and inductive arguments
If the argument is
deductive
(providing premises that guarantee their conclusions):
Is the argument
valid
? (Are the premises and the conclusions true?)
What types of formal and/or informal
logical fallacies
are used?
Is the argument
sound
?
If the argument is
inductive
(aiming to provide premises that make the conclusion more probable):
Is the argument
strong
(more probable conclusion in light of premises) or
weak
(less probable conclusion i.
You work for an international construction company that has been con.docxrosemarybdodson23141
You work for an international construction company that has been contracted to build the tallest skyscraper in the world in Rio De Janeiro. The financing is coming from Dubai, the materials are coming from China, the engineering and technology is
coming from Germany, and the labor will be hired locally with management from the United States. You invite all of the players to the headquarters in the United States for a big meeting to explain the project and get to know one another. The people seem to be staying with their own groups and not mingling.
·
What is the cultural phenomenon here?
·
How do you explain the lack of intercultural communication?
·
What do you know about these cultures—specifically their economic, political, educational, and social systems—that could help you in getting them together?
·
What are some of the contrasting cultural values of these countries?
You are concerned about some of the language issues as you start the meeting, particularly the fact that the United States is a low-context country, and some of the countries present are high-context countries. Furthermore, you only speak English, and you do not have an interpreter present.
·
How will this affect the presentation?
·
What are some of the issues you should be concerned about regarding verbal and nonverbal language for this group?
·
What strategy would you use to begin to have everyone develop a relationship with each other that will help ease future negotiations, development, and implementation?
.
You will write your Literature Review Section of your EBP Projec.docxrosemarybdodson23141
You will write your Literature Review Section of your EBP Project Proposal. Here is a
Review of Literature Example (Word)
to use as a model or guide. To conduct your literature review, you begin with the search strategy, gather your resources, then start writing your literature review and gap analysis.
Search Strategy
In the literature review section, you are to identify your
search strategy
, which can include the following:
the databases and internet sites or search engines used to explore the literature (CINAHL, Medline, Google, Yahoo, etc.)
the search terms you used
the beginning and ending dates of the period covered in this study
the time period when the search was conducted (e.g., Fall 2008)
any special journals hand-searched and any relevant sources used in performing the literature search
Description of Literature or Gaps in the Literature
The literature review section is a review of studies that are related to your phenomenon. It should take up about eight to ten pages, or approximately 3,000 to 4,000 words. The purpose is to tell the reader what is known about your phenomenon and lead the reader to what is not known about your phenomenon (your research problem). You should have sub-headings throughout this section of the paper.
The literature section discusses the relevant research related to your study. Do not discuss each study individually; instead, synthesize the literature based on your literature matrix. You can discuss individual findings of studies (include all eight studies that you described in your literature matrix in Weeks 4 and 9) as appropriate including the statistical findings and study samples. This section needs to tell the reader what is known about your clinical area of interest. You will also summarize your review of the literature and discuss the gaps you have identified.
Assignment Instructions
Your assignment should be:
Eight to ten pages, or approximately 3,000 to 4,000 words, no cover page required, and the page count doesn’t include the references list
Your search strategy
Description of articles (who, population, sample, what was done, statistical findings, limitations, and so on)
Gaps section: the gaps you have identified from your literature search
Please refer to the
Grading Rubric
for details on how this activity will be graded.
Example of A Literature Review : Follow the below example
Week 9 Review of Literature Example
Written by Jennifer Oddy, Entitled:
Distress And Coping of Mothers of Children With Muscular Dystrophy
Introduction
The purpose of this literature review is to discuss the current knowledge regarding experiences of mothers who care for their child with muscular dystrophy, their coping mechanisms, and to understand their lived experiences in order to provide better nursing care to these mothers. Not only will the current knowledge be addressed, this literature review will also speak to what is unknown about this phenomenon. The concepts of matern.
You work for a small community hospital that has recently updated it.docxrosemarybdodson23141
You work for a small community hospital that has recently updated its health record system to a modern electronic health record (EHR) system. As a health care manager, you have been asked to meet with the health information manager (HIM) and analyze the efficiency, security, and privacy of your current health records system. Your organization has very high standards and a culture of keeping up with current trends. After your analysis, you have been asked to provide a detailed report to the hospital's chief operating officer (COO) detailing the following:
Examine the emergence of technology and electronic health systems in health care since the passage of the Health Insurance Portability and Accountability Act (HIPAA).
Provide an analysis of the current trends in health care record keeping and charting as they relate to advancements in technology.
Assess ways in which contemporary patient records systems can support health care operations including privacy, quality patient care delivery, insurance and cost administration, and records access and retention.
Present your findings in an executive summary of 5–7 pages.
.
You work for a regional forensic computer lab and have been tasked w.docxrosemarybdodson23141
You have been tasked with recovering data from a suspect's cell phone/PDA to find evidence of cyberstalking. Research methods of cyberstalking and detail your process for recovering all information from the device to prove the allegations using any evidence found.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
How to Setup Warehouse & Location in Odoo 17 Inventory
MP 4 – Continuation-Passing StyleCS 421 – Fall 2012Revis.docx
1. MP 4 – Continuation-Passing Style
CS 421 – Fall 2012
Revision 1.0
Assigned September 17, 2013
Due September 24, 2013 21:59
Extension 48 hours (20% penalty)
1 Change Log
1.0 Initial Release.
2 Objectives and Background
The purpose of this MP is to help the student learn the basics of
continuation-passing style, or CPS, and CPS transfor-
mation. Next week, you will be using your knowledge learned
from this MP to construct a general-purpose algorithm
for transforming code in direct style into continuation-passing
style.
3 Instructions
The problems below are all similar to the problems in MP2 and
MP3. The difference is that you must implement each
of these function in continuation-passing style. In some cases,
you must first write a function in direct style (according
to the problem specification), then transform the function
definition into continuation-passing style.
The problems below have sample executions that suggest how to
write answers. Students have to use the same
function name, but the name of the parameters that follow the
function name need not be duplicated. That is, the
2. students are free to choose different names for the arguments to
the functions from the ones given in the example
execution. We also will use let rec to begin the definition of
some of the functions that are allowed to use recursion.
You are not required to start your code with let rec. Similarly, if
you are not prohibited from using explicit
recursion in a given problem, you may change any function
definition from starting with just let to starting with let
rec.
For all these problems, you are allowed to write your own
auxiliary functions, either internally to the function
being defined or externally as separate functions. All such
helper functions must satisfy any coding restrictions (such
as being in tail recursive form, or not using explicit recursion)
as the main function being defined for the problem must
satisfy.
Here is a list of the strict requirements for the assignment.
• The function name must be the same as the one provided.
• The type of parameters must be the same as the parameters
shown in sample execution.
• Students must comply with any special restrictions for each
problem. For several of the problems, you will be
required to write a function in direct style, possibly with some
restrictions, as you would have in MP2 or MP3,
and then transform the code you wrote in continuation-passing
style.
1
3. 4 Problems
These exercises are designed to give you a feel for
continuation-passing style. A function that is written in
continuation-
passing style does not return once it has finished computing.
Instead, it calls another function (the continuation) with
the result of the computation. Here is a small example:
# let report x =
print_string "Result: ";
print_int x;
print_newline();;
val report : int -> unit = <fun>
# let inck i k = k (i+1)
val inck : int -> (int -> ’a) -> ’a = <fun>
The inck function takes an integer and a continuation. After
adding 1 to the integer, it passes the result to its
continuation.
# inck 3 report;;
Result: 4
- : unit = ()
# inck 3 inck report;;
Result: 5
- : unit = ()
In line 1, inck increments 3 to be 4, and then passes the 4 to
report. In line 4, the first inck adds 1 to 3, and
passes the resulting 4 to the second inck, which then adds 1 to
4, and passes the resulting 5 to report.
4.1 Transforming Primitive Operations
Primitive operations are “transformed” into functions that take
4. the arguments of the original operation and a continu-
ation, and apply the continuation to the result of applying the
primitive operation on its arguments.
1. (10 pts) Write the following low-level functions in
continuation-passing style. A description of what each function
should do follows:
• addk adds two integers;
• subk subtracts the second integer from the first;
• mulk multiplies two integers;
• posk determines if the argument is strictly positive;
• float addk adds two floats;
• float divk divides the first float by the second float;
• catk concatenates two strings;
• consk created a new list by adding an element at the front of a
list;
• geqk determines if the first argument is greater than or equal
to the second argument; and
• eqk determines if the two arguments are equal.
# let addk n m k = ...;;
val addk : int -> int -> (int -> ’a) -> ’a = <fun>
# let subk n m k = ...;;
val subk : int -> int -> (int -> ’a) -> ’a = <fun>
2
# let mulk n m k = ...;;
val mulk : int -> int -> (int -> ’a) -> ’a = <fun>
# let posk x k = ...;;
val posk : int -> (bool -> ’a) -> ’a = <fun>
# let float_addk a b k = ...;;
val float_addk : float -> float -> (float -> ’a) -> ’a = <fun>
5. # let float_divk a b k = ...;;
val float_divk : float -> float -> (float -> ’a) -> ’a = <fun>
# let catk str1 str2 k = ...;;
val catk : string -> string -> (string -> ’a) -> ’a = <fun>
# let consk e l k = ...;;
val consk : ’a -> ’a list -> (’a list -> ’b) -> ’b = <fun>
# let eqk x y k = ...;;
val eqk : ’a -> ’a -> (bool -> ’b) -> ’b = <fun>
# let geqk x y k = ...;;
val geqk : ’a -> ’a -> (bool -> ’b) -> ’b = <fun>
# addk 1 1 report;;
Result: 2
- : unit = ()
# catk "hello " "world" (fun x -> x);;
- : string = "hello world"
# float_addk 1.0 1.0
(fun x -> float_divk x 2.0
(fun y -> (print_string "Result: ";print_float y;
print_newline())));;
Result: 1.
- : unit = ()
# geqk 2 1 (fun b -> (report (if b then 1 else 0)));;
Result: 1
- : unit = ()
4.2 Nesting Continuations
# let add3k a b c k =
addk a b (fun ab -> addk ab c k);;
val add3k : int -> int -> int -> (int -> ’a) -> ’a = <fun>
# add3k 1 2 3 report;;
Result: 6
- : unit = ()
6. We needed to add three numbers together, but addk itself only
adds two numbers. On line 2, we give the first call
to addk a function that saves the sum of a and b in the variable
ab. Then this function adds ab to c and passes its
result to the continuation k.
2. (5 pts) Using addk and mulk as helper functions, write a
function polyk, which takes on integer argument x
and “returns” x3 + x + 1. You may only use the addk and mulk
operators to do the arithmetic. The order of
evaluation of operations must be as follows: first compute x3,
then compute x + 1, and then compute x3 + x + 1.
# let poly x k = ...;;
val poly : int -> (int -> ’a) -> ’a = <fun>
# poly 2 report;;
Result: 11
- : unit = ()
3
3. (5 pts) Write a function composek, which takes as the first
two arguments two functions f and g and “returns”
g ◦ f (the composition of f with g). A function h is equal with g
◦ f if and only if h(x) = g(f(x)) for all elements
in the domain of f. You must assume that the functions f and g
are given in the continuation-passing style.
# let compose f g k = ...;;
val composek :
(’a -> (’b -> ’c) -> ’d) ->
(’b -> ’e -> ’c) -> ((’a -> ’e -> ’d) -> ’f) -> ’f = <fun>
7. # composek inck inck (fun h -> h 1 report);;
Result: 3
- : unit = ()
4.3 Transforming Recursive Functions
How do we write recursive programs in CPS? Consider the
following recursive function:
# let rec factorial n =
if n = 0 then 1 else n * factorial (n - 1);;
val factorial : int -> int = <fun>
# factorial 5;;
- : int = 120
We can rewrite this making each step of computation explicit as
follows:
# let rec factoriale n =
let b = n = 0 in
if b then 1
else let s = n - 1 in
let m = factoriale s in
n * m;;
val factoriale : int -> int = <fun>
# factoriale 5;;
- : int = 120
To put the function into full CPS, we must make factorial take
an additional argument, a continuation, to which the
result of the factorial function should be passed. When the
recursive call is made to factorial, instead of it returning a
result to build the next higher factorial, it needs to take a
8. continuation for building that next value from its result. In
addition, each intermediate computation must be converted so
that it also takes a continuation. Thus the code becomes:
# let rec factorialk n k =
eqk n 0
(fun b -> if b then k 1
else subk n 1
(fun s -> factorialk s
(fun m -> timesk n m k)));;
# factorialk 5 report;;
Result: 120
- : unit = ()
Notice that to make a recursive call, we needed to build an
intermediate continuation capturing all the work that must
be done after the recursive call returns and before we can return
the final result. If m is the result of the recursive call
in direct style (without continuations), then we need to build a
continuation to:
4
• take the recursive value: m
• build it to the final result: n * m
• pass it to the final continuation k
Notice that this is an extension of the ”nested continuation”
method.
In Problems 4 through 6 you are asked to first write a function
9. in direct style and then transform the code into
continuation-passing style. When writing functions in
continuation-passing style, all uses of functions need to take a
continuation as an argument. For example, if a problem asks
you to write a function partition, then you should
define partition in direct style and partitionk in continuation-
passing style. All uses of primitive operations
(e.g. +, -, *, >=, =) should use the corresponding functions
defined in Problem 1. If you need to make use of
primitive operations not covered in Problem 1, you should
include a definition of the corresponding version that takes
a continuation as an additional argument, as in Problem 1. In
Problem 5 and 6, there must be no use of list library
functions.
4. (6 pts total)
a. (2 pts) Write a function inverse square series, which takes an
integer n, and computes the (partial)
series 1 + 1
4
+ 1
9
+ . . . + 1
n2
and returns the result. If n ≤ 0, then return 0.
# let rec inverse_square_series n = ...;;
val inverse_square_series : int -> float = <fun>
# inverse_square_series 10;;
- : float = 2.92896825396825378
10. b. (4 pts) Write the function inverse square series which is the
CPS transformation of the code you
wrote in part a.
# let rec inverse_square_seriesk n k = ...;;
val inverse_square_seriesk : int -> (float -> ’a) -> ’a = <fun>
# inverse_square_seriesk 10 (fun x -> x);;
- : float = 2.92896825396825378
5. (8 pts total)
a. (2 pts) Write a function rev map which takes a function f (of
type ’a -> ’b) and a list l (of type ’a
list). If the list l has the form [a1; a2; . . . ; an], then rev map
applies f on an, then on an−1, then . . . ,
then on a1 and then builds the list [f(a1); . . . ; f(an)] with the
results returned by f. The function f may
have side-effects (e.g. report). There must be no use of list
library functions.
# let rec rev_map f l = ...;;
val rev_map : (’a -> ’b) -> ’a list -> ’b list = <fun>
# rev_map (fun x -> print_int x; x + 1) [1;2;3;4;5];;
54321- : int list = [2; 3; 4; 5; 6]
b. (6 pts) Write the function rev mapk that is the CPS
transformation of the code you wrote in part a. You
must assume that the function f is also transformed in
continuation-passing style, that is, the type of f is not
’a -> ’b, but ’a -> (’b -> ’c) -> ’c.
# let rec rev_mapk f l k = ...;;
val rev_mapk :
(’a -> (’b -> ’c) -> ’c) -> ’a list -> (’b list -> ’c) -> ’c = <fun>
# let print_intk i k = k (print_int i);;
val print_intk : int -> (unit -> ’a) -> ’a = <fun>
# rev_mapk (fun x -> fun k -> print_intk x (fun t -> inck x k))
11. [1;2;3;4;5] (fun x -> x);;
54321- : int list = [2; 3; 4; 5; 6]
5
6. (8 pts total)
a. (2 pts) Write a function partition which takes a list l (of type
’a list), and a predicate p (of type
’a -> bool), and returns a pair of lists (l1, l2) where l1 contains
all the elements in l satisfying p, and l2
contains all the elements in l not satisfying p. The order of the
elements in l1 and l2 is the order in l. There
must be no use of list library functions.
# let rec partition l p = ...;;
val partition : ’a list -> (’a -> bool) -> ’a list * ’a list = <fun>
# partition [1;2;3;4;5] (fun x -> x >= 3);;
- : int list * int list = ([3; 4; 5], [1; 2])
b. (6 pts) Write a function partitionk which is the CPS
transformation of the code you wrote in part a. You
must assume that the predicate p is also transformed in
continuation-passing style, that is, its type is not ’a
-> bool, but ’a -> (bool -> ’b) -> ’b.
# let rec let rec partitionk l p k = ...;;
val partitionk :
’a list -> (’a -> (bool -> ’b) -> ’b) -> (’a list * ’a list -> ’b)
-> ’b = <fun>
# partitionk [1;2;3;4;5] (fun x -> fun k -> geqk x 3 k) (fun x ->
x);;
12. - : int list * int list = ([3; 4; 5], [1; 2])
4.4 Using Continuations to Alter Control Flow
As we have seen in the previous sections, continuations allow
us a way of explicitly stating the order of events, and
in particular, what happens next. We can use this abilty to
increase our flexibility over the control of the flow of
execution (referred to as control flow). If we build and keep at
our access several different continuations, then we have
the ability to choose among them which one to use in moving
forward, thereby altering our flow of execution. You are
all familiar with using an if-then-else as a control flow
construct to enable the program to dynamically choose between
two different execution paths going forward.
Another useful control flow construct is that of raising and
handling exceptions. In class, we gave an example of
how we can use continuations to abandon the current execution
path and roll back to an earlier point to continue with
a different path of execution from that point. This method
involves keeping track of two continuations at the same
time: a primary one that handles “normal” control flow, and one
that remembers the point to roll back to when an
exceptional case turns up. As in regular continuation-passing
style, the primary continuation should be continuously
updated; however, the exception continuation remains the same.
The exception continuation is then passed the control
flow (by being called) when an exceptional state comes up, and
the primary continuation is used otherwise.
7. (8 pts) Write a function findk which takes a list l, a predicate
p, a normal continuation (of type ’a -> ’b),
and an exception continuation (of type unit -> ’b), and searches
for the first element in l satisfying p. If
there is such an element, it calls the normal continuation with
the said element; otherwise, it calls the exception
13. continuation with the unit (“()”). Your definition must be in
continuation-passing style, and must follow the same
restrictions about calling primitives as the previous section’s
problems. (For this problem, you will receive no
points for the direct style definition of find, though writing it
may be helpful when converting it to continuation-
passing style.)
# let rec findk l p normalk exceptionk = ...;;
val findk :
’a list -> (’a -> (bool -> ’b) -> ’b) -> (’a -> ’b) -> (unit -> ’b)
-> ’b = <fun>
# findk [1;2;3;4;5] (fun x -> fun k -> eqk x 3 k)
(fun x -> x) (fun x -> print_string "element not found"; -1);;
6
- : int = 3
# findk [1;2;3;4;5] (fun x -> fun k -> eqk x 6 k)
(fun x -> x) (fun x -> print_string "element not found"; -1);;
element not found- : int = -1
4.5 Extra Credit
8. (8 pts)
Write the function appk which takes a list l of functions in
continuation-passing style (of type ’a -> (’a ->
’b) -> ’b), an initial value x (of type ’a) and a continuation k. If
the list l is of the form [f1; . . . ; fn], then
appk evaluates f1 (f2 (. . . (fn x) . . .)) and passes the result to
k. Intuitively, it evaluates fn on x, then fn−1 on
14. the result, then fn−2 on the second result, and so on. Your
definition must be in continuation-passing style.
# let rec appk l x k = ...;
val appk : (’a -> (’a -> ’b) -> ’b) list -> ’a -> (’a -> ’b) -> ’b =
<fun>
# appk [inck;inck;inck] 0 (fun x -> x);;
- : int = 3
7
HW 4 – CSP Transformation; Working with
Mathematical Specifications
CS 421 – Fall 2013
Revision 1.0
Assigned Wednesday, September 18, 2013
Due Wednesday, September 25, 2013, 19:59pm
Extension 48 hours (20% penalty)
1 Change Log
1.0 Initial Release.
2 Objectives and Background
The purpose of this HW is to help your understanding of:
• The basic CSP transformation algorithm
• How to use a formal mathematically recursive definition
3 Turn-In Procedure
Using your favorite tool(s), you should put your solution in a
15. file named hw4.pdf (the same name as this file has
on the website). If you have problems generating a pdf, please
seek help from the course staff. Your answers to the
following questions are to be submitted electronically via the
handin script as though an MP. This assignment is
named hw4.
4 Background and Definitions
Throughout this HW, we will be working with a (very) simple
functional language. It is a fragment of MicorML (a
frgament of SML, an OCaml-like language), and the seed of the
language that we will be using in MPs throughout
the rest of this semester. Using a mix of MicroML concrete
syntax (expression constructs as you would type them
in MicroML’s top-level loop) and recursive mathematical
functions, we will describe below the algorithm for CSP
transformation for this fragment. You should compare this
formal definition with the description given on examples in
class.
The language fragment we will work with in this assignment is
given by the following Context Free Grammar:
e → c | v | e⊕e
| if e then e else e
| fn v => ; | e e
The symbol e ranges recursively over all expressions in
MicroML, c ranges over constants, v ranges over program
variables, and ⊕ ranges over infixed binary primitive
operations. The MicroML construct fn v=> e corresponds the
OCaml’s construct fun v-> e. This language will expand over
the course of the semester.
1
16. Mathematically we represent CPS transformation by the
functions [[e]]κ, which calculates the CPS form of an
expression e when passed the continuation κ. The symbol κ does
not represent a programming language variable, but
rather a complex expression describing the current continuation
for e.
The defining equations of this function are given below. Recall
that when transforming a function into CPS, it is
necessary to expand the arguments to the function to include
one that is for passing the continuation to it. We will use
κ to represent a continuation that has already been calculated or
given to us, and k, ki, k′ etc as the name of variables
that can be assigned continuations. We will use v, vi, v′ etc for
the ordinary variables in our program.
By v being fresh for an expression e, we mean that v needs to be
some variable that is NOT in e. In MP5, you will
implement a function for selecting one, but here you are free to
choose a name as you please, subject to being different
from all the other names that have already been used.
• The CPS transformation of a variable or constant expression
just applies the continuation to the variable or
constant, since during execution, when this point in the code is
reached, both variables and constants are already
fully evaluated (except for being looked up).
[[v]]κ = κ v
[[c]]κ = κ c
Example: [[x]](FUN y -> report y) = (FUN y -> report y) x This
may be read as “load reg-
17. ister y with the value for x, then do a procedure call to report”.
• The CPS transformation for a binary operator mirrors its
evaluation order. It first evaluates its first argument
then its second before evaluating the binary operator applied to
those two values. We create a new continuation
that takes the result of the first argument, e1, binds it to v1 then
evaluates the second argument, e2, and binds
that result to v2. As a last step it applies the current
continuation to the result of v1 ⊕v2. This is formalized in
the following rule:
[[e1 ⊕e2]]κ = [[e1]]FUN v1 -> [[e2]]FUN v2 -> κ (v1 ⊕v2)
Where
v1 is fresh for e1, e2, and κ
v2 is fresh for e1, e2, κ, and v1
Example: [[x + 1]](FUN w -> report w)
= [[x]](FUN y -> [[1]](FUN z -> (FUN w -> report w) (y + z)))
= [[x]](FUN y -> ((FUN z -> (FUN w -> report w) (y + z)) 1))
= (FUN y -> ((FUN z -> (FUN w -> report w) (y + z)) 1)) x
• Each CPS transformation should make explicit the order of
evaluation of each subexpression. For if-then-else
expressions, the first thing to be done is to evaluate the boolean
guard. The resulting boolean value needs to
be passed to an if-then-else that will choose a branch. When the
boolean value is true, we need to evaluate
the transformed then-branch, which will pass its value to the
final continuation for the if-then-else expression.
Similarly, when the boolean value is false we need to evaluate
the transformed else-branch, which will pass its
value to the final continuation for the if-then-else expression.
To accomplish this, we recursively CPS-transform
the boolean guard e1 with the continuation with a formal
18. parameter v that is fresh for the then branch e2, the
else branch e3 and the final continuation κ, where, based on the
value of v, the continuation chooses either
the CPS-transform of e2 with the original continuation κ, or the
CPS-transform of e3, again with the original
continuation κ.
[[if e1 then e2 else e3]]κ = [[e1]]FUN v -> IF v THEN [[e2]]κ
ELSE [[e3]]κ
Where v is fresh for e2, e3, and κ
2
With FUN v -> IF v THEN [[e2]]κ ELSE [[e3]]κ we are creating
a new continutation from our old. This
is not a function at the level of expressions, but rather at the
level of continuations, hence the use of a different,
albeit related, syntax.
Example:
[[if x > 0 then 2 else 3]](FUN w -> report w)
= [[x > 0]](FUN y -> IF y THEN [[2]](FUN w -> report w)
ELSE [[3]](FUN w -> report w))
= (FUN y -> IF y THEN [[2]](FUN w -> report w) ELSE
[[3]](FUN w -> report w)) (x > 0)
= (FUN y -> IF y THEN ((FUN w -> report w) 2) ELSE ((FUN
w -> report w) 3)) (x > 0)
• A function expression by itself does not get evaluated (well, it
gets turned into a closure), so it needs to be
handed to the continuation directly, except that, when it
eventually gets applied, it will need to additionally
take a continuation as another argument, and its body will need
19. to have been transformed with respect to this
additional argument. Therefore, we need to choose a new
continuation variable k to be the formal parameter
for passing a continuation into the function. Then, we need to
transform the body with k as its continuation,
and put it inside a continuation function with the same original
formal parameter together with k. The original
continuation κ is then applied to the result.
[[fn x => e]]κ = κ (FN x k -> [[e]]k) Where k is new (fresh for
κ)
Notice that we are not yet evaluating anything, so (FN x k ->
[[e]]k) is a CPS function expression, not
actually a closure.
Example:
[[fn x => x + 1]](FUN w -> report w)
= (FUN w -> report w) (FN x k -> (FUN y -> ((FUN z -> k (y +
z)) 1)) x)
• The CPS transformation for application mirrors its evaluation
order. In MicroML, we will uniformly use left-to-
right evaluation. Therefore, to evaluate an application, first
evaluate the function, e1, to a closure, then evaluate
e2 to a value to which that closure is applied. We create a new
continuation that takes the result of e1 and binds
it to v1, then evaluates e2 and binds it to v2. Finally, v1 is
applied to v2 and, since the CPS transformation makes
all functions take a continuation, it is also applied to the current
continuation κ. This rule is formalized by:
[[e1 e2]]κ = [[e1]](FUN v1 -> [[e2]](FUN v2 -> v1 v2 κ))
Where
v1 is fresh for e2 and κ
v2 is fresh for v1 and κ
20. Example: [[(fn x => x + 1) 2]](FUN w -> report w)
= [[(fn x => x + 1)]](FUN y -> [[2]](FUN z -> y z (FUN w ->
report w)))
= (FUN y -> [[2]](FUN z -> y z (FUN w -> report w)))
(FN x k -> (FUN a -> ((FUN b -> k (a + b)) 1)) x)
= (FUN y -> ((FUN z -> y z (FUN w -> report w)) 2))
(FN x k -> (FUN a -> ((FUN b -> k (a + b)) 1)) x)
5 Problem
1. (35 pts) Compute the following CPS transformation. All parts
should be transformed completely.
[[fn f => fn x => if x > 0 then f x else f ((-1) * x)]](FUN w ->
report w)
3