gpt4 book ai didi

Clojure:使用散列作为函数可以吗?

转载 作者:行者123 更新时间:2023-12-04 02:18:13 25 4
gpt4 key购买 nike

<分区>

这些都有效:

=> (def hash {:a "potato" :b "pants"})
#'hash
=> (hash :a)
"potato"
=> (:a hash)
"potato"

有什么理由让我更喜欢其中之一吗?我看到更多人在做后者 (:a hash)...为什么?我喜欢前者 (hash :a) 因为它类似于 (-> hash :a :b :c) 的结构,我更喜欢前者 (进入哈希 [:a :b :c])

它们之间是否存在效率差异或其他差异?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com