3
나는 숙제를하려고합니다. 다음 컬렉션이 있습니다.자녀 - 부모 관계
(defparameter *tuples*
'((has bird feathers)
(color budgie yellow)
(eats budgie seed)
(color tweetie green)
(isa tweetie budgie)
(isa budgie bird)
))
다음 테스트를 통과하는 방식으로 작동시켜야합니다.
(forevery (' ((isa ?b budgie) (eats budgie ?x)) *tuples*)
(format t "~&~a" #?x) #?x)
종자를 반환
(inherit tuples 'tweetie 'heart-rate) => nil
(inherit tuples 'tweetie 'color) => green
(inherit tuples 'tweetie 'eats) => seeds
(inherit tuples 'tweetie 'has) => feathers
내가 예를 들어 트위티의 값을 지정하면 일을 관리했다.
하지만
(forevery (' ((isa ?b budgie) (eats tweetie ?x)) *tuples*)
(format t "~&~a" #?x) #?x)
은 nil을 반환, 그래서 어떻게 테스트 할 때 (eats tweetie ?x)
종자를 반환해야하고 (has tweetie ?x)
깃털을 반환해야합니다 그래서 값이 지정된 부모를 위해 일치 할 수 있습니다.
감사합니다.
소장품이 있습니까? 아니면 다른 데이터 구조를 사용할 수 있습니까? 관계의 구조를 반영하는 다른 데이터 구조가 당신의 삶을 더 쉽게 만들 수 있습니다 ... – RonaldBarzell