. , P - .

 

1. UNPACK <atom>. , P - <atom>. <atom> , NIL.

$ (UNPACK abcde) $ (UNPACK 216) $ (SETQ *PRINT-BASE 16*)

(a b c d e) (\2 \1 \6) $ (UNPACK 216)

(\0 \D \8)

 

2. PACK <list>. , P - 䳺 P - <list>. P - - . PACK , P - .

$ (PACK (a b c d e) $ (PACK (\7 \3 \1) $ (PACK (Q \7 \A \1))

abcde |731| Q7A1

 

3. PACK* <atom1> ... <atomN>. , P- P- . PACK, , - .

$ (PACK* a b c) $ (PACK 4 QW T)

ABC |4QWT|

 

4. CHAR <atom> <n>. <atom> , <n> 䒺 , CHAR , P - n- P - <atom>, 0. NIL <n> , P - <atom> n .

(DEFUN CHAR (atm n) $ (CHAR ABCDE 3) $ (CHAR 12345 0)

((ATOM atm) D \1

(NTH n (UNPACK atm)) ) )

 

5. SUBSTRING <atom> <n> <m>. <atom> , <n> <m> 䒺 , nm, SUBSTRING , P - P - n- m-, 0. n0, n=0. m , 0 P - , m P - . n>m NIL.

 

(DEFUN SUBSTRING (atm n m)

((AND (ATOM atm) (INTEGERP n))

((MINUSP n) (SUBSTRING atm 0 m))

(PACK (SUBLIST (UNPACK atm) n m))

$ (SUBSTRING ABCDEFG 2 4) $ (SUBSTRING ABCDEFG 3)

CDE DEFG

$ (SUBSTRING 123456 3) $ (SUBSTRING ABCDEFG 0 3)

|456| ABCD

 

6. STRING<pr> <atom1> <atom2> <flag>, <pr - - <, >, <=, >=, =, /=. ³ P - <pr>. NIL, . , T. STRING= T NIL. NIL, , P - .

$ (STRING= ABC ABC) $ (STRING ABC ABC NIL)

T T

$ (STRING= Abc AbC) $ (STRING= Abc AbC NIL)

T NIL

$ (STRING= |100| 100) $ (STRING< ABC AZC)

T 1

$ (STRING< AZC ABC) $ (STRING>= 123 123)

NIL 3

 

7. STRING-UPCASE <atom>. , P - P - , . <atom> , NIL.

$ (STRING-UPCASE Lisp Is A Language) $ (STRING-UPCASE (a s d))

|LISP IS A LANGUAGE| NIL

 

8. STRING-DOWNCASE <atom>. , P - P - , . <atom> , NIL.

$ (string-upcase |This is A TEXT|) $ (string-downcase |This is A TEXT|)

|THIS IS A TEXT| |this is a text|

$ (STRING-UPCASE i) $ (STRING-DOWNCASE I)

I \i

 

9. FINDSTRING <atom1> <atom2> <n>. P - 1 P - 2. <n> - , n- 2. P - 1 , NIL.

$ (FINDSTRING BC ABCDEFG) (FINDSTRING abc abdeabcde)

1 4

 

10. PRINT-LENGTH <atom>. P - *PRINT-BASE* *PRINT-ESCAPE*.

$ (DEFUN PRINT-LENGTH (atm) $ (PRINT-LENGTH Mulisp)

((ATOM atm) (LENGTH (UNPACK atm))) 6

 

 

$ (PRINT-LENGTH -156) $ (PRINT-LENGTH NIL)

4 3

 

1. , , . , . , a22eeerty (e . 3).

(DEFUN symmax (atm) $ (symmax a22eeerty)

((NOT (ATOM atm)) NIL) (e . 3)

(SETQ lst (UNPACK atm) endel (ASCII 0) endct 0) $ (symmax nil)

(LOOP (n . 1)

((NULL lst)) $ (symmax 1222334)

(SETQ el (CAR lst) ct 0) (\2 . 3 )

(LOOP

((NOT (EQL (CAR lst) el)))

(POP lst)

(INCQ ct) )

(IF (> ct endct) (SETQ endct ct endel el)) )

(CONS endel endct) )

 

 

(CIS - Current Input Stream) .

1.    READ. ϳ (SETQ a (READ)) , . ᒺ, ᒺ. , : as bf gh, a as. ( ᒺ), : (as df gh).

2.    (CLEAR-INPUT) . - NIL.

3.    (READ-LINE) CIS (<return>). , - , <return>.

4.    (READ-CHAR) CIS .

5.    (UNREAD-CHAR) CIS .

6.    (LISTEN) T CIS , NIL .

7. (OPEN-INPUT-FILE <name>) (CLOSE-INPUT-FILE <name>) <name> .

8. (OPEN-OUTPUT-FILE <name>) (CLOSE-OUTPUT-FILE <name>) <name> .

 

 

1. sym name.

(DEFUN f (name sym) (SETQ a (READ))

(SETQ c 0) (IF (EQL a sym) (INCQ c)) )

(OPEN-INPUT-FILE name) (CLOSE-INPUT-FILE name)

(LOOP c )

((NOT (LISTEN)))

 

2. , .

(DEFUN rew (in out) (PUSH (READ) temp) )

(OPEN-INPUT-FILE in) (LOOP

(OPEN-OUTPUT-FILE out) ((EQL temp NIL))

(SETQ temp NIL) (WRITE (POP temp))

(LOOP (SPACES 1) )

((NOT (LISTEN))) (CLOSE-INPUT-FILE in)

(CLOSE-OUTPUT-FILE out) )

 

 

1. (SRT <in> <out>), <in> <out>.

2. (PRNUM2 num) (PRNUM16 num), .

3. n y (y yy yyy yyyy .... yyyyyyyy. ʳ s n.

³

1. (DEFUN appl (lst1 lst2)

((NULL lst1) (append lst3 lst2))

((NULL lst2) (append lst3 lst1))

((STRING< (CAR lst1) (CAR lst2)) (CONS (CAR lst1) (appl (CDR lst1) lst2)))

(CONS (CAR lst2) (APPL lst1 (CDR lst2))) )

 

(DEFUN QSORT (lst)

((NULL (CDR lst)) lst)

((NULL (CDDR lst))

((STRING< (CAR lst) (CADR lst)) lst)

(CONS (CADR lst) (CONS (CAR lst) NIL)))

(SETQ tmp1 (SPLIT lst))

(APPL (QSORT tmp1) (QSORT lst)) )

 

(DEFUN srt (in out)

(OPEN-INPUT-FILE in)

(OPEN-OUTPUT-FILE out)

(SETQ temp NIL)

(LOOP

((NOT (LISTEN)))

(PUSH (READ) temp) )

(setq temp1 (qsort temp))

(print temp1)

(CLOSE-INPUT-FILE in)

(CLOSE-OUTPUT-FILE out) )

 

2. (DEFUN prnum2 (num)

(SETQ res NIL)

(LOOP

((= num 1))

(SETQ tmp (DIVIDE num 2))

(SETQ num (CAR tmp))

(PUSH (CDR tmp) res) )

(PUSH 1 res)

(PACK res) )

 

(DEFUN prnum16 (num)

(SETQ res NIL)

(LOOP

((< num 16))

(SETQ tmp (DIVIDE num 16))

(SETQ num (CAR tmp) tmp (CDR tmp))

(IF (>= tmp 10) (SETQ tmp (ASCII (+ (- 65 10) tmp))))

(PUSH tmp res) )

(IF (>= num 10) (SETQ num (ASCII (+ (- 65 10) num))))

(PUSH num res)

(PACK res) )

 

3. ; (m1 y 7 y) -> (y yy yyy yyyy yyyyy yyyyyy yyyyyyy)

(DEFUN m1 (sym n list)

((ZEROP n) NIL)

(CONS (APPEND sym list) (m1 sym (- n 1) (PACK* sym list))) )