( )
____________________________________________
3:
" , "
304: " , "
: " ".
23
.304, ... ..
____________
: ..
: 03-219
____________
, 2012
1: " "
1) :
:
(plus
( quotier
(times a b c)
(quotier m n k) )
( quotier
(plus exp (expt a b) (expt c d))
(sqrt (diff (sin x) (cos y) (ln z))) )
)
:
(+
( /
(* a b c)
(/ m n k) )
( /
(+ (exp x) (expt a b) (expt c d))
(sqrt (- (sin x) (cos y) (ln z))) )
)
2) . , :
(difference (quotient (sqrt (plus (sin x) (cos x))) (sub1 y)) (times (add1 x) (log z))).
:
(- (/ (sqrt (+ (sin x) (cos x))) (1- y)) (* (1+ x) (log z)))
:
:
>(- (/ (sqrt (+ (sin 1) (cos 1))) (1- 2)) (* (1+ 1) (log 100)))
:
x=1,y=2,z=100
:
-8.034852
3) N: (setq N ((gk ij kl) (ab cd ef))).
) CAR CDR N, ij.
> (cadar N)
IJ
) S-:
> (last N)
((AB CD EF))
>(delete kl N)
((GK IJ KL) (AB CD EF))
>(reverse N)
((AB CD EF) (GK IJ KL))
>(cons a N)
(A (GK IJ KL) (AB CD EF))
>(append N N)
((GK IJ KL) (AB CD EF) (GK IJ KL) (AB CD EF))
4) S-:
>(and (number 3) (greaterp 4 2 1) (equal (setq x 1) 1)).
T
2: " "
, DEFUN. . .
.
, .
>(defun area (a b c)
(setq L (* (/ 1 2) a b (sin c)))
)
>(area 1 2 3)
0.14112
APPLY MAPCAR.
, .
>(defun arifm (x)
(/ (apply '+ x) (length x))
)
>(arifm '(9 4 8))
|
|
COND.
,
.
>(defun hister (x a b)
(cond ((or (>= x a)) (setq y b))
((or (<= x (* a -1))) (setq y (* b -1)))
((or (< (abs x) a)))
(T (setq y y))
))
(hister 5 3 6)
(hister 6 4 8)
(hister -5 3 9)
-9
.
, Ʈ ( ) .
>(defun tet (n)
(if (= n 0) 0
(/ 1.0 (+ 1 (tet(1- n)))))
)
>(tet 15)
0.618034
5) λ- , , 3/2.
>(defun summa (x)
(apply '+ (mapcar (lambda (z) (expt z 1.5)) x))
)
>(summa '(5 4 7 1 3))
43.896752
: