Next | Titel | Inhalt | Vorwort | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Appendix | @ CAAD | Teachers |
KAPITEL
1
Einleitung,
theoretische und praktische Bedeutung
Lisp
I - einfache Funktionen
The emphasis of this course will be on principles. All exercises have the purpose of illustrating one particular aspect of design computing.
In order to effectively use a computer system, some basic concepts need to be understood. A computer system is made up of a number of physical components, collectively known as hardware. Hardware is controlled and directed by a set of instructions known as software or computer programs. Software programs can be obtained from various sources and can be installed on various machines or hardware.
An operating system is a collection of software programs designed to work on specific hardware configuration. When you log into your account, you interact with the operating system. At present, in the Space and CAD labs, we have Sun Sparc Stations and Silicon Graphics Indys running operating systems called UNIX and IRIX respectively. In order to make working with computers easier, a set of programs may be installed on top of the operating systems, known as window managers, e.g., OpenWindows on our Sun machines and IndigoMagic on the SGIs. As a result, each command or process you start is displayed in a rectangular region on the screen, called a window. Windows can be closed temporarily in which case they will collapse into an icon, or windows can be quit if a process is finished and no longer needed. Commands can be entered by typing them in at the keyboard or by a series of movement and clicking actions with a mouse. Some useful commands and actions are explained in Appendix A.
In some cases, you can enter a command and its result will be some information displayed on the screen, e.g., if you type date, the current date and time are displayed. Other commands start a process in which you can generate additional information that can be stored and retrieved later. For example, an editor program lets you create text files which can be stored and manipulated. Thus there are computer programs and data you generate with such programs, both are referred to as files and may be stored separately with different file names. To work on a data file, you need to start the program which created that file, and then load in that data file for further processing.
Program and data files are stored in directories and subdirectories organized in a hierarchical fashion. You can move up and down a file system using operating system commands like cd, and delete, rename, or copy files using other commands like rm, mv, cp (see Appendix A for further details).
A valid LISP statement is expressed as a list enclosed in parentheses. A statement in LISP can be executed directly by an interpreter program and results displayed on the screen. Thus two steps are involved in this process: writing LISP expressions and passing them to the LISP interpreter for evaluation.
Start AutoCAD by typing acad in any shell window. Select a new drawing option and enter any name for the drawing file name. Once AutoCAD is properly loaded, you will see a graphic window with a screen menu and some pull-down menus at the top. At the bottom, you see a prompt command: in a small window. Here is where you can enter LISP statements for evaluation. If you hit F1 key, a bigger window comes to the foreground on your screen. This is the same command: prompt window which was only partially visible earlier. With this larger window available, proceed with the following sections.
When you are finished with the following sections, remember to quit AutoCAD, exit OpenWindows, and log out.
Examples: Enter the following expressions and check the results.
(+ 23 34) => 57 (+ 3.0 12) => 15.0 (- 30.6 25) => (- 25 10) => (* 12 3) => (* 12 3.0) => (/ 12 5) => (/ 12 5.0) =>Try these operations with more than two numbers as arguments.
(setq a_float 23.5678) => 23.5678 (setq an_integer -23567) => (setq a_list '(a b c)) =>A variable may be evaluated by simply passing it to the interpreter. In AutoLisp, you can retrieve the value of a variable by typing exclamation mark (!), followed by the variable name, without any spaces between the two. For example:
!a_float => 23.5678 !an_integer => !a_list =>The examples above should make it clear that once a variable is assigned some value, that variable can be used whenever the value it refers to is needed.
(car '(a b c)) => A (cdr '(a b c)) => (B C) (car '((3 b) c)) => (cdr '((3 b) c)) => (cdr '(a)) =>What happens if you evaluate the following expressions?
(setq a_list '((23.9 ab)(apples oranges cherries) (dogs cats cows))) => (car (car a_list)) => (cdr (cdr a_list)) => (car (cdr a_list)) => (cdr (car a_list)) =>When a number of list operations involving car and cdr are needed, it is possible to combine them into compound operations by joining ar (from car) and dr (from cdr). For example, the previous four examples could be rewritten as follows:
(caar a_list) => (cddr a_list) => (cadr a_list) => (cdar a_list) =>
Example: (setq a_variable nil) will set up a symbol a_variable that does not have any value assigned to it. Since it is declared, it can be evaluated and the result of evaluation will be nil.
It is also possible to have lists which are empty, i.e. they do not contain any atoms, just left and right parentheses. These are known as null lists.
Example: (setq an_empty_list '()) will set up a null list. See what happens if you use car or cdr on such a list.
2. Create a directory called u01 (not U01) and make it the working directory.
3. Copy a file named 01_name.dwg, from the directory: /homes5/prog/ausgabe, into your current directory and store it as 01_name.dwg where name is your name. Remember: Do not use capital letters in any directory or file names.
4. Start the AutoCAD program by typing acad in a Shell window. Select the Open option from the File pulldown menu, then the 01_name file from the list in the Open Drawing window that appears. Click the O.K. button. This will load in your data file.
5. Write your name with the command DTEXT in AutoCAD. When prompted for a Startpoint, enter 0,0. Enter 1.0 when prompted for the Height.
6. Enter the command SAVE. The Save Drawing As window will appear. Confirm that the file should be saved under its original name (i.e., updated) by clicking the O.K. button.
7. Enter END at the command prompt to stop the AutoCAD program.
8. Copy your file 01_name.dwg to the directory: /homes5/prog/abgabe.
2. Restart AutoCAD and a new drawing file. Bring the AutoCAD text window into the foreground by hitting the F1 key.
3. Enter each of the following expressions at the AutoCAD command: prompt.
(+ 3 4.0 8 99.99) => (- 234 34 89 10) => (* 10.0 2 5 6.0) => (/ 335 12 8 9.9) => (car (cdr '((ab cd) (ef gh ij) (kl mn)))) => (cdr (car '((ab cd) (ef gh ij) (kl mn)))) => (setq a_list '((ab cd) (ef gh ij) (kl mn))) => (car (cdr a_list)) => (cdr (car a_list)) => !a_list => (setq num1 25) => (setq num2 10) => (+ num1 num1 num2 num2) => (* num1 num2) => (/ num2 num1) =>4. Select the entire AutoCAD text window by clicking at the top of the window with the left mouse button and then clicking at the bottom of the window with middle mouse button. This should make the entire text grey out.
5. Copy the selected text by hitting the Copy function key on the keyboard. This puts the selected text in computer memory.
6. Move the mouse over to the text editor window and hit the Paste function key on the keyboard.
7. Use the right mouse button to open the File menu of the text window, select the Store as New File... option, complete the path name indicated next to Dirctory: by adding u01. Type 01_name.txt (where name is your name) on the line next to File:. Complete the proceedure by clicking on the Store as New File button.
8. Quit AutoCAD. Copy the file 01_name.txt to directory /homes5/prog/abgabe.
9. Exit OpenWindows and log out of your account.
Next | Titel | Inhalt | Vorwort | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Appendix | @ CAAD | Teachers |
This website has been archived and is no longer maintained.