Породження комбінаторних об’єктів
((ZEROP i) (RETURN (PRINT list)))
(PUSH i list)
(LOOP ((> 1 (CAR list)) (RETURN (POP list)))
(calc (- i 1))
(PUSH (- (POP list) 1) list)
) )
4. а) $ (DEFUN INTEGRATE (function a b n)(defun f (x)
(SETQ step (/ (- b a) n) intsumma 0)(* x x)
(LOOP)
((= a b) (* intsumma step))
(INCQ intsumma (FUNCALL function a))Виклик: (INTEGRATE f 0 1 100)
(INCQ a step)
) )
б) (DEFUN HALFDIV (function a b eps)
(SETQ middle (/ (+ a b) 2) res (FUNCALL function middle))
((< (- b a) eps) middle)
(IF (MINUSP (* res (FUNCALL function a)))
(HALFDIV function a middle eps) (HALFDIV function middle b eps))
)
в) $ (DEFUN SQRT2 (n eps) г) $ (DEFUN DIFF (function x)
(SETQ s (/ n 2)) (SETQ delta 0.01)
(LOOP (/ (- (FUNCALL function (+ x delta))
(SETQ snew (/ (+ s (/ n s)) 2)) (FUNCALL function x)) delta)
((< (ABS(- s snew)) eps) snew) )
(SETQ s snew)