The War of Languages
-
Is you name on the test?
-
Yes it is
-
It is, yes.
-
What does the following code print? _____________________________
if("twelve" == "ten plus two") {
print "Yes";
}
else {
print "No\n";
}
-
In WWII, who declared war on Germany first?
-
U.S.
-
Canada
-
Mexico
-
Write this is Lisp: 5 * 4 - 3 / (2 + 1)
-
(Yes/No) Can an assocative array in Perl hold as an element a normal array?
For example, can this program fragment work?
$a[0] = 1;
$a[1] = 12;
$b{"array"} = @a;
-
When was the last time Italy won a war?
-
WWII
-
WWI
-
The last time they attacked Ethiopia
-
Sometime during the late Roman Empire
-
Consider an association list of length N. What is the time needed
to look up a key value from this list
-
O(1)
-
O(log(n))
-
O(n)
-
O(n * log(n))
-
O(n * n)
-
Consider an associative array with N elements. What isthe time needed
to look up a key value from this list?
-
O(1)
-
O(log(n))
-
O(n)
-
O(n * log (n))
-
O(n * n)
-
In your own words, what happens when you run this program?
#!/usr/bin/perl -w
$a = 3;
while ($a > 2) {
$a++;
}
-
In your own words, what happens when you run this program?
(define (loop x)
(if (> x 2)
x
(loop (+ 1 x))
)
)
(loop 3)
-
Which general lost more battles than he won?
-
Napoleon Bonaparte
-
G. Washington
-
Attila the Hun
-
Julius Caesar
-
What does the code below mean in Lisp?
(fred)
-
The literal string "fred".
-
The variable 'fred'
-
Call the function 'fred'.
-
Run the program 'fred'.
-
What does the code below mean in Perl? Note that the quotes are backtics
(`) and not normal single quotes (').
$a = `fred`;
-
Assign to $a the literal string "fred".
-
Assign to $a the contents of the variable 'fred'
-
Assign to $a the return value of the function 'fred'.
-
Assign to $a the output of the program 'fred'.
-
How man elements in the list? If I call length on this list, what
will it say? ____________
'(fred (barney wilma) pebbles (bambam (stick stone)))
-
Associate the tactic and the war
March toward the machine gun nest
WWII
Stab with the pike
The hundred years war
Stay in the castle. Taunt. Repeat
The Pelipaniasian war
Drop a bomb from 40,000 ft.
WWI
-
(2 points) Write me a program in Lisp that counts from 1 .. 10.
-
(2 points) Write me a program in Perl that counts from 1 .. 10.
-
(4 points) Write me a program in Lisp that takes as input a list.
Return '1' if the list is in order, 0 otherwise. The null list should
return '1'. Examples: (check '(2 4 8 10)) should return '1'.
(check '(1 4 7 2 9)) should return '0'.
-
(4 points) Write me a Perl program that checks to see if a word is spelled
correctly. A word is spelled correctly if it's listed in /usr/dict/words,
otherwise it's spelled wrong.