EECS 368 / Spring 2020 Take Home Exam Initials:
EECS 368 Final
Take Home Exam:
Due 5:00pm, Friday May 15th 2020
Name: KUID:
Each student is expected to complete the exam individually using only course notes, the EECS 368 lectures, and technical literature, and without aid from other outside sources. You can use a JavaScript and/or a Haskell interpreter, if you wish.
I assert that I have neither provided help nor accepted help from another student in completing this exam. As such, the work herein is mine and mine alone.
Signature Date
⃝c Andrew Gill, prepared for EECS 368, University of Kansas 1 of 6
EECS 368 / Spring 2020 Take Home Exam Initials:
1 True or False (1 point each)
Mark the True or False box next to each question. or Yes
or No
2
• Does JavaScript support IEEE numbers? ………………………. • Can a JavaScript programmer change the length of an array? . . . . . . . • Does JavaScript support recursion? …………………………… • Can JavaScript in a browser read any file from the local filesystem? . . • Is it possible to write an anonymous function in JavaScript? . . . . . . . . . • In Haskell, are all elements of a list the same type? ……………… • Are all data-based structures in Haskell mutable? ………………. • Can you have two-dimensional lists in Haskell? ………………….
Multiple choice (2 points each)
Multiple choices. Which is the most accurate answer? Clearly write your selection on the line or mark the box.
• In JavaScript, a number is .
A. an integer value, like Int in Java.
B. a floating point value.
C. a fundamental and unifying subatomic particle. D. a string that contains a number.
• When a JavaScript object is initialized with new, . A. a constructor is called with a fresh object.
B. another object is erased.
C. a random method is called.
D. a property of the object is called.
• Given the declaration var s = “Hello”, which statement is most accurate:
A. s is a string value. B. s is an array.
C. s contains an object. D. s is a function.
• In Haskell, getChar :: IO Char, when called, . A. reads a character from keyboard.
B. builds an effect.
C. writes a character.
D. waits for input.
⃝c Andrew Gill, prepared for EECS 368, University of Kansas
2 of 6
True False
EECS 368 / Spring 2020 Take Home Exam Initials:
3 Writing JavaScript (15 points)
Write a JavaScript function that, when called, outputs to the console a hollow square of stars. The size of the square should be given as an argument.
So, calling square(9), will give:
********* ** ** ** ** ** ** ** *********
You should use console.log(…). This function adds a newline automatically, so you should use an intermediate string in solution.
⃝c Andrew Gill, prepared for EECS 368, University of Kansas 3 of 6
EECS 368 / Spring 2020 Take Home Exam Initials:
4 Writing Haskell (15 points)
Write a Haskell function that, when called, outputs to the console a hollow square of stars. The size of the square should be given as an argument.
So, calling square 9, will give:
********* ** ** ** ** ** ** ** *********
You should use a sub-function to generate the output content, and then use putStr or putStrLn to write to the console.
⃝c Andrew Gill, prepared for EECS 368, University of Kansas 4 of 6
EECS 368 / Spring 2020 Take Home Exam Initials:
5 Monads and Effect (12 points)
Describe how Haskell handles effects like reading the keyboard, and writing to the screen. You can use examples.
How does Haskell chain effects together, to make a program? Include the type of at least one of the monadic binding operators, such as (>>=) or (>>), in your answer.
⃝c Andrew Gill, prepared for EECS 368, University of Kansas 5 of 6
EECS 368 / Spring 2020 Take Home Exam Initials:
6 General Questions (3 points each question)
• What is a significant difference between JavaScript and Haskell?
• What does (Int -> Bool) -> [Int] -> [Bool] mean in Haskell.
• What is the DOM used for in JavaScript?
• What is the difference between let and var in JavaScript.
⃝c Andrew Gill, prepared for EECS 368, University of Kansas
6 of 6