我有这段代码:
(defparameter fc #\F)
(defparameter bc #\B)
(defparameter gap #\G)
(defun solp (seq)
(if (eql fc (car seq))
(not (if (listp (cdr seq))
(find bc (cdr seq))
(eql seq bc)))
(solp (cdr seq))))
(defun heuristic (seq &optional (f 0))
(if (eql nil seq)
0
(if (eql bc (car seq))
(+ f (heuristic (cdr seq) f))
(heuristic (cdr seq) (+ f 1)))))
(defun genneighbors (seq)
;seq == (fc fc gap bc bc) ===> neighbors == ( (gap fc fc bc bc)
; (fc gap fc bc bc)
; (fc fc bc gap)
; (fc fc bc bc gap) )
;I can't figure out how to do this
)
我无法弄清楚如何编写genneighbors
函数的代码。如何在gap
之前访问元素(2 | 1)插槽如何生成所有四个可能的邻居?有人可以给我一些指示吗?