Beginners Question - Can't manipulate a local variable
Posted: Sat Jan 02, 2010 4:20 pm
Hi all,
I'm having a problem trying to get a local-variable in my Lisp code to be manipulated. I have no idea why it refuses to change!
Here is the code:
game-rating does not seem to increment for some reason.
Any help will be appreciated.
I'm having a problem trying to get a local-variable in my Lisp code to be manipulated. I have no idea why it refuses to change!
Here is the code:
Code: Select all
(setf list ((title "New Super Mario Bros. Wii")
(genre "Platform")
(platform "Wii")))
(defun rate (&optional title genre platform)
(dolist (element list) ; element is the specific game. In this case, New Super Mario Bros. Wii.
(setf element (append element '((rating 0))))
(let ((game-rating 0))
(dolist (e element) ; e will be each attibute in the element, such as (genre "Platform").
(cond ((equal (second e) title) (+ game-rating 1))
((equal (second e) genre) (+ game-rating 1))
((equal (second e) platform) (+ game-rating 1))))
(setf (second (assoc 'rating elem)) game-rating)
(print element))))
Any help will be appreciated.