SHARE
TWEET

Untitled

skidd0 Jun 21st, 2019 65 Never
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"
  6.  
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top