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