(defn returnLoc [obj-data super-cat]
;If the list passed through is not empty
(if-not (empty? obj-data)
;If the super-category passed in (i.e. Fruit/Agent) is equal
;to the Super-Category (the second object in the first row)
(if (= super-cat (nth (first obj-data) 2))
;Recurvisely goes through the same process as above,
;To see if there is any other records in the list with the same super-cat
;then finds the location of the object and conj[oin]'s that to the returned values
(conj (returnLoc (rest obj-data) super-cat)
(nth (first obj-data) 3))
;If the super-cat passed through is not equal, it does not add it to the list
;And recursively goes back through to check if there are any other possible items to add to
;the list.
(returnLoc (rest obj-data) super-cat)
)
())
)
正如你可以看到,我返回OBJ-數據的第3個值一旦代碼已經找到了比賽,有沒有辦法在那裏我能得到OBJ-數據的第2個值,每次3日返回,然後在末尾添加一個分隔符,將2個值連接到返回列表的方法?
它當前返回一個項目的位置(fruit/agent),但我希望它返回特定的項目和位置。
所以它看起來像:
(returnLoc obj-data 'agent)
回報:
=>(hallway bedroom)
理想的地方,我想它返回:
=>(tom is in hallway | jerry is in bedroom)
有沒有人對如何解決做這個?