0

I want to write a function/macro that will write a macro that will create a list structure. What's a good place to start. I'm looking to do something like (mkList id name phone) and having it result in a (defun (id name phone) (list :id id :name name :phone phone)), preferably with use of &rest. Any Ideas?

3
  • functions defined with defun need a name. in your defun form, the name is missing. Commented Dec 7, 2015 at 6:54
  • Camel case is mostly not used in Common Lisp. Commented Dec 7, 2015 at 6:56
  • FWIW, you probably don't need that macro. The vast majority of problems can (and should) be solved without them. Commented Dec 7, 2015 at 6:57

2 Answers 2

1

This should give you some hints:

CL-USER 39 > (defun foo (l)
               (cons 'list
                     (mapcan (lambda (e)
                               (list (intern (symbol-name e)
                                             (find-package "KEYWORD"))
                                     e))
                             l)))
FOO

CL-USER 40 > (foo '(a b c))
(LIST :A A :B B :C C)
Sign up to request clarification or add additional context in comments.

Comments

0

(defun mkcode (item) (eval (read-from-string item))) Is what's working for me, let's me have a lot of flexibility

1 Comment

This answer seems entirely unrelated to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.