So quoting works like everything you put ' in front of becomes the literal thing you're seeing.. What it means is that it WONT be seen as a variable and lisp won't try to turn it into it's value, which it got from either being a parameter or a variable.
Here is how to translate a line of code into a line of code calling a function that does the same:
- Code: Select all
;; When you're looking for symbol A in list (W E A D E) you do:
(member 'A '(W E A D E)) ; ==> (A D E)
;; make it a function
(defun myfind (needle haystack)
(member needle haystack)) ; neither needle nor haystack should be quoted!
;; but when you use them in the same manner as member you need to quote the literal values
(myfind 'A '(W E A D E)) ; == >(A D E)
;; Now you might have one or both as variables. Lets make em..
(setq W 'A) ; A is a literal since it's quoted with '
(setq list '(W E A D E)) ; (W E A D E) is a literal since it's quoted
;; no lets try using them
(myfind 'W list) ; ==> (W E A D E) since the 'W doesnæt mean the variable but literal W
(myfind W list) ; ==> (A D E) since W means the variable W which happens to be bound to literal A
So, as you can see. When we use variables we defenitely don't quote them. It's ONLY when we want A to mean the symbol When you use variables you don't quote.
Hope this helps