3

我正在尝试通过哈希图音译列表,如下所示:

(map {"a" 0 "b" 1 "c" 2} ["a","c","b","a"])

我想吐出:

[0,2,1,0]

我该怎么做呢?

更正:上述方法有效,但这不是:

  (map {"a" 0 "b" 1 "c" 2} (vec "acba"))

这里有什么不同?

4

1 回答 1

4

mapv改为使用

user=> (map {"a" 0 "b" 1 "c" 2} ["a" "c" "b" "a"])
(0 2 1 0)
user=> (mapv {"a" 0 "b" 1 "c" 2} ["a" "c" "b" "a"])
[0 2 1 0]

还:

user=> (map {"a" 0 "b" 1 "c" 2} (vec "acba"))
(nil nil nil nil)
user=> (vec "acba")
[\a \c \b \a]
user=> (= \a "a")
false

这有效(但是回旋处):

user=> (mapv {"a" 0 "b" 1 "c" 2} (map str (vec "acba")))
(0 2 1 0)
于 2013-05-06T19:39:28.837 回答