set - setf - setq woes
Posted: Mon Aug 21, 2017 10:49 pm
I'm getting back to playing with newLISP! - Again!! :)
The following code broke when I used setf or setq! Why is that? What is the subtle diffs between the three? I want to grok this ASAP - so that I don't spin my wheel ever again with setting a symbol, etc. TIA
The following code broke when I used setf or setq! Why is that? What is the subtle diffs between the three? I want to grok this ASAP - so that I don't spin my wheel ever again with setting a symbol, etc. TIA
Code: Select all
(set 'vowels '("a", "e", "i", "o", "u"))
;; define a function called pig-latin
(define (in-pig-latin this-word)
(set 'first-letter (first this-word))
(if (find first-letter vowels)
(append this-word "ay") ; concatenate word and "ay"
(append (slice this-word 1) first-letter "ay"))) ; concatenate
;; test the function
(println (in-pig-latin "red"))
(println (in-pig-latin "orange"))
(exit 0)
;; output is
;;edray
;;orangeay
;;Notes: the setf and setq function BROKE the code when I tried to use them
;; Why was that? When is setf and setq used in NL?