Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Last active December 18, 2015 09:29
Show Gist options
  • Save PuercoPop/5761645 to your computer and use it in GitHub Desktop.
Save PuercoPop/5761645 to your computer and use it in GitHub Desktop.
Why does setf (top-left board) fails?
(in-package :cl-user)
;;; Everything now works thanks to Bike and http://stackoverflow.com/questions/11457071/defining-setf-expanders-in-common-lisp
;;; Learned something new today
(defun top-center (board)
(car (cdr board)))
(defun (setf top-center) (value board)
(setf (car (cdr board)) value))
(let ((board (list :1 :2 :3 :4))
(player :empty))
(format t "Board: ~A~%" board)
(setf (top-center board) player)
(format t "Board: ~A~%" board))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment