访问嵌套结构槽

时间:2016-12-05 16:59:15

标签: lisp common-lisp

我有以下结构:

(defstruct track 
    size 
    env 
    startpos 
    endpositions)

(defstruct state 
    pos 
    vel
    action
    cost
    track
    other)

我有一个州,我试图访问endpositions(列表列表)

(setq coluna_final (nth 1 (nth 0 (state-track-endpositions st))))

但我收到错误:EVAL: undefined function STATE-TRACK-ENDPOSITIONS

我做错了什么?

1 个答案:

答案 0 :(得分:2)

第一个defstruct定义(尤其)函数track-endpositions,第二个定义state-track。 Lisp无法知道后者返回track(即使您声明了插槽类型,它也不会定义您想要的函数)。

你可以自己做:

(defun state-track-endpositions (st)
  (track-endpositions (state-track st)))
相关问题