我有以下数据结构:
{:file #<File /foo.bar>, :resolution {:width 1280, :height 1024}}
我想编写一个将:resolution
密钥解构为width
和height
符号的函数。像
(defn to-directory-name [{{:keys [width height]}} wallpaper]
(str width "x" height))
这种类似的东西可能会被解构吗?
感谢。
答案 0 :(得分:18)
你必须首先解构:分辨率,然后获得宽度和高度:
{{:keys [width height]} :resolution}
答案 1 :(得分:4)
(defn to-directory-name [{{width :width height :height} :resolution}]
(str width "x" height))
适合我。