32 lines
893 B
Common Lisp
32 lines
893 B
Common Lisp
;;; PACKAGES 4: FIND-SYMBOL AND INTERN (solution)
|
|
|
|
(defpackage #:attic
|
|
(:use #:common-lisp)
|
|
(:export #:heirloom))
|
|
|
|
(in-package #:attic)
|
|
|
|
(defun heirloom ()
|
|
'grandmas-ring)
|
|
|
|
(in-package #:common-lisp-user)
|
|
|
|
(defun attic-lookup (name)
|
|
(find-symbol name 'attic))
|
|
|
|
(defun attic-intern (name)
|
|
(intern name 'attic))
|
|
|
|
;;; ------------------------------------------------------------------
|
|
;;; Checks. Read them - they tell you what to aim for - but leave
|
|
;;; them unchanged.
|
|
;;; ------------------------------------------------------------------
|
|
|
|
(check-equal '(attic:heirloom :external)
|
|
(multiple-value-list (attic-lookup "HEIRLOOM")))
|
|
(check-equal '(nil nil)
|
|
(multiple-value-list (attic-lookup "GHOST")))
|
|
(check (attic-intern "SPARE-KEY"))
|
|
(check-equal "SPARE-KEY" (symbol-name (attic-intern "SPARE-KEY")))
|
|
(check (eq 'attic:heirloom (attic-intern "HEIRLOOM")))
|