CherMi

lab6

May 13th, 2021 (edited)
515
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (setf (get 'car 'model) 'ford
  2.       (get 'car 'motor) 'engine
  3.       (get 'engine 'horse_power) 340
  4.       (get 'engine 'cylinders) 8
  5.       (get 'car 'seats) 4
  6.       (get 'car 'wheels) 4
  7.       (get 'car 'trunk) 'trunk
  8.       (get 'trunk 'capacity) 50
  9.       (get 'trunk 'content) nil
  10. )
  11. NIL
  12.  
  13. (defun put_in_trunk (L)
  14.   (cond ((eql (get 'trunk 'content) NIL) (setf (get 'trunk 'content)  L))
  15.         (T (setf (get 'trunk 'content) (append (get 'trunk 'content) L)))
  16.         )
  17.   )
  18.  
  19. PUT_IN_TRUNK
  20.  
  21. (get 'trunk 'content)
  22. NIL
  23.  
  24. (put_in_trunk '(shardblade shardplate soulcaster))
  25.  
  26.  
  27. (put_in_trunk '(Kaladin Syl Rock Teft Chull_Dung Lopen))
  28.  
  29. (defun get_from_trunk (item)
  30.   (cond ((null item) nil)
  31.         ((null (get 'trunk 'content)) nil)
  32.         (T (mapcar (lambda (i)
  33.                   (cond ((null i) nil)
  34.                         ((null (member i (get 'trunk 'content))) nil)
  35.                         (T (delete i (get 'trunk 'content)))
  36.                         ))
  37.                   item))
  38.      )
  39.   )
  40. GET_FROM_TRUNK
  41.  
  42. (get_from_trunk '(Teft))
  43. ((SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL ROCK CHULL_DUNG LOPEN))
  44. (get_from_trunk '(Rock Chull_dung))
  45. ((SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL LOPEN) (SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL LOPEN))
  46. (SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL LOPEN)
  47. (get_from_trunk '(Syl Lopen))
  48. ((SHARDBLADE SHARDPLATE SOULCASTER KALADIN) (SHARDBLADE SHARDPLATE SOULCASTER KALADIN))
  49. (put_in_trunk '(Syl))
  50. (SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL)
  51. (SHARDBLADE SHARDPLATE SOULCASTER KALADIN SYL)
RAW Paste Data