1.
1
:
(- (/ (sqrt (+ (sin x) (cos x))) (+ (expt a b) (expt c d) (expt e t))) (/ (* m n k) (* q r s)))
:
(difference(quotient(sqrt(plus (sin x) (cos x))) (plus(pow a b) (pow c d) (pow e t))) (quotient (times m n k) (times q r s)))
2
,
Plus(quotient(difference 12 4 3)(add1 4))(sub1 0)).
:
(+ (/ (- 12 4 3) (1+ 4)) (1- 0))
:
=0
:
3
M: (SETQ M ((x y v) (w z a))).
a) CAR CDR M, z.
(cadadr M)
:
Z
) S-:
(REVERSE M)
((W Z A) (X Y V))
(CADR M)
(W Z A)
(CAR M)
(X Y V)
(LAST M)
((W Z A))
(LENGTH M)
4
S-:
(OR (NUMBERP (A B)) (LESSP 2 7 1) (EQUAL (SETQ X 1) X)))).
:
2.
, DEFUN. . :
(1) ;
(2) APPLY MAPCAR;
(3) COND;
(4) ;
(5) ƛ-;
(6) PROG, GO RETURN;
(7) .
1
, .
(defun ger(a b c)
(sqrt(* (/(+ a b c) 2) (- (/(+ a b c) 2) a) (- (/(+ a b c) 2) b) (- (/(+ a b c) 2) c))
)
)
GER
(ger 3 4 5)
:
6.0
2
, .
(defun rms(l)
(sqrt (/(apply '+(mapcar '* l l)) (LENGTH l))
)
)
RMS
(rms '(1 2 3 4 5))
:
3.3166253
3
, .
(defun gap(x a y)
(cond ((<= y (- x a)) (- x a))
((>= y (+ x a)) (+ x a))
(T y)
)
)
GAP
(gap 2 3 4)
:
4
(defun rek (q p n)
(cond ((zerop n) (/ p (+ q (rek q p (- n 1)))))
((> n 0) (+ q (/ p (+ q (rek q p (- n 1))))))
(t 0)
)
)
REK
(rek 15.0 5.0 10.0)
:
15.165751
5
, f(x)=exp(x)*cos(x) .
(defun sum(L)
|
|
(apply '+ (mapcar (lambda(x)(* (exp x) (cos x))) L))
)
SUM
(sum '(1 2 3))
:
-21.49077
6
:
(defun odd(i)
(cond
((=(mod i 2) 0) 1)
((=(mod i 2) 1) -1)
)
)
(defun func(n) (prog(i sum subsum result)
(setq i 1)
(setq sum 0)
start (setq subsum (/(odd i)(*
(-(* 2 i) 1)
(+(* 2 i) 1)
(+(* 2 i) 3)
(+(* 2 i) 5)
(+(* 2 i) 7))))
(setq sum (+ sum subsum))
(setq i (1+ i))
(cond
((<= i n)(go start))
((> i n) (go end)))
end (setq result(- (/ 64.0 21.0) (* 96.0 sum))) (return result)))
FUNC
(func 5)
:
3.141684
7
shift, .
(defun shift (L N)
(cond
((null L) nil)
((minusp N) L)
((zerop N) L)
(T (shift (append (cdr L) (cons (car L) Nil)) (1- N))
)
)
)
:
(shift '(1 2 3) 1)
(2 3 1)
(shift '(1 2 3) 2)
(3 1 2)
(shift '(1 2 3) 3)
(1 2 3)
3.
. , .
(setf (get 'launch-vehicle 'name) "Dnepr")
(setf (get (get 'launch-vehicle 'one-stage) 'ox-tank) 600)
(setf (get (get 'launch-vehicle 'one-stage) 'engine) 70000000)
(setf (get (get 'launch-vehicle 'one-stage) 'fuel-tank) 550)
(setf (get (get 'launch-vehicle 'two-stage) 'ox-tank) 600)
(setf (get (get 'launch-vehicle 'two-stage) 'engine) 70000000)
(setf (get (get 'launch-vehicle 'two-stage) 'fuel-tank) 550)
(setf (get (get 'launch-vehicle 'three-stage) 'fuel-tank) 550)
(setf (get (get 'launch-vehicle 'three-stage) 'ox-tank) 600)
(setf (get (get 'launch-vehicle 'three-stage) 'rotary-engines) 30000000)
(setf (get (get (get 'launch-vehicle 'three-stage) 'satellite) 'Sname) "Satellite-1")
(setf (get (get (get 'launch-vehicle 'three-stage) 'satellite) 'Sweight) 90)
(defun show (Property)
(cond ((get 'launch-vehicle Property))
((get (get 'launch-vehicle 'one-stage) Property))
((get (get 'launch-vehicle 'two-stage) Property))
((get (get 'launch-vehicle 'three-stage) Property))
((get (get (get 'launch-vehicle 'three-stage) 'satellite) Property))
(T nil)
)
)
(defun change (Property Value)
(cond ((get 'launch-vehicle Property)
(setf (get 'launch-vehicle Property) Value))
((get (get 'launch-vehicle 'one-stage) Property)
(setf (get (get 'launch-vehicle 'one-stage) Property) Value))
((get (get 'launch-vehicle 'two-stage) Property)
(setf (get (get 'launch-vehicle 'two-stage) Property) Value))
((get (get 'launch-vehicle 'three-stage) Property)
(setf (get (get 'launch-vehicle 'three-stage) Property) Value))
((get (get (get 'launch-vehicle 'three-stage) 'satellite) Property)
(setf (get (get (get 'launch-vehicle 'three-stage) 'satellite) Property) Value))
(T nil)
)
)
:
(show 'name)
"Energy"
(change 'name "Dnepr")
"Dnepr"
(show 'name)
"Dnepr"
1
, (* f 1) f.
(defun change(x)
(cond ((or (null x)(atom x)) x)
((and (equal (car x) '*)(equal (caddr x) '1))(change (cadr x)))
(T (mapcar 'change x))
|
|
)
)
:
CHANGE
(change '(* (* (* (* (* (* (exp x)1)1)1)1)1)1))
(EXP X)
2
, add1.
(defun sum (a b) (cond
((= b 1) (1+ a))
(t (1+ (sum a (1- b))
)
)
)
)
:
SUM
(sum 14 6)
Q2
S0
S1
Q1
S2
Q0
nand(integer,integer,integer,integer,integer) -, 4 1 .
trigger(integer,integer,integer,integer,integer,integer) , , 3 3
predicates
nand(integer,integer,integer,integer,integer)
trigger(integer,integer,integer,integer,integer,integer)
clauses
nand(1,1,1,1,0).
nand(1,1,1,0,0).
nand(1,1,0,1,0).
nand(1,0,1,1,0).
nand(0,1,1,1,0).
nand(1,0,0,0,0).
nand(0,1,0,0,0).
nand(0,0,1,0,0).
nand(0,0,0,1,0).
nand(0,0,0,0,1).
nand(0,0,1,1,0).
nand(1,0,0,1,0).
nand(1,1,0,0,0).
nand(1,0,1,0,0).
nand(0,1,0,1,0).
nand(0,1,1,0,0).
trigger(S0,S1,S2,Q0,Q1,Q2):-
nand(Q0,S1,S0,Q1,Q2),
nand(Q2,S0,S2,Q0,Q1),
nand(Q1,S2,S1,Q2,Q0).
: