Literal values
Sets can be used as predicate functions returning true if the value is within the set
Checking valid playing cards
Define a namespace for the page and require Clojure Spec
(ns practicalli.clojure
(:require [clojure.spec.alpha :as spec]))
(spec/valid? #{:club :diamond :heart :spade} :club)
(spec/valid? #{:club :diamond :heart :spade} 42)
Answer to the ultimate question?
(spec/valid? #{42} 42)
Using sets for literal values is similar to using the clojure.core/contains?
function with a set collection type.
(contains? #{:clubs :diamonds :hearts :spades} :hearts )
当前内容版权归 practicalli 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 practicalli .