Загрузил Настя Волкова

LISP 6

реклама
1.
(setf (get 'BPO-20 'студенты) '3)
(setf (get 'BPO-20 'курс) '2)
(setf (get 'BPO-20 'факультет) 'IT)
(setq bpo-20 '(Volkova Grechachin Ivanov))
2.а)
(setq volkova '(2002 (mama1 papa1) (program1 math)))
(setq grechachin '(2001 (mama2 papa2) (rus fisika)))
(setq ivanov '(1998 (mama3 papa3) (paradigm program2)))
б)
(setq mama1 '(volkova venera ivanovna bank))
(setq papa1 '(volkov sasha ivanovich school))
(setq mama2 '(grechachina nastasya ivanovna store))
(setq papa2 '(grechachin nikolay danilovich school))
(setq mama3 '(ivanova katerina petrovna bar))
(setq papa3 '(ivanov oleg michailovich university))
в)
(setq program1 '(0 5 5 1))
(setq math '(5 1.2 3.4 2))
(setq rus '(10 4.3 2.4 3))
(setq fisika '(9 2.5 4.3 4))
(setq paradigm '(4 4.3 3.3 5))
(setq program2 '(9 1.2 3.5 1))
3.
a)старше
(> (car volkova) (car ivanov))
T
(< (car volkova) (car ivanov))
NIL
б)у кого.ср бал меньше (setq m (/ (+ (cadr (eval (caaddr volkova))) (caddr (eval (caaddr volkova)))) 2))
(setq n (/ (+ (cadr (eval (caaddr grechachin))) (caddr (eval (caaddr grechachin)))) 2) )
(< (/ (+ (cadr (eval (caaddr volkova))) (caddr (eval (caaddr volkova)))) 2) (/ (+ (cadr (eval (caaddr grechachin))) (caddr (eval (caaddr grechachin)))) 2) )
в)у кого больше прогулов
(> (car (eval (caaddr volkova))) (car (eval (caaddr grechachin))) )
г)
(equalp (caadr volkova) (caadr grechachin)))
(equalp (cdadr volkova) (cdadr grechachin)))
д)
(or (equalp (cadddr (eval (caadr volkova))) (cadddr (eval (caadr grechachin)))) (equalp (cadddr (eval (cadadr volkova))) (cadddr (eval (cadadr grechachin)))) )
4.
(setf (get 'program1 'ЛР) '(5 5 5))
(setf (get 'program1 'ПР) '(5 5 5))
(setf (get 'math 'ЛР) '(2 2 2))
(setf (get 'math 'ПР) '(3 2 3))
(setf (get 'rus 'ЛР) '(4 5 2))
(setf (get 'rus 'ПР) '(3 2 2))
(setf (get 'fisika 'ЛР) '(2 2 3))
(setf (get 'fisika 'ПР) '(3 2 3))
(setf (get 'paradigm 'ЛР) '(4 2 4))
(setf (get 'paradigm 'ПР) '(3 3 4))
(setf (get 'program2 'ЛР) '(2 2 2))
(setf (get 'program2 'ПР) '(3 2 5))
5.
а)
(defun info(students) students)
(info volkova)
б)
(defun pns (students disc) (if (eq (caaddr students) disc) (cons (car (eval (caaddr students))) (symbol-plist (caaddr students))) (if (eq (car (cdaddr students)) disc) (cons (car (eval (car (cdaddr students)))) (symbol-plist (car (cdaddr students)))))) )
(pns ivanov 'inform)
(pns volkova 'program1)
в)
(defun sredb(stud disc pred) (if (eq (caaddr stud) disc) (if (eq pred 'ЛР) (= (cadr (eval (caaddr stud))) (/ (apply '+ (get (caaddr stud) 'ЛР)) 3)) (= (cadr (eval (caaddr stud))) (/ (apply '+ (get (caaddr stud) 'ПР)) 3)) ) (if (eq (car (cdaddr stud)) disc) (if (eq pred 'ЛР) (= (cadr (eval (car (cdaddr stud)))) (/ (apply '+ (get (car (cdaddr stud)) 'ЛР)) 3)) (= (cadr (eval (car (cdaddr stud)))) (/ (apply '+ (get (car (cdaddr stud)) 'ПР)) 3)) ) ) ))
(sredb volkova 'program1 'ПР)
6.
а)ne rab
(defun chen (stud) (rplaca (cddr (eval (caaddr stud))) (/ (apply '+ (get (caaddr stud) 'ЛР)) 3)) (rplaca (cdr (eval (caaddr stud))) (/ (apply '+ (get (caaddr stud) 'ПР)) 3)) (rplaca (cddr (eval (car (cdaddr stud)))) (/ (apply '+ (get (car (cdaddr stud)) 'ЛР)) 3)) (rplaca (cdr (eval (car (cdaddr stud)))) (/ (apply '+ (get (car (cdaddr stud)) 'ПР)) 3)))
(car (cdaddr stud))
б)
(defun lec (stud) (if (< (car (eval (caaddr stud))) (car (eval (car (cdaddr stud))))) (caaddr stud) (car (cdaddr stud))) )
в)
(defun sredm (stud disc) (if (eq (caaddr stud) disc) (if (< (cadr (eval (caaddr stud))) (caddr (eval (caaddr stud)))) (get (caaddr stud) 'ПР) (get (caaddr stud) 'ЛР))) (if (eq (car (cdaddr stud)) disc) (if (< (cadr (eval (car (cdaddr stud)))) (caddr (eval (car (cdaddr stud))))) (get (car (cdaddr stud)) 'ПР) (get (car (cdaddr stud)) 'ЛР))) )
(sredm volkova 'math)
7.
а)
(defun star (stud1 stud2) (if (> (car stud1) (car stud2)) (cons 'старше (cons stud1 nil)) (cons 'старше (cons stud2 nil)) ) )
б)
(defun best (stud1 stud2) (if (equalp (cadddr (eval (caaddr stud1))) (cadddr (eval (caaddr stud2)))) (if (> (/ (+ (cadr (eval (caaddr stud1))) (caddr (eval (caaddr stud1)))) 2) (/ (+ (cadr (eval (caaddr stud2))) (caddr (eval (caaddr stud2)))) 2)) (cadr (eval (caaddr stud1))) (cadr (eval (caaddr stud2))) ) ) (if (equalp (cadddr (eval (caaddr stud1))) (cadddr (eval (car (cdaddr stud2))))) (if (> (/ (+ (cadr (eval (caaddr stud1))) (caddr (eval (caaddr stud1)))) 2) (/ (+ (cadr (eval (car (cdaddr stud2)))) (caddr (eval (car (cdaddr stud2))))) 2)) (cadr (eval (caaddr stud1))) (cadr (eval (car (cdaddr stud2)))) ) )
(if (equalp (cadddr (eval (car (cdaddr stud1)))) (cadddr (eval (car (cdaddr stud2))))) (if (> (/ (+ (cadr (eval (car (cdaddr stud1)))) (caddr (eval (car (cdaddr stud1))))) 2) (/ (+ (cadr (eval (car (cdaddr stud2)))) (caddr (eval (car (cdaddr stud2))))) 2)) (cadr (eval (car (cdaddr stud1)))) (cadr (eval (car (cdaddr stud2)))) ) )
(if (equalp (cadddr (eval (car (cdaddr stud1)))) (cadddr (eval (caaddr stud2)))) (if (> (/ (+ (cadr (eval (caaddr stud1))) (caddr (eval (caaddr stud1)))) 2) (/ (+ (cadr (eval (caaddr stud2))) (caddr (eval (caaddr stud2)))) 2)) (cadr (eval (car (cdaddr stud1)))) (cadr (eval (caaddr stud2))) ) )
)
в)
(defun rods(stud1 stud2) (or (equalp (caadr stud1) (caadr stud2)) (equalp (cdadr stud1) (cdadr stud2))) )
Скачать