.


:




:

































 

 

 

 


. 1. , , :




1. , , :

:

>(fun 3)

32; 11 + 22 + 33

2. , . x y. , | x - y2 | <= err, err . 1/2 *(y + x/y), . abs: (abs -5) = 5.

:

; 5

; 1

; 0.05

>(newton 5 1 0.05)

2.2380953

3. N- . . .

4. , .

:

>(last1 '(a b c))

C

5. my-nth, l n, n- l. .

:

>(my-nth 2 '(0 1 2 3))

>(my-nth 0 '((a b) c d))

(A B)

6. fringe, , , , . :

- atom - T, , NIL ;

- listp - T, .

:

>(fringe '(a b (c) (d (e) f)))

(A B C D E F)

>(fringe '((((((((a)))))))))

(A)

>(fringe '(((nil) a) 7))

(A 7)

1. , - null . :

(defun recurse (l)

(if (null l) (do-something)

(do-something-else (car l) (recurse (cdr l)))))

null (eql l nil)? . , .

2. , .

3. ?

(defun mystery (n)

(cond ((zerop n) 1)

(t (+ n (mystery (- n 1))))))

4. mystery.

5. , . , 0.

:

>minimum('(3 2 7 1 4 8))

6. sum, , NIL. , : , NIL . .

(defun sum (lst)

(let ((x (first lst)))

(if (null x)

(sum (rest x))

(+ x (sum (rest x))))))


6

, ,





:


: 2015-10-01; !; : 474 |


:

:

: , , , , .
==> ...

1286 - | 1191 -


© 2015-2024 lektsii.org - -

: 0.007 .