如何删除此clojure代码中的冗余?

如何删除此clojure代码中的冗余?,clojure,Clojure,我编写了以下代码: (defprotocol MusicFile (get-artist [this]) (get-song [this]) (get-album [this])) (defrecord Mp3 [filename] MusicFile (get-artist [this] (let [info (get-all-info (:filename this))] (:artist info)))

我编写了以下代码:

(defprotocol MusicFile
    (get-artist [this])
    (get-song [this])
    (get-album [this]))


(defrecord Mp3 [filename]
    MusicFile
    (get-artist [this]
        (let [info (get-all-info (:filename this))]
            (:artist info)))
    (get-song [this]
        (let [info (get-all-info (:filename this))]
            (:title info)))
    (get-album [this]
        (let [info (get-all-info (:filename this))]
            (:album info))))

是否有一种简单的方法来删除此代码中的冗余?

记录的字段在记录定义中定义的方法的范围内

(defrecord Mp3 [filename]
    MusicFile
    (get-artist [this]
      (:artist (get-all-info filename)))
    (get-song [this]
      (:title (get-all-info filename)))
    (get-album [this]
      (:album (get-all-info filename))))

记录的字段在记录定义中定义的方法范围内

(defrecord Mp3 [filename]
    MusicFile
    (get-artist [this]
      (:artist (get-all-info filename)))
    (get-song [this]
      (:title (get-all-info filename)))
    (get-album [this]
      (:album (get-all-info filename))))

是否有可能创建一个通用访问器,以便您可以像get-Artister[this]get-field this:Artister那样定义get-Artister?您可以很容易地编写一个函数来定义get-field[k t]get-all-info:filename t。是否有可能创建一个通用访问器,以便您可以像get-Artister[this]一样定义get-Artisterget field this:artist?您可以轻松编写一个函数,该函数可以定义get field[k t]get get all info:filename t k