Question: I need a 2 page study guide for this test. Our hint is the following topics will be covered and anything in modules 1, 2,
I need a 2 page study guide for this test. Our hint is the following topics will be covered and anything in modules 1, 2, 3. There will be a lot of writing code for this test.
The Test covers Modules 13. There are 10 multiple choice questions, 6 short-answer questions, and 7 work-out problems.
The following topics are covered:
phases of software development and binding times
compilation vs. interpretation
delayed linking
ML types, functions, operators, and structured types (tuples, lists, etc.), list processing, pattern matching of parameters
types and polymorphism
unions in C++ and endian-ness
The book is Modern Programming languages, a practical solution, second edition, by adam brooks webber
Module 1: Languages, Paradigms, and Systems (Chapters 1, 4, 24) Module 2: Types (Chapters 56) Module 3: Functions and Polymorphism (Chapters 78)
Module 1
Do all parts of problems 2 and 4 from Chapter 4, plus the following problem.
A. Indicate the binding times for each of the following for a typical statically-typed, statically scoped language (C, C++, C#, Java):
Which built-in functions are to be provided by the standard library that accompanies the language development system
The variable declaration corresponding to a particular use of the variable (For example, in the statement x = a;, when is this use of a bound to the appropriate definition of the variable a elsewhere in the code?)
The maximum length allowed for a string literal
The address in memory of a particular library function
Module 2
Do the following 12 problems from Chapter 5 in the book:
311, 1315
For #14, only check divisors up to the square root of the number being tested (you don't have to use Math.sqrt to solve this! Remember, if x < sqrt(y), then x*x < y).
You should only need hd, tl, ::, [ ], and explode, as far as built-in functions go.
Do not use any function call preceded by "List.".
Do the following problems from Chapter 6 in the book, plus the additional problem below:
1, 2, 4 (part g should read X := X + Y;)
Note for #2, you are given a set in each part of the problem. Write the ML type constructor that corresponds to that set. The curly braces are not ML recordsthey're just sets.
Additional problem:
Write a short C/C++ program that reads a 64-bit machine instruction as a hex integer and extracts the values for its components from certain bits, specified left-to-right, as follows:
Bits 0-4 code (the instruction code) Bits 5-8 ladrm (left address mode) Bits 9-12 radrm (right address mode) Bits 13-19 si (short immediate) Bits 20-25 lreg (left register) Bits 26-31 rreg (right register) Bits 32-63 li (long immediate)
You will read 16 hexadecimal digits, such as 08800080000004D2, which represent the numeric value of the 64 bits to be analyzed. The output for this input string should be:
Instruction: 08800080000004D2
rreg = 0 lreg = 2 si = 0 radrm = 0 ladrm = 1 code = 1 li = 1234
Note that the output numbers are base 10, not hexadecimal. To get full credit for this program, youll need to use a union with a nested bit-field structure in C/C++(use no bitwise operators). If youre using an Intel machine, remember that it is a little-endian machine, which means youll have to reverse the order of the bit-field declarations to extract the correct values. Use the following input strings to test your program:
08800080000004D2 E05000000000008E 1140408300000000 5008000300000000 E800000000000020
Here is a main program to use:
int main( ) { unsigned long long x; while (cin >> hex >> x) { cout << "Instruction: " << hex << x << endl; cout << dec; // Convert back to decimal readStuff(x); cout << endl; } }
Module 3
Do the following problems:
Chapter 7: 2,3,4,5,7
(Note: for #5, do not use Math.pow or write your own power function see hint below; 7 requires knowing 6, which can be found in Chapter 12; do not use features we havent covered yet, like List.partition and let rec).
Hint for #5: Any polynomial can be rewritten by factoring x out of each term as follows: 3x37x2+5x3=3+x(5+x(7+x(3)))
Hint for #7: Use the code for quick sort in Chapter 12 as a starting point.
Extra Problems for Chapter 7:
A: What does the following function, g, do?
fun g stuff = let fun f (nil,y) = [y] | f (x::rest,y) = f (rest,y) @ f (rest,x::y) in f (stuff,nil) end;
B: (For 2018, add 3 points) Write a function, f2n (f,n,x), that computes applying f n times to x. For example, given the function p:
fun p = p+1;
then f2n (p,3,1) computes f(f(f(1))) = 1+(1+(1+1)) = 4 (adding 1 to 1 3 times).
Chapter 8: 3, 5, 6ab
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
