Jun 21st, 2019
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; I want to print out the name of a variable then it's contents for a list of
  2. ;; variables, but only if the variable has data.
  3. ;; Ideal Output:
  4. ;; var1: "one"
  5. ;; var3: "three"
  7. ;; Here's what I tried:
  8. (let ((var1 "one")
  9. (var2 nil)
  10. (var3 "three"))
  11. (loop for var in (list var1 var2 var3)
  12. do (if var
  13. (format t "~A: ~A~%"
  14. (symbol-name var)
  15. var))))
  16. ;; It complains the "one" is not a symbol, which makes sense. The loop is being
  17. ;; passed the contents of var1, var2, var3, but not the symbols themselves.
RAW Paste Data