Thursday 6/5/2008. 30 points.
http://www.cs.nyu.edu/courses/summer08/G22.3033-002/
(10 points) Add explicit type annotations to the following VBA module.
Function geometricMean(arr())
geometricMean = 1
For i = LBound(arr) To UBound(arr)
geometricMean = geometricMean * arr(i)
Next i
n = 1 + UBound(arr) - LBound(arr)
geometricMean = geometricMean ^ (1.0 / n)
End Function
Sub main()
Dim A(1)
A(0) = 1: A(1) = 2
Debug.Print geometricMean(A)
End Sub
(10 points) Consider the following excerpt of Perl's operator table.
Operator Arity Associativity Description
** 2 right exponentiation
* 2 left multiplication
= 2 right assignment
Fully parenthesize the following expression:
$x = $y = 3 ** 3 ** 3 * 2.
(4+3+3 = 10 points)