我有这个变量,手,当我自己定义它时工作得很好.
(def yourHand
(map
;;fn
#(let [x %]
(cond
;;hearts
(< x 10) (* x -1)
(< x 13) -10
;;diamonds
(< x 23) (* (mod x 13) -1)
(< x 26) -10
;;clubs
(< x 36) (mod x 13)
(< x 39) 10
;;spades
(< x 49) (mod x 13)
(< x 52) 10
))
;;list
(take (rand-int 12) (repeatedly #(+ 1 (rand-int 52))))))
Run Code Online (Sandbox Code Playgroud)
我想在这个函数中使用这个变量.当我首先定义变量然后在函数中使用它的名称时,这很好用.
(reduce + (vec (map #(let [x %]
(cond
(= x 1) 1
:else 0 …Run Code Online (Sandbox Code Playgroud)