The basic unit of evaluation in LISP is an expression. An expression is a sentence in Lisp and it can be a value, a symbol, or a list. It is the basic unit which the LISP interpreter evaluates in one step.
What is a lambda expression?
A lambda expression has a list of parameters, and a body which consists of a sequence of expressions. The list of parameters defines the environment in which the expressions are to be evaluated. Lambda calculus, introduced by Alonzo Church in 1941, led to the development of LISP and functional programming. A lambda expression, explained below, is similar to the defun construct introduced in Kapitel 4. It is useful when you need to use a procedure in only one or very few places in a program and you do not want to define a special procedure by a unique name.
Every LISP expression that you enter from the keyboard is evaluated, and the result of evaluation process is returned. The AutoLisp environment also has a LISP interpreter- sometimes called an evaluator, and it works as follows:
In the examples presented so far, expressions are evaluated as they are passed to the interpreter. A series of expressions can be evaluated one after another one as in case of functions. This is a purely sequential control. In situations when we need to perform different actions depending on the context, a conditional control structure is needed. In LISP this can be expressed as if-then-else construct.
In this exercise, you will make use of conditional expressions to write a small interactive program. In order to get you started, a sample program is provided in which you will also see how to use three AutoLisp functions: getint, getreal, getpoint. These functions allow you to get input from a user which may be an integer or a floating-point number entered from the keyboard, or a point which may be entered as (x y z) coordinates from the keyboard or picked directly on screen with the mouse.
Your task is to write a program which does the following. It prompts the user to input four points using which a building outline is drawn. A user should be able to specify height for the building. Further, your program prompts the user for selection of a roof type where the choices are signified by an integer 1, 2 or 3. These choices correspond to the roof types shown in the following figure. In order to draw the gable or hip roofs, you will need to prompt the user for the height of the roof. Assume any other variable you may need for the geometry of the roof. The fourth roof type, Mansard, is optional.
You should write small functions first, testing various parts of what your program needs to do. Once you have them working properly, combine them into a final version.
In order to get started on your program, copy the file 06_name.lsp from directory /homes2/prog/ausgabe into your account. Load it into AutoCad and evaluate each function to see what it does. Then modify and add functions that you need for this exercise. Save your final version as 06_name.lsp and submit it by copying it in directory /homes2/prog/ausgabe.
Prog Content Vorwort ..1.. ..2.. ..3.. ..4.. ..5.. ..6.. ..7.. ..8.. ..9.. ..10.. ..11.. ..12.. ..13.. Appendix