BABYL OPTIONS:
Version: 5
Labels:
Note:   This is the header of an rmail file.
Note:   If you are seeing it in rmail,
Note:    it means the file has no messages in it.

1,,
Received: from life.ai.mit.edu by altdorf.ai.mit.edu with SMTP
	(15.11/15.6) id AA13113; Fri, 11 Oct 91 18:07:04 edt
Return-Path: <joshua@athena.mit.edu>
Received: from Athena.MIT.EDU by life.ai.mit.edu (4.1/AI-4.10) id AA24282; Fri, 11 Oct 91 18:06:57 EDT
Received: from M34-501-13.MIT.EDU by Athena.MIT.EDU with SMTP
	id AA01409; Fri, 11 Oct 91 18:06:49 EDT
From: joshua@athena.mit.edu
Received: by m34-501-13.MIT.EDU (5.61/4.7) id AA25564; Fri, 11 Oct 91 17:21:12 -0400
Message-Id: <9110112121.AA25564@m34-501-13.MIT.EDU>
To: 6001-staff@ai.mit.edu
Subject: Instantiate
Date: Fri, 11 Oct 91 17:21:10 EDT

*** EOOH ***
Return-Path: <joshua@athena.mit.edu>
From: joshua@athena.mit.edu
To: 6001-staff@ai.mit.edu
Subject: Instantiate
Date: Fri, 11 Oct 91 17:21:10 EDT

Some students wrote an iterative version of the instantiate procedure in the
last problem set.  Here is a working copy...

(define (instantiate list1 list2)
  (define (iter list1 list2 answer)
    (if (null? list1)
        answer
        (if (list? (car list1))
            (iter (cdr list1)
		  list2
		  (append answer (list-ref list2 (cadar list1))))
	    (iter (cdr list1)
		  list2
		  (append answer (list (car list1)))))))
  (iter list1 list2 '() ))

                                         -Josh

