Guest User

Untitled

a guest
May 17th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.54 KB | None | 0 0
  1. ;; a silly struct and two silly functions that use it:
  2. (defstruct person name)
  3.  
  4. (defun print-hello (person)
  5.   (let ((name (string-upcase (person-name person))))
  6.     (format t "HI, ~A!" name)))
  7.  
  8. (defun make-name-upcase (person)
  9.   (let ((name (string-upcase (person-name person))))
  10.     (setf (person-name person) name)))
  11.  
  12. ;; first use case, name is just a string:
  13. (defvar bob (make-person "Bob"))
  14. (print-hello bob)
  15. (make-name-upcase bob)
  16.  
  17. ;; change name to be an array of strings:
  18. (defvar bob (make-person (vector "Bob" "Featherstone")))
Add Comment
Please, Sign In to add comment