1 / 14

Intelligent Agents

Intelligent Agents. Lecture 3-2 October 14 th , 1999 CS250. Projects. What’s expected Project ideas. “Get Your Red-Hot Lists Here!”. Conses are pairs of pointers First pointer is the car Rest is the cdr Lists are conses in which: First pointer is the first element

sage
Download Presentation

Intelligent Agents

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intelligent Agents Lecture 3-2 October 14th, 1999 CS250 CS250: Intro to AI/Lisp

  2. Projects • What’s expected • Project ideas CS250: Intro to AI/Lisp

  3. “Get Your Red-Hot Lists Here!” • Conses are pairs of pointers • First pointer is the car • Rest is the cdr • Lists are conses in which: • First pointer is the first element • Second pointer is the rest of the list • No intermediate pointers makes last expensive USER(104): (last (list 'a 'b 'c)) (C) CS250: Intro to AI/Lisp

  4. nil d a nil b c Box & Pointer • Represent a cons graphically (list ‘a (list ‘b ‘c) ‘d) CS250: Intro to AI/Lisp

  5. eq • True if its arguments are the same, identical object; otherwise, returns false (eq 'a 'b) => false (eq 'a 'a) => true (eq 3 3) => true OR => false (eq 3 3.0) => false CS250: Intro to AI/Lisp

  6. More on eq • Crazy things can happen • Implementations can “collapse” constants (eq “Foo” “Foo”) could be TRUE or FALSE • If interpreted, it’s always FALSE • Question from last time: (eq ‘(a .b) ‘(a . b)) could be TRUE or FALSE (eq (cons ‘a ‘b) (cons ‘a ‘b)) is FALSE CS250: Intro to AI/Lisp

  7. eql • True of two objects, x and y, in the folowing cases: 1. If x and y are eq. 2. If x and y are both numbers of the same type and the same value. 3. If they are both characters that represent the same character. (eql 'a 'b) => false (eql 'a 'a) => true (eql 3 3) => true (eql 3 3.0) => false (eql 3.0 3.0) => true (eql #c(3 -4) #c(3 -4)) => true (eql #c(3 -4.0) #c(3 -4)) => false CS250: Intro to AI/Lisp

  8. eq vs. eql • eql tells whether two objects are conceptually the same • eq tells whether two objects are implementationally the same CS250: Intro to AI/Lisp

  9. = • Numeric comparisons USER(3): (= 3 3 3 3) T USER(4): (= 3 3.0 3 3 3) T USER(5): (= 2 3.0 3 3 3) NIL CS250: Intro to AI/Lisp

  10. Sequences • Sequences are ordered “sets” • Lists + vectors • Many useful functions: elt reverse map remove length nreverse some delete ... CS250: Intro to AI/Lisp

  11. Association lists • Easy lookup tables • Try this (setf nickname '(("Red Sox" . "Losers") ("Mets" . "Wannabes") ("Yankees" . "World champions"))) What is returned by: (assoc “Red Sox” nickname) CS250: Intro to AI/Lisp

  12. Keyword args • Keywords enable flexibility in arguments • Playing with args: • &rest • &optional • &key CS250: Intro to AI/Lisp

  13. The rest of the story • How does #’+ work? • How to handle an unknown number: • Use a list • Use rest • Testing for nil (defun any-nil-p (&rest all-values) (notevery #'null (mapcar #'null all-values))) CS250: Intro to AI/Lisp

  14. Optional parameters • Add an optional parameter with a default value ((lambda (a &optional (b 2)) (+ a (* b 3))) 4 5) ((lambda (a &optional (b 2)) (+ a (* b 3))) 4) CS250: Intro to AI/Lisp

More Related