Types “:-”在clojure';s核心类型?
Types “:-”在clojure';s核心类型?,types,clojure,Types,Clojure,:-在core.typed库中是什么意思 (t/ann play-many [(ta/Chan RPSResult) t/Int -> (t/Map t/Any t/Any)]) (defn play-many "Play n matches from out-chan and report a summary of the results." [out-chan n] (t/loop [remaining :- t/Int, n
:-
在core.typed库中是什么意思
(t/ann play-many [(ta/Chan RPSResult) t/Int -> (t/Map t/Any t/Any)])
(defn play-many
"Play n matches from out-chan and report a summary of the results."
[out-chan n]
(t/loop [remaining :- t/Int, n ;; <======== This line
results :- (t/Map PlayerName t/Int), {}]
(if (zero? remaining)
results
(let [[m1 m2 winner] (a/<!! out-chan)]
(assert m1)
(assert m2)
(assert winner)
(recur (dec remaining)
(merge-with + results {winner 1}))))))
(t/ann播放多个[(ta/Chan RPSResult)t/Int->(t/Map t/Any t/Any)])
(defn玩很多游戏
“播放chan的n场比赛,并报告结果摘要。”
[行政长官]
(t/loop[剩余:-t/Int,n;;:-
是单个字符的关键字,-
)
user=> :-
:-
user=> (class :-)
clojure.lang.Keyword
如前所述,:-
只是一个关键字。但是,在您的上下文中,它是核心.typed
注释的一部分,将循环绑定标记为特定类型:
(t/loop [remaining :- t/Int, n
results :- (t/Map PlayerName t/Int), {}]
...)
这意味着,剩余的
是一个整数,而结果
是一个将玩家姓名与整数关联的映射。可以使用核心。键入的
的类型检查器进行验证。它的意思是:-
。打开一个clojure repl,键入:-
,你就会明白我的意思了。