Page 74 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 74

Introduction to Artificial Intelligence & Expert Systems




                    Notes
                                          Example 5:

                                   Objective: Write a program in LISP showing implementation of condition.
                                   Solution:
                                   Maximum of Two Numbers
                                   :->(defun maximum2 (a b) (cond ((>a b) a) (t b)))
                                   MAXIMUM2

                                   OUTPUT
                                   (maximum2 234 320)
                                   :-> 320

                                   Maximum of Three Numbers
                                   (defun maximum3(a b c)(cond((>a b)(cond((>a c)a)(t c)))((>b c)b)(t c)))
                                   MAXIMUM3
                                   OUTPUT
                                   (maximum3 20 30 25)

                                   :-> 30




                                      Task  Write a LISP program for login and password checking.

                                   Self Assessment


                                   State whether the following statements are true or false:
                                   13.  LISP is a language that is usually associated with the Functional Programming paradigm.
                                   14.  To define a procedure we use the special operator average.
                                   15.  The words you use for the parameters are arbitrary.
                                   16.  A procedure does have to have any parameters.


                                   4.5 Summary

                                       LISP programs are made up of expressions, which are lists or single atoms.
                                       Lists are made up of zero or more atoms or inner lists, separated by white space and
                                       surrounded by parentheses. A list can be empty.
                                       Atoms are multi-character symbols, like forward-paragraph, single character symbols
                                       like +, strings of characters between double quotation marks, or numbers.

                                       A number evaluates to itself.
                                       A string between double quotes also evaluates to itself.
                                       When you evaluate a symbol by itself, its value is returned.





          68                                LOVELY PROFESSIONAL UNIVERSITY
   69   70   71   72   73   74   75   76   77   78   79