I am trying to use cl-labels, but i have run into errors i do not understand. Here is elisp code i am using:
(defun nthelt (N ARRAY) "Behaves like nth but for arrays" (if (and (>= N 0) (< N (length ARRAY))) (elt ARRAY N) nil)) (defvar *neraser-board* [(*sync* . 7) (*cell* . 3) (*cell* . 2) (*cell* . 2)]) (defun neraser-check-victory () "Check if victory or loss condition (weak) has been reached" (cl-labels ((victory-key (board-elem) (cond ((eq (car board-elem) '*c-sync*) (nthelt 0 (cdr board-elem))) ((eq (car board-elem) '*sync*) (cdr board-elem)) (t 0)))) (let ((victory-index (position 0 *neraser-board* :key 'victory-key :test-not 'eq))) (if (null victory-index) (message "Congratulations!")))))
When i try to run
neraser-check-victory, i get this error:
Debugger entered--Lisp error: (void-function victory-key)
How can i resolve this error?