Thursday, March 25, 2010

Student B goes to the student center to get some tutoring.

“I'm not doing so well in my intro to computer science course. I just took a quiz and didn't finish it. This may sound paranoid, but there's a blog that seems to be talking about the problems I'm having. They were discussing part of the program in the quiz.”
mquander wrote:
Where did student B get the idea that he was supposed to evaluate it?
Blaise Pascal wrote:
He didn't need to evaluate it to answer the quiz questions, and he wasn't asked to evaluate it.
Alexey wrote:
He was expected to ignore the evaluation path of the sanity check form.
“Anyway,”Student B continued, “I don't understand what they are talking about. What else would you do with a program but evaluate it? Isn't that what programs are for? They're telling what not to do, but not what I ought to be doing instead. Can you help me?“

How should the tutor approach this? What should he or she say?

Tuesday, March 23, 2010

Pop quiz fallout

At the end of the two hours, Student B was still furiously scribbling away. He had accumulated a suprising amount of paper around himself. The professor came over to talk to him.
“What seems to be the problem?”
‘I don't have enough time!’
“It isn't that hard a quiz, you know. Every other student has finished. What exactly are you doing?”
‘This part, right here.’
Student B pointed to this line in the quiz:
(= (- (fib 100) (fib 99)) (fib 98))
‘I decided to evaluate this from right to left because you said that order doesn't matter. I'm still working on the (fib 98) subexpression. I think that (fib 99) and (fib 100) are going to take even longer. I can't see how anyone could get past this. I'm getting discouraged. I don't even think a computer could solve this in two hours.’

This is a key question: What, if anything, is Student B doing wrong?

Monday, March 22, 2010

A pop quiz

Partway through the term the professor decides to give the students a pop quiz.

“The quiz is contained in the file quiz.scm which you can find in the usual location. For those of you that prefer hardcopy, I have a printout for you.

“I know that some of you” (and here the professor glared at Student A) “seem to have issues with the way I present code, so you should assume that this code is to be entered into an unmodified R5RS Scheme interpreter.

“You have two hours.

;; Question 1:
;; What does (fib 4) evaluate to?

;; Question 2:
;; What is domain and range of the EVEN? procedure?

;; Question 3:
;; How many top-level forms are in this file?

;; Question 4:
;; Make a list of the free variables in this file.

(define (even? x)
  (or (zero? x)
      (odd? (- x 1))))

(define (odd? x)
  (and (not (zero? x))
       (even? (- x 1))))

(define (fib n)
  (if (< n 2)
      (+ (fib (- n 1)) 
         (fib (- n 2)))))

;; Sanity check
(= (- (fib 100) (fib 99)) (fib 98))

;; Question 5:
;; Are either of the following two forms an infinite loop?
;; Make an informal argument to support your answer.

(define (loop1 n)
  (if (positive? n)
      (loop1 (- n 1))
      (loop1 n)))

(define (loop2 n)
  (if (negative? n)
      (loop2 (+ n 1))
Meta-questions for readers of this blog:
  1. Is this a reasonable quiz? If it is too difficult for first-year students, is there a year at which it would be appropriate or even too simple?
  2. Is two hours enough time to answer the questions?
  3. Are there any loopholes that will allow Student A to object?

Monday, March 1, 2010


Pascal Costanza wrote:
Student A's statement is self-contradictory. You can only meaningfully talk about making something incorrect when you have a correct meaning in mind in the first place. So for Student A, the program has a meaning, even if he/she denies that.
Student A might argue: “The professor is the one that is assuming there is a correct meaning. I'm simply pointing out that whatever meaning he might have in mind could be wrong.”

Student C's description of the program is circular. He/she states that FACTORIAL implements factorial, which doesn't say much at all - it's both times the same word, both times the same string of characters (only once in upper case and once in lower case).
Student C replies: “Oh, I meant that the program named FACTORIAL implements the mathematical function ‘factorial’.” (This is a beginner's course, so we shouldn't make him work too hard.)

Alexey wrote:
I would say to student A: That answer is useless. Of course someone could shadow * or IF; but what did the author of the program mean when they wrote it?
Student A replies: “How should I know? I can't read minds!”

What do we say to Student A?

I would say to student B: OK, that's what the program does, for a few trials with a few arguments, but what it does is beside the point. The question was: what does the program mean?
Student B asks: So what is the difference between what it “means” and what it “does”? Doesn't “(+ 2 3)” mean 5? Doesn't “(factorial 4)” mean 24?