1

I'm just learning LISP and i am having trouble doing the following:

; return ":h :i"
(defun get-char() 
  (loop for char across "ab" 
        collect (concatenate 'string ":" (string char))))

; plist
(defun get-list() (list :a "1" :b "2"))

; I cannot get this to work 
; <-- returns all null, cannot get plist values :-(
(loop for x in (get-char) 
      collect (getf (get-list) x))

; this works fine...
(loop for x in '(:a :b) 
      collect (getf (get-list) x))

I know im close, but i am just missing something.

Thanks a lot :-)

1
  • 1
    Tip: might want to come up with a more descriptive title than "Simple LISP question" next time. :-) Commented May 8, 2011 at 0:22

1 Answer 1

5

Change the get-char function to return a list of keywords from the characters:

(defun get-char() 
  (loop 
    for char across "ab" 
    collect (intern (string-upcase char) :keyword)))

Evaluating (get-char) => (:A :B). Furthermore:

(loop for x in (get-char) collect (getf (get-list) x))

=>

("1" "2")
Sign up to request clarification or add additional context in comments.

1 Comment

Thats exactly what i wanted - seems a bit cryptic to me, but i am just starting on LISP - it make sense tho :-) - THANK YOU!

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.