CMSC 471/671 Artificial Intelligence Fall 2000

CMSC 471/671 Artificial Intelligence Fall 2000

<p>CMSC 471/671 Artificial Intelligence Fall 2000 Section 0101 TuTh 5:30 - 6:45pm MP103</p><p>Answer Keys for Homework 1</p><p>1. Which of the following S-expressions are atoms? Which of them are lists? A, “this is foo”, (), T, (1 2 3), 25, (sqrt 36), NIL Atoms: A, “this is foo”, (), T, 25, NIL List: (), (1 2 3), (sqrt 36), NIL 2. What will be returned when evaluating each of the following S-expressions? a) (mapcar #’= L1 (reverse L1)), where L1 has been assigned value (1 2 3) (NIL T NIL) b) (set y x), where x has been assigned value 5 but y has not Error message: y has not been assigned value c) (nth 1 ‘(a b c)) B 3. Using recursive definition to define a LISP function (union L1 L2) that returns the union of two sets represented as lists L1 and L2. Both L1 and L2 can be empty sets. (defun union (L1 L2) (cond ((null L1) L2) ((not (member (car L1) L2)) (cons (car L1) L2)) (t (union (cdr L1) L2)))) 4. Write a function (average L) that iteratively computes the average of a list of real numbers in list L. You may assume that L is non-empty. (defun average (L) (setq y 0) (dolist (x L) (setq y (+ x y))) (/ y (length L)))</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us