. , , ,

,,,

- — ,

1

- , . , , . , .

; , 2 - . , , , .

- , . 3 , : "LISP" ( ), "Looking at LISP" ( ). - , : , , . , . .

1.1

:

- lists -

- symbols -

- strings -

- real numbers -

- integers -

- file descriptors -

- AutoCAD entity "names" - ""

- AutoCAD selection-sets -

- subrs (build-in functions) - ( )

- 16- -32768 +32767. . , .

. , :

2D points -

(X Y):

(3.400000 7.520000 )

- X, - Y.

3D points -

(X Y Z ):

(3.400000 7.520000 1.000000)

- X, -Y, -Z.

(, ) , .

1.2

. , . :

- , ; ; ; - ;

- - ;

- - , :

  • ( ); , .

  • (subrs); subr subr.

"Command:" , . "Command:" .

, :

n>

n - , . , n , . - (") ; n. , , n .

1.3

. : ; ASCII . :

- , : ( ) . ' " ;

- :

( ) ' " ; () ( )

- ;

- . , ;

- (subrs) . ;

- "+" "-". , -32768 +32767;

- , , , ".4" , "0.4". ,"5." , - "5.0". .. "" "", ;

- - , . , , (\) . :

\\ "\"

\e

\n

\r

\t

\nnn , - nnn

, :

(prompt "\nEnter first point: ")

- QUOTE. , 'foo (quote foo)

- , , . . ,

:This entire line is a comment

: -

(setq area (* pi r r )) :Compute area of circle

:

1.4

. ,

(moo ...)

, . , , , .

"moo" : . ("...") , . , .

"moo" ; "moo" :

(moo "Hello" 5)

(moo "Hi" 1 2 3 )

:

(moo 1 2 3 ) ( )

(moo "Hello") ( )

(moo "do" '(1 2)) ( , )

, , ("[]"):

(foo [])

"foo" . , "foo" :

(foo "catch")

(foo "catch" 22)

:

(foo 44 13) ( )

(foo "foe" 44 13) ( )

1.5

, :

error:text

text - . "ERROR" ( ), , , ("text"- ). "ERROR" , , , 100 .

2

2.1

. . "acadl.ovl" .

"readme.doc". ; .

2.2 - "acad.lsp"

, "acad.lsp" ( ). . . DEFUN 4 .

3

. , , , , . , , . , . - - , .

- . , - , . , ( ).

. , . , , , , , - , .

3.1

, - .. . , , ASCII . , .

. .

3.2

- , .

:

COMMAND: PATH ()

Start point of path: start point

( : )

End point of path: end point

( : )

Half point of path: number

( : )

Radius of tiles: number

( : )

Spacing between tiles: number

( : )

. . , . , , " " .

3.3

( ). .

, , . 0 2'PL. , , . , GP.LSP. :

: Convert angle in degree to radians

(defun dtr (a)

(*pi (/a 180.0))

)

, . , DEFUN. DR ( "degrees to radians" (" ")).

"" - . - :

PI * (a / 180.0)

: " PI, , 180 ". PI 3.1459...; , ,- - , .

, ( , .. ).

"Command:", , :

Command: (load "gp")

, "DR". , : " ", .

, . , 0 ; :

Command: (dtr 0)

, , . DIR, , - . , ; :

0.000000

180 .

Command: (dtr 180)

:

3.141593

, 180 PI . , , .

:

Command: QUIT

Really want to discard all changes to drawing? Y

( ? )

0

DOS . " " .

3.4

garden path ( ) : , , . , , , .

, GP.LSP ( ).

: Convert angle in degrees to radians

(defun dtr (a)

('pi (/ a 180.0))

)

| :Acquire information for garden path

| (defun gpuser ()

| (setq sp (getpoint "\nStart point of path:"))

| (setq ep (getpoint "\nEnd point of path:"))

| (setq hwidth (getdist "\nHalf width of path:"sp))

| (setq trad (getdist "\nRadius of tiles:"sp))

| (setq pangle (angle sp ep ))

| (setq plength (distance sp ep ))

| (setq width (' 2 hwidth))

| (setq angp90 (+pangle (dtr 90))) : Path angle +90 deg

| (setq angm90 (-pangle (dtr 90))) : Path angle -90 deg

, . . , . , , , .

, GPUSER. , . SETQ . SETQ SP ( ) GETPOINT. GETPOINT. , . "\n" . GETPOINT , . GETPOINT , SP, " " . , , , .

. PANGLE . ANGLE . PLENGTH . DISTANCE , . , , . , , - 90 ANGP90 ANGM90 (.. , DTR ).

, . , , .

, :

Command: (gpuser)

:

: 2,2

: 9,8

: 2

: .2

: .1

GPUSER ( - 0,826169, ANGM90 ). , GPUSER (!) . . , :

Command: !sp

(2.000000 2.000000)

Command: !ep

(9.000000 8.000000)

Command: !hwidth

2.000000

Command: !width

4.000000

Command: !trad

0.200000

Command: !tspac

0.100000

Command: !pangle

0.708626

Command: !plength

9.219544

Command: !angp90

2.279423

Command: !angm90

-0.862169

, PANGLE, ANGP90 ANGM90 . , GP.LSP.

3.5

, . C:XXX , (, ) . PATH, C:PATH, GP.LSP PATH garden path .

GP.LSP, .

C:PATH, PATH . , :

: PATH

: 2,2

: 9,8

: 2

: .2

: .1

3.6

PATH , , , / (). , , .

GETVAR , BLIPMODE CMDECHO. SETQ SBLIP SCMDE. SETVAR , ; . , GPUSER. , .

, , SETVAR .

, PATH. , , .

3.7

. : , , . , .

. PATH, . . , , , , . . . , , .

, . , . "" , .

4

. ( ) , ( ) .

. . , , . , . .

4.1 (+ ...)

<>. . <> - , ; - , .

:

(+1 2) 3

(+1 2 3 4.5) 10.500000

(+1 2 3 4.0) 10.000000

4.2 (- < number > ...)

<> . <>, . <>, . , .

:

(-50 40) 10

(-50 40.0 2) 8.000000

(-50 40.0 2.5) 7.500000

(-8) -8

4.3 (* ...)

<>. .

:

(* 2 3) 6

(* 2 3 4.0) 8.000000

(* 3 -4.5) -13.500000

4.4 (/ ...)

<> . <>, <> .

:

(/100 2) 50

(/100 2.0) 50.000000

(/100 20 2.0) 2.500000

(/100.0 20 2) 2.500000

(/100 20 2) 2

(/135 360) 0

(/135 360.0) 0.375000

4.5 (= ...)

" -". T, <> , . .

:

(=4 4.0) T

(=20 388) nil

(=2.4 2.4 2.4) T

(=499 499 500) nil

(="me" "me") T

(="me" "you") nil

4.6 (/= )

" -". T, < 1> < 2>, nil. , . :

(/=10 20) T

(/=5.43 5.43) nil

(/=5.43 5.44) T

4.7 (< ...)

", ". T, <> , nil . <>, T , , <> . :

(< 10 20) T

(< 4 4) nil

(< 357 33.2) nil

(< 2 3 88) T

(< 2 3 4 4) nil

4.8 (<= ...)

" ". T, <> nil . <>, T , <>, . :

(<= 10 20) T

(<= 4 4) T

(<= 357 33.2) nil

(<= 2 9 9) T

(<= 2 9 4 5) nil

4.9 (> ...)

", " . T, <> , nil, . <>, T , . :

(> 120 17) T

(> 57 57) nil

(> 3.5 1792) nil

(> 77 4 2) T

(> 77 4 4) nil

4.10 (>= ...)

" ". T, <> , nil . <>, T , <> . :

(>= 120 17) T

(>= 57 57) T

(>= 3.5 1792) nil

(>= 77 4 4) T

(>= 77 4 9) nil

  1. (- )

(NOT) (- ) <>. <> . :

(-3) -4

(-100) -101

(- -4) 3

4.12 (1+ )

<>, (). <> . :

(1+ 5) 6

(1+ -17.5) -16.500000

4.13 (1- )

<>, (). <> . :

(1- 5) 4

(1- -17.5) -18.500000

4.14 (abs )

<>. <> . :

(abs 100) 100

(abs -100) 100

(abs -99.25) 99.250000

4.15 (and ...)

(AND) . , , T. , :

(setq a 103)

(setq b nil)

(setq c "string")

:

(and 1.4 a c) T

(and 1.4 a b c) nil

4.16 (angle

)

( ) 2D

, 2D - . :

(angle '(1.0 1.0) '(1.0 4.0)) 1.570796

(angle '(5.0 1.33) '(2.4 1.33)) 3.141593

4.17 (angtos [ [

]])

<> (, ) - . /<> - ; :

ANGTOS

------------ ---------------------

0

1 //

2

3

4

/<> - , . <> <> AUNITS AUPREC . , AUNITS AUPREC.

, :

(setq pt1 '(5.0 1.33))

(setq pt2 '(2.4 1.33))

(setq a (angle pt1 pt2))

:

(angtos a 0 0) "180"

(angtos a 0 4) "180.0000"

(angtos a 1 4) "180d0'0"

(angtos a 3 4) "3.1416r"

(angtos a 4 2) "W"

4.18 (append ...)

(/<>) .

(append '(a b) '(c d)) (A B C D)

(append '((a)(b)) '((c)(d)) ((A)(B)(C)(D))

APPEND , .

4.19 (apply )

, /<> , /<>. :

(apply ' + '(1 2 3)) 6

(apply 'stract' ("a" "b" "c")) "abc"

APPLY (subrs), ( DEFUN, LAMBDA) .

4.20 (ascii )

<> ASCII ( ). , ASC . :

(ascii "A") 65

(ascii "a") 97

(ascii "BIG") 66

4.21 (assoc )

() . , ASSOC . , , "al" :

((name box) (width 3) (size 4.7263) (depth 5))

:

(assoc 'size al) (SIZE 4.7263)

(assoc 'weight al) nil

, "". . SUBST, , , .

4.22 (atan [])

, ATAN . , -pt +pt . :

(atan 0.5) 0.463647

(atan 1.0) 0.785398

(atan -1.0) -0.785398

(angtos (atan -1.0) 0 4) "-45.0000"

( ), / . - , 1.570796 (90 -90 ) . :

(atan 2.0 3.0) 0.588002

(angtos (atan 2.0 3.0) 0 4) "33.6901"

(atan 2.0 -3.0) 2.553590

(angtos (atan 2.0 -3.0) 0 4) "146.3099"

(atan -2.0 3.0) -0.588002

(atan -2.0 -3.0) -2.553590

(atan 1.0 0.0) 1.570796

(angtos (atan 1.0 0.0) 0 4) "90.0000

(atan -0.5 0.0) -1.570796

(angtos (atan -0.5 0.0) 0 2) "-90.00"

4.23 (atof )

. :

(atof "97.1") 97.100000

(atof "3") 3.000000


4.24 (atoi )

.

(atoi "97") 97

(atoi "3") 3

(atoi "3.9) 3

4.25 (atom )

, - , T. , , atom. , :

(setq a '(x y z))

(setq b 'a)

:

(atom 'a) T

(atom a) nil

(atom 'b) T

(atom b) T

(atom '(a b c)) nil

ATOM, .

4.26 (Boole ...)

. - 0 15, 16 . () , :

Int1 Int2 Func bit

---------------------

0 0 8

0 1 4

1 0 2

1 1 1

, . , 1, , . , 1, - 0.

AND, OR, XOR NOT. :

1,...

-------------------------------------------------------

1 AND - 1

6 XOR - 1

7 OR

8 NOT - 0 (- )

:

(Boole 1 12 5)

AND 12 5. 4. :

(Boole 6 6 5)

XOR 6 5, - 3.

, . , - 4 , , , . :

(Boole 4 3 14)

12.

4.27 (boundp )

T, , ( ). , ( ), . , :

(setq a 2)

(setq b nil)

:

(boundp 'a) T

(doundp 'b) nil

4.28 caar, cadr, cddr, cadar, etc.

CAR CDR . , :

(setq x '((a b) c d))

:

(caar x ) (car (car x)) A

(cdar x) (cdr (car x)) (B)

(cadar x) (car (cdr (car x))) B

(cadr x) (car (cdr x))

(cddr x) (dr (dr x)) (D)

(caddr x) (car (cdr (cdr x))) D

CADR Y 2D 3D ( ). , CADDR Z 3D. :

(setq pt2 '(5.2 1.0 (2D )

(setq pt3 '(5.2 1.0 3.0) (3D )

:

(car pt2) 5.200000

(cadr pt2) 1.000000

(caddr pt2) nil

(car pt3) 5.200000

(cadr pt3) 1.000000

(caddr pt3) 3.000000

4.29 (car )

<> . <> , . :

(car '(a b c)) A

(car '((a b) c)) (A B)

(car '()) nil

4.30 (cdr )

<>, . <> , . :

(cdr '(a b c)) (B C)

(cdr '((a b) c)) (C)

(cdr '()) nil

<> - (. CONS), CDR . :

(cdr '(a . b) B

(cdr '(1 . "Text") "Text"

4.31 (chr )

, ASCII, ( CHRS ). :

(chr 65) "A"

(chr 66) "B"

(chr 97) "a"

4.32 (close )

. - (), OPEN. CLOSE , . , , - ,

(close x )

.

4.33 (command ...)

. , , , . , 2D 3D . "Command". :

(setq pt1 '(1.45 3.23))

(setq pt2 (getpoint "Enter a point: "))

(command "line" pt1 pt2)

(command "")

, "Command" , "pt1", "pt2" LINE . COMMAND , , - . ("") . COMMAND CTR C ; .

, COMMAND, , CMDECHO ( SETVAR GETVAR) . COMMAND - .

"GETxxx" (GETANGLE, GETSTRING, GETINT, GETPOINT) . , :

": " . , GETxxx, , COMMAND.

, ("/"), COMMAND, ( ). , . , , , .

, COMMAND , . , ZOOM PAN COMMAND. , .

:

(command "circle" "5,5" "r" "\\" "line" "5,5" "7,5" "")

CIRCLE, 5,5 -, . ( ), , 5,5 7,5.

. COMMAND , . , . , COMMAND, .

4.34 (cond ( ...)

. ( ) , . , , . (, ), . COND - .

, COND :

(cond (minusp a) (-a))

(t a)

)

"" -10, 10. , COND "case". T ( ) <> . , . "s", 1, "Y" "y" 0, "N" "n", -nil ().

(cond (( = s "Y") 1)

(( = s "y") 1)

(( = s "N") 0)

(( = s "n") 0)

( t nil)

)

4.35 (cons )

. (< >) (<>), . :

(cons 'a '(b c d)) (A B C D)

(cons '(a) '(b c d)) ((A) B C D)

, . CONS <>, , dotted pair ( ). , . , ; CDR . :

(cons 'a 'b) ( A . B)

(car (cons 'a 'b)) A

(cdr (cons 'a 'b)) B

4.36 (cons )

<>, <> . :

(cos 0.0 ) 1.000000

(cos pi ) -1.000000

4.37 (defun ...)

DEFUN ( , , ). ( ), , . ( ) .

, , . :

(defun myfunc (x y)...) ( 2 )

(defun myfunc (/a b)...) ( 2 )

(defun myfunc (x/temp)...) ( )

(defun myfunc ()...) ( )

.

DEFUN . , () . . , . . DEFUN . :

(defun add (x y)

(+ x y)

)

(add 10 5) 15

(add -7 . 4) 2,60000

(defun dots ( x y/temp)

(setq temp (strcat x "..."))

(strcat temp y)

)

(dots "a" "b" ) "...b"

(dots "from" "to") "from...to"

, .

4.37.1.

LOAD ( ). "acad.lsp", ; .

4.37.2. : -

, DEFUN , . , , :

1. : ":", - . "" , "" , , , .

2. ( ).

, : :

(defun C:PSQUARE ('pt1 pt2 pt3 pt4 len)

(setq pt1 (getpoint "Lower left corner:"))

(setq len (getdist pt1 "Length of one side:"))

(setq pt2 (polar pt1 0.0 len))

(setq pt3 (polar pt2 ('PI 2.0) len))

(setq pt4 (polar pt3 PI len))

(Command "PLINE" pt1 pt2 pt3 pt4 "C")

)

, , "" , "Command:". "" - , ":" . , C:PSQUARE :

ommand: PSQUARE

Lower left corner: (enter a point)

: ( )

Length of one side: (enter a distance)

: ( )

PLINE : . - . , , . , , , .

4.38.(distance

)

2D

, 2D - .

:

(distance '(1.0 2.5) '(7.7 2.5)) 6.700000

(distance '(1.0 2.5) '(3.0 4.0)) 2.828427

4.39. (eq )

, , , (,SETQ). EQ T, , . . , :

(setq f1 '(a b c))

(setq f2 '(a b c))

(setq f3 f2)

:

(eq f1 f2) (f1 f2 - !)

(eq f3 f2) T (f3 f2 - !)

. EQUAL.

4.40 (equal )

, , .. . , :

(setq f1 '(a b c))

(setq f2 '(a b c))

(setq f3 f2)

:

(equal f1 f2) T (f1 f2 )

(equal f3 f2) (f2 f3 )

, , , , , , . , , , .

4.41.(eval )

(), - . , :

(setq a 123)

(setq b 'a)

:

(eval 4.0) 4.000000

(eval (abs - 10 )) 10

(eval a) 123

(eval b) 123

4.42.(exp )

, <> ( (antilog)). . ,

(exp 1.0) 2.718282

(exp 2.2) 9.025013

(exp -0.4) 0.670320

4.43. (expt

)

<>, <>. , . , . :

(expt 2 4) 16

(expt 3.0 2.0) 9.000000

4.44. (fix )

<> . <> , . , . :

(fix 3) 3

(fix 3.7) 3.000000

4.45.(float )

<> . <> , . :

(float 3) 3.000000

(float 3.7) 3.700000

4.46.(foreach )

<>, <> < >. < > . FOREACH <>. :

(foreach n'(a b c)(print n))

(print a)

(print b)

(print c)

FOREACH .

4.47.(gcd )

<1> <2>. <1> <2> . :

(gcd 81 57) 3

(gcd 12 20) 4

4.48.(getangle [

][

]

. <> - , ,

- 2D. , . , , .., .

"" , 2D . , .

GETANGLE ( ) , "" " , . GETANGLE :

(setq ang (getangle))

(setq ang (getangle '(1.0 3.5))

(setq ang (getangle "Which way?")

(setq ang (getangle '(1.0 3.5)"Which way?")

GETANGLE. "Can't reenter Autolisp" ( "). . GETORIENT INITGET.

4.49. (getcorner

[

])

GETCORNER , GETPOINT. , GETCORNER <> <> . . GETPOINT INITGET. GETCORNER, .

4.50.(getdist [

][

])

. <> - , ,

- . , . , , (), .

"" , . , .

GETDIST ( ) , "" , .

GETDIST.

(setq dist (getdist))

(setq dist (getdist '(1.0 3.5))

(setq dist (getdist "How far?")

(setq dist (getdist '(1.0 3.5)"How far?")

GETDIST. . INITGET.

4.51.(getint[

])

. <> - , .

:

(setq num (getint))

(setq num (getint "Enter a number:")) ( )

GETINT. . INITGET.

4.52.(getkword [

])

GETKWORD . GETKWORD, , INITGET ( ). GETWORD , . , . () ( ). , . :

(initgent 1 "Yes N")

(setq x (getkword "Are you sure? (Yes or No)"))

"Yes", "No", . , , .

GETKWORD. . INITGET.

4.53.(getorient [

][

])

, - ( ) , . , , - INITS ANGBASE ANGDIR.

GETORIENT GETANGLE, - -, GETANGLE. GETANGLE , ( ), GETORIENT ( ).

, INITS - 90 () - . , GETANGLE GETORIENT ( ) ( ).

Input (degrees)

GETANGLE

GETORIENT

0

0.000000

1.570796

90

1.570796

3.141593

180

3.141593

4.712389

90 (-90 270?)

4.712389

0.000000

, GETANGLE , - . , GETANGLE / , - . , GETORIENT - , . , GETORIENT , . , UNITS, 90 .

GETORIENT. . GETANGLE INITGET.

4.54. (getpoint [

] [

])

.

- ,

- , . .

, . :

(setq p (getpoint))

(setq p (getpoint "Where?")) "?"

(setq p (getpoint '(1.5 2.0) "Second point:")

GETPOINT 2D ( ). INITGET ".3D", GETPOINT 3D ( ).

GETPOINT. . GETCORNER INITGET.

4.55.(getreal [

])

. <> - , . :

(setq val (getreal)

(setq val (getreal " :")

GETREAL. . INITGET.

4.56.(getstring [][

])

. , ( RETURN). RETURN. <> - , . :

(setq s (getstring))

(setq s (getstring "What's your first name?"))

(setq s (getstring T "What's your full name?"))

( ), GETSTRING GETKWORD.

GETSTRING.

4.57.(getvar )

. "". , , 0.25 :

(getvar "FILLETRAD") 0.250000

. . SETVAR.

4.58.(graphscr)

GRAPHSCR - ( "Flip screen" ). GRAPHSCR . . TEXTSCR.

4.59.(if )

. , , . () - . IF ; , , IF . :

(if (=1 3)"Yes!!" "No") "No"

(if (=2 (+1 1)) "Yes!!") "Yes!!"

(if (=2 (+3 4)) "Yes!!") nil

4.60.(initget [][])

GETxxx ( GETSTRING GETVAR). INTGET . - :


INITGET Bits

1

2

4

8

, limcheck

16

3D , 2D

0 31. (, , ), . :

(initget (+ 1 2 4))

(setq age (getint "How old are you?") : " ?"

, , , . , ( ). GETxxx, ( ):

INITGET control bits honored ( INITGET)


No null

No zerro

No neg.

No limits

3D hoints

GETINT



GETREAL



GETDIST



GETANGLE



GETORIENT



GETPOINT



GETCORNER



GETKWORD





GETSTRING






GETVAR






INITGET , GETxxx, (, GETPOINT). , GETxxx STRING. . , . : "KEY1 KEY2 KEY3 ABBREV3". . () , .

, - ; , . , . - , . ( - , - ).

: "LTYPE,LT" "LType" - . , "LTYPE", "LTYP", "LTY" "LT" , "L"- , "LTSCALE" "LTYPEX" .

,

(defun getnum (ix)

(initget 1 "Pi Two-pi")

(setq x (getreal "Pi/Two-pi/:"))

(cond((eqx "Pi") pi)

((eq x "Two-pi")(*2.0 pi))

(T x)

)

)

INITGET "Pi" "TWO-Pi". GETREAL , "Pi/Two-pi/:", .

, GETNUM. , "Pi" ( "P"), GETPOINT "Pi". COND , , Pi. "Two-pi" . INITGET GETxxx , . .

4.61.(inters

[])

INTERS , , .

- ,

- . , , INTERS . - , INTERS . , :

(setq a'(1.0 1.0) b'(9.0 9.0))

(setq c'(4.0 1.0) d'(4.0 2.0))

:

(inters a b c d) nil

(inters a b c d T) nil

(inters a b c d nil) (4.000000 4.000000)

4.62.(itoa )

. :

(itoa 33) "33"

(itoa -17) "-17"

4.63 (lambda ...)

LAMBDA "" . . , . LAMBDA <> APPLY / MAPCAR . :

(apply '(lambda (x y z)

(* x (-y z)

)

'(5 20 14)

) 30

:

(mapcar '(lambda (x)

(setq counter (1 + counter))

(* x 5)

)

'(24 -6 10.2)

) (10 20 -30 51.000000)

4.64.(last)

<>. <> . :

(last '(a b c d e)) E

(last '(a b c (d e))) (DE)

, LAST , . , LAST- Y . 2D ( ), LAST Z 3D . , , 2D 3D, CADR Y CADDR Z.

4.65.(length )

, <>. :

(length '(a b c d) 4

(length '(a b (c d)) 3

(length '()) 0

4.66.(list ...)

() , . :

(list 'a 'b 'c) (A B C)

(list 'a '(d c) 'd) (A (B C) D)

(list 3.9 6.7) (3.90000 6.70000)

2D 3D ( ).

4.67. (listp )

T, - , nil . :

(listp '(a b c)) T

(listp 'a) nil

(listp 4.343) nil

4.68.(load )

. - , ( ".lsp" ). , "/function/test1" ("/ 1"). MS-DOS/PC-DOS (, a: c:) ( , "\\" ).

, LOAD . , LOAD .

, , "/fred/test1.lsp" DEFUN MY-FUN, "test2.lsp" :

(load "/fred/test1") MY-FUNC

(load "test2" "test"

LOAD . ( , /script file/), .

, , "acad.lsp", . , , .

4.69.(log )

log <>. :

(log 4.5) 1.504077

(log 1.22) 0.198850

4.70.(logand ...)

AND/ <>. <> , . :

(logand 7 15 3) 3

(logand 2 3 15) 2

(logand 8 3 4) 0

4.71.(logior )

OR/ <>. <> , . :

(logior 1 2 3) 7

(logior 9 3) 11

4.72.(lsh )

. <1> < > , . < > , <1> , - . "" , , , (shift in/shift out). "" (into/out) (16- ) , . :

(lsh 2 1) 4

(lsh 2 -1) 1

(lsh 40 2) 160

(lsh 16384 1) -32768

4.73.(mapcar ...)

MAPCAR <> <1> < n>, <>. <> , <>. :

(mapcar '1+'(10 20 30) (11 21 31)

(1 + 10)

(1 + 20)

(1 + 30)

MAPCAR . :

(mapcar '+'(10 20 30)'(4 3 2) (14 23 32)

:

(+10 4)

(+20 3)

(+30 2)

LAMBDA "" , MAPCAR. , - . :

(mapcar '(lambda (x)(+ x 3))'(10 20 30) (13 23 33)

(mapcar '(lambda (x y z)

(* x (-y z)

)

'(5 6)'(20 30)'(145.0)

) (30 150.000000)

4.47.(max ...)

<>. <> . :

(max 4.07 -144) 4.070000

(max -88 19 5 2) 19

4.75.(member )

<> <> <>, , <>. <> <>, MEMBER . :

(member 'c '(a b c d e) (C D E)

(member 'q '(a b c d e) nil

4.76.(menucmd )

MENUCMD . , , , /. <> MENUCMD :

section - submenu ( - )

section / . :

S - (SCREEN)

B - (BUTTONS)

T1-T4 - (TABLET) 1 4

A1 - AUXI .

submenu . / ( "**") , . . 5. , "S", , . :

(menucmd "S = OSNAP")

"OSNAP" (, ). :

(menucmd "B" = "MY-BUTTONS")

"MY-BUTTONS" . MENUCMD nil.

4.77.(min ...)

<>. <> . :

(min 683 -10.0) -10.000000

(min 73 2 48 5) 2

4.78.(minusp )

T, - , nil. . :

(minusp -1) T

(minusp -4.293) T

(minusp 830.2) nil

4.79.(not )

T, - . , NULL , NOT . , :

(setq a 123)

(setq b "string")

(setq c nil)

:

(not a) nil

(not b) nil

(not c) T

(not '()) T

4.80.(nth )

"nth" <>, - ( - ). , <>, nil. :

(nth 3 '(a b c d e)) D

(nth 0 '(a b c d e)) A

(nth 5 '(a b c d e) nil

4.81.(null )

, , nil. , :

(setq a 123)

(setq b "string")

(setq c nil)

:

(nul a) nil

(nul b) nil

(nul c) T

(nul '()) T

4.82.(numberp )

T, - , . , :

(setq a 123)

(setq b 'a)

:

(numberp 4 ) T

(numberp 3.8348) T

(numberp "Howdy") nil

(numberp 'a) nil

(numberp a) T

(numberp b) nil

(numberp (eval b)) T

4.83.(open )

I/O . , I/O , setq. :

(setq a(open "file.ext" "r"))

- , . - /. , . mode :

PEN mode

"r"

. ,

"w"

. , . , .

"a"

. , . , , , , .

DOS, - (CTRL Z, ASCII 26) . DOS -, CTRL Z , . "a" OPEN , , CTRL Z .

, :

(setq f(open "new.tst" "w"))

(setq f(open "nouch.fil" "r")) nil

(setq f(open "logfile" "a"))

, "test/func3" MS-DOS ; ( , "\\" ). :

(setq f(open "/x/new.tst" "w")

(setq f(open nosuch.fil" "r") nil

4.84.(or ..)

OR/ . , . :

(or nil 'a '()) T

(or nil '()) nil

4.85.(osnap

)

, (snap) ,

. - , , "midpoint", "center" .., . :

(setq pt2 (osnap pt1 "midp"))

(setq pt2 (osnap pt1 "midp,endp,center")

- 2D ( ), 2D.

3D ( ), 3D. , /,

, .

4.86. pi

, pi. 3,1415926.

4.87.(polar

)

. - , . :

(polar '(1.0 1.0) 0.785398 1.414214)

(2.000000 2.000000)

4.88. (prin1[])

. , . ( , ), <> , . <>, . , :

(setq a 123)

(setq b '(a))

(prin1 'a) A A

(prin1 a) 123 123

(prin1 b) (A) (A)

(prin1 "Hello") "Hello" "Hello"

, < >. , F - , :

(prin1 "Hello" f)

"Hello" "Hello".

- , , PRIN1 " ".

\e escape

\n newline

\r return ,

\t tab

\nnn , nnn

:

(prin1 (chr 2)) "\002" "\002"

(prin1 (chr 10)) "\n" "\n"

4.89.(princ [])

, PRIN1, , . , PRIN1 , LOAD , PRINC READ-LINE .

4.90. (print [])

, PRIN1, , , .

4.91. (progn ...)

<> . PROGN , . :

(if (=a b) (progn

(setq a (+a 10)

(setq b (-b 10)

)

IF "then", - . PROGN .

4.92.(prompt )

/ . - . , PROMPT PRINC. :

(prompt "New value:")

"New value:" .

4.93.(quote )

<>. :

'expr

:

(quote a) A

(quote cat) CAT

(quote (a b)) (A B)

'a A

'cat CAT

'(a b) (A B)

4.94. (read )

, <>. <> . :

(read "hello") HELLO

(read "hi") HI

(read "(a)") (A)

4.95.(read-char [])

, . ( ) ASCII , .

, , READ-CHAR , - ( RETURN !). , , :

(read-char)

, - . "A B C", RETURN, READ-CHAR 65 ( ASCII "A"). READ-CHAR 66, 67 10 ( ) . READ-CHAR, .

4.96. (read-line [])

, . , READ-LINE , , . , F - :

(read-line f)

, , .

4.97 (redraw [[]])

. ,

(redraw)

, REDRAW. ,

(redraw )

. GRCLEAR .

REDRAW :

()

- , , - :

Redraw Mode

Action/

1

2

( )

3

( )

4

( )

- ( ), , . , REDRAW . , REDRAW .

4.98.(rem ...)

( ). mod mod - .

REM . :

(rem 42 12) 6

(rem 12.0 16) 12.000000

(rem 60 3) 0

4.99.(repeat ...)

<> . . , :

(setq a 10)

(setq b 100)

:

(repeat 4

(setq a(+ a 10)))

(setq b(+ b 10)))

) 140

4.100.(reverse )

<> . :

(reverse '((a)b c)) (C B (A))

4.101. (rtos [

])

, <> () /

/ , DIMZIN. <> <> - , . <>:

RTOS

1

2

3

( )

4

( )

5

LUNITS LUPREC . , LUPREC LUNITS. RTOS:

(rtos 17.5 1 4) "1.7500E+01"

(rtos 17.5 2 2) "17.50"

(rtos 17.5 3 2) "1'-5.50""

(rtos 17.5 4 2) "1'-5 1/2""

(rtos 17.5 5 2) "17 1/2"

5.

5.1.

. . .

.mnu. .mnx. LISP- .mnl. LISP-, . .mnd. , . mc, SAMPLE.

.mnu , .mnx, , . , -, . . menu (). ; . menu :

Command: MENU

. .mnu, , .mnx, MNX- , MNU-, . MNU- MNX-. MNU- , MNX-. MNX- , , .

FILEDIA, :

Command: MENU : (: )

Menu file name or . for none : : ( . < >:

.

, , . . MENU.

5.2.

, , , , . :

***SCREEN - ;

***BUTTONSn - , n - 1 4;

***AUXn - , n - 1 4;

***POPn - , n - 1 16;

***ICON - ;

***TABLETn - , n - 1 4.

, . :

***SCREEN

[Help]help

[Bye]end

***BUTTONS

erase

oops

Help Bye , erase oops - . ***SCREEN, , ***SCREEN .

5.3.

, , . , ARC DRAW , ARC. . . .

. :

** < > <> .

31 , , , $, - (), _ ( ). . , :

**MOVE 3

[MOVE:]^C^CMOVE

Window

Last

Previous

Crossing

Remove

Add

Undo

**MOVE MOVE. [MOVE:] , MOVE.

, , . , , 20 .

. , , , . . , **MOVE 3 * * * *, MOVE:.

, :

$<>=<> ,

<> - . :

S - SCREEN;

P1 - P16 - POP 1 16;

I - ICON;

B1 - B4 - BUTTONS;

T1 - T4 - TABLET1 - TABLET4;

A1 - A4 - AUX1.

<> - ** , .

, EDIT MOVE $S=MOVE:

**EDIT 3

...

[MOVE:]^C^C$S=MOVE

...

, , , . , , $S=. , LAST , :

[_LAST_]^C^C$S=

, , . . , .

, .. , COLOR $=X $S=LACOLOR:

[COLOR:]^C^CCOLOR $S=X $S=LACOLOR

...

**X 3

...

[_LAST]$S= $S=

[DRAW]^C^C$S=X $S=DR

[EDIT]^C^C$S=X $S=ED

...

**LACOLOR 3

[COLOR]

red

yellow

green

cyan

blue

magenta

white

...

COLOR, X LACOLOR COLOR.

, . .

. , SNAP 0.01 SNAP 0.0. , [ ]. . . , , :

[MYSNAP]SNAP 0.01

. . , .

, , . .

, +. + , .

. \ . ,

[CIRCLE-3]circle \3

[erase 1]erase \;

CIRCLE-3 , , 3. ERASE 1 , ; .

:

  • , ;

  • , ;

  • SELECT ();

  • ;

  • ( ), ( , ).

, , (, ), (_):

[, , ]^C^C_arc;_c;\\_l

^C^C. . ^C, ^C^C Command: (, DIM); ^C^C.

, , , , , . MENUECHO. - , ^P .

. . : ;, ENTER. - \, ; +, .

ASCII ^ . , ^ , /.

- . *^C^C ( ), Command: , . ^C , *^C^C, .. .

:

*** - ;

** - ;

[] - , , , , , ;

; - ;

^M - ;

^I - ;

\ - ;

_ - ;

+ - ,

=* - , ;

*^C^C - ;

$ - , ;

^B - ;

^C - ;

^D - ;

^E - ;

^G - ;

^H - ;

^O - ;

^P - MENUECHO;

^Q - , ;

^T - ;

^V - .

, , S- . , S-, :

[BOX](setq a (getpoint Enter first corner:));\+

(setq b (getpoint Enter second corner:));\+

pline !a (list (car a) (cadr b)) !b (list (car b) (cadr a)) c;

255 - . (;), .

- .mnl. load. .mnl .


1 - , . , ,

 

 

 

! , , , .
. , :