非常感谢 Steve Tayon 的创建以及 Andy Fingerhut 对其持续维护。
字面量 | Long: 7, 十六进制 0xff, 八进制 017, 二进制 2r1011, 三十六进制 36rCRAZY BigInt: 7N Ratio: -22/7 Double: 2.78 -1.2e-5 BigDecimal: 4.2M |
算术 | + - * / quot rem mod inc dec max min +' -' *' inc' dec' (1.11) abs |
比较 | == < > <= >= compare |
按位操作 | bit-and bit-or bit-xor bit-not bit-flip bit-set bit-shift-right bit-shift-left bit-and-not bit-clear bit-test unsigned-bit-shift-right (参见 BigInteger 获取大于 Long 的整数) |
强制类型转换 | byte short int long float double bigdec bigint num rationalize biginteger |
测试 | zero? pos? neg? even? odd? number? rational? integer? ratio? decimal? float? (1.9) double? int? nat-int? neg-int? pos-int? (1.11) NaN? infinite? |
随机数 | rand rand-int |
BigDecimal | with-precision |
未经检查的 | *unchecked-math* unchecked-add unchecked-dec unchecked-inc unchecked-multiply unchecked-negate unchecked-subtract |
创建 | str format "a string" "转义字符 \b\f\n\t\r\" 八进制 \377 十六进制 \ucafe" 另请参阅 IO/to string 部分 |
使用 | count get subs compare (clojure.string/) join escape split split-lines replace replace-first reverse index-of last-index-of (1.11) (clojure.core/) parse-boolean parse-double parse-long parse-uuid |
正则表达式 | #"pattern" re-find re-seq re-matches re-pattern re-matcher re-groups (clojure.string/) replace replace-first re-quote-replacement 注意: |
字母 | (clojure.string/) capitalize lower-case upper-case |
修剪 | (clojure.string/) trim trim-newline triml trimr |
测试 | string? (clojure.string/) blank? starts-with? ends-with? includes? |
字符 | char char? char-name-string char-escape-string 字面量: \a \newline (更多请点击链接) |
关键字 | keyword keyword? find-keyword 字面量: :kw :my.name.space/kw ::in-cur-namespace ::namespace-alias/kw |
符号 | symbol symbol? gensym 字面量: my-sym my.ns/foo |
其他 | 字面量: true false nil |
通用操作 | count empty not-empty into conj (clojure.walk/) walk prewalk prewalk-demo prewalk-replace postwalk postwalk-demo postwalk-replace (1.9) bounded-count |
内容测试 | distinct? empty? every? not-every? some not-any? |
功能 | sequential? associative? sorted? counted? reversible? |
类型测试 | coll? list? vector? set? map? seq? record? map-entry? |
创建 | () list list* |
检查 | first nth peek .indexOf .lastIndexOf |
'改变' | cons conj rest pop |
创建 | [] vector vec vector-of mapv filterv |
检查 |
|
'改变' | assoc assoc-in pop subvec replace conj rseq update update-in |
操作 | reduce-kv |
创建无序集合 | #{} set hash-set |
创建有序集合 | sorted-set sorted-set-by (clojure.data.avl/) sorted-set sorted-set-by (flatland.ordered.set/) ordered-set (clojure.data.int-map/) int-set dense-int-set |
检查 |
|
'改变' | conj disj |
集合操作 | (clojure.set/) union difference intersection select 另见关系部分 |
测试 | (clojure.set/) subset? superset? |
有序集合 | rseq subseq rsubseq |
创建无序集合 | {} hash-map array-map zipmap bean frequencies group-by (clojure.set/) index |
创建有序集合 | sorted-map sorted-map-by (clojure.data.avl/) sorted-map sorted-map-by (flatland.ordered.map/) ordered-map (clojure.data.priority-map/) priority-map (flatland.useful.map/) ordering-map (clojure.data.int-map/) int-map |
检查 |
|
'改变' | assoc assoc-in dissoc merge merge-with select-keys update update-in (clojure.set/) rename-keys map-invert (1.11) (clojure.core/) update-keys update-vals GitHub: Medley |
操作 | reduce-kv |
条目 | key val |
有序映射 | rseq subseq rsubseq |
创建 | clojure.lang.PersistentQueue/EMPTY(没有字面语法或构造函数) |
检查 | peek |
'改变' | conj pop |
关系代数 | (clojure.set/) join select project union difference intersection index rename |
创建 | transient persistent! |
更改 | conj! pop! assoc! dissoc! disj! 注意:始终使用返回值进行后续更改,不要使用原始值! |
比较 | = identical? not= not compare clojure.data/diff |
测试 | true? false? instance? nil? some? |
从集合 | seq vals keys rseq subseq rsubseq sequence |
来自生产者函数 | lazy-seq repeatedly iterate (1.11) iteration |
来自常量 | repeat range |
来自其他 | file-seq line-seq resultset-seq re-seq tree-seq xml-seq iterator-seq enumeration-seq |
来自 seq | keep keep-indexed |
提取元素 | first second last rest next ffirst nfirst fnext nnext nth nthnext rand-nth when-first max-key min-key |
构造集合 | zipmap into reduce reductions set vec into-array to-array-2d mapv filterv |
传递给 fn | 应用 |
搜索 | some filter |
强制求值 | doseq dorun doall run! |
检查是否强制 | realized? |
现成的 | map mapcat filter remove take take-while take-nth drop drop-while replace partition-by partition-all keep keep-indexed map-indexed distinct interpose cat dedupe random-sample (1.9) halt-when |
创建你自己的 | completing ensure-reduced unreduced 另请参阅部分 并发/易变 |
使用 | into sequence transduce eduction |
提前终止 | reduced reduced? deref |
操作 | valid? conform unform explain explain-data explain-str explain-out form describe assert check-asserts check-asserts? |
生成器操作 | gen exercise exercise-fn |
Defn。& 注册表 | def fdef registry get-spec spec? spec with-gen |
逻辑 | and or |
集合 | coll-of map-of every every-kv keys merge |
正则表达式 | 正则表达式操作符 |
cat alt * + ? & keys* | 范围 |
其他 | int-in inst-in double-in int-in-range? inst-in-range? |
可空和动态规范 | nilable multi-spec fspec conformer |
数字 | explain-printer *explain-out* |
具有test.check生成器的谓词 | number? rational? integer? ratio? decimal? float? zero? (1.9) double? int? nat-int? neg-int? pos-int? |
符号和关键字 | string? true? false? nil? some? (1.9) boolean? bytes? inst? uri? uuid? |
集合 | list? map? set? vector? associative? coll? sequential? seq? empty? (1.9) indexed? seqable? |
其他 | (1.9) any? |
to/from ... | spit slurp (to writer/from reader,Socket,带有文件名的字符串,URI 等等) |
to *out* | pr prn print printf println newline (clojure.pprint/) print-table |
to writer | (clojure.pprint/) pprint cl-format 另外: (binding [*out* writer] ...) |
to string | format with-out-str pr-str prn-str print-str println-str |
from *in* | read-line (clojure.edn/) read (clojure.tools.reader.edn/) read |
from reader | line-seq (clojure.edn/) read (clojure.tools.reader.edn/) read 另外: (binding [*in* reader] ...) java.io.Reader |
from string | with-in-str (clojure.edn/) read-string (clojure.tools.reader.edn/) read-string |
Open | with-open (clojure.java.io/) text: reader writer binary: input-stream output-stream |
二进制 | (.write ostream byte-arr) (.read istream byte-arr) java.io.OutputStream java.io.InputStream GitHub: gloss byte-spec |
其他 | flush (.close s) file-seq *in* *out* *err* (clojure.java.io/) file copy delete-file resource as-file as-url as-relative-path GitHub: fs |
数据读取器 | *data-readers* default-data-readers *default-data-reader-fn* |
tap | (1.10) tap> add-tap remove-tap |
创建 | fn defn defn- definline identity constantly memfn comp complement partial juxt memoize fnil every-pred some-fn |
调用 | apply -> ->> trampoline as-> cond-> cond->> some-> some->> |
测试 | fn? ifn? |
定义 |
|
扩展 |
|
扩展 null |
|
Reify |
|
测试 | satisfies? extends? |
其他 | extend extend-protocol extenders |
定义 |
|
访问 |
|
创建 | Pair. ->Pair map->Pair |
测试 | record? |
定义 |
|
访问 |
|
创建 | Pair. ->Pair |
带方法 |
|
定义 |
|
方法定义 |
|
分派 | get-method methods |
移除 | remove-method remove-all-methods |
优先 | prefer-method prefers |
关系 | derive underive isa? parents ancestors descendants make-hierarchy |
创建 | defmacro definline |
调试 | macroexpand-1 macroexpand (clojure.walk/) macroexpand-all |
分支 | and or when when-not when-let when-first if-not if-let cond condp case when-some if-some |
循环 | for doseq dotimes while |
排列 | .. doto -> ->> as-> cond-> cond->> some-> some->> |
范围 | binding locking time with-in-str with-local-vars with-open with-out-str with-precision with-redefs with-redefs-fn |
延迟 | lazy-cat lazy-seq delay |
文档。 | assert comment doc |
, |
逗号被解读为空格。通常用于 map 的键值对之间,以提高可读性。 |
' |
quote: |
/ |
命名空间分隔符(参见基本类型/其他部分) |
\ |
字符字面量(参见基本类型/其他部分) |
: |
关键字(参见基本类型/其他部分) |
; |
单行注释 |
^ |
元数据(参见元数据部分) |
*foo* |
'earmuffs' - 约定用于指示 动态变量,编译器会对非动态变量发出警告 |
@ |
Deref: |
` |
语法引用 |
foo# |
'auto-gensym',在相同的 |
~ |
取消引用 |
~@ |
取消引用拼接 |
-> |
'thread first' 宏 -> |
->> |
'thread last' 宏 ->> |
>!! <!! >! <! |
core.async 通道宏 >!! <!! >! <! |
( |
列表字面量(参见集合/列表部分) |
[ |
向量字面量(参见集合/向量部分) |
{ |
映射字面量(参见集合/映射部分) |
#' |
变量引用: |
#" |
#"p" 被解读为正则表达式模式 p(参见字符串/正则表达式部分) |
#{ |
集合字面量(参见集合/集合部分) |
#( |
匿名函数字面量: |
% |
匿名函数参数: |
#? |
读取器条件: |
#?@ |
拼接读取器条件: |
#foo |
带标记的字面量 例如 |
#: |
映射命名空间语法 例如 |
## |
(1.9) 符号值: |
$ |
|
foo? |
谓词的常规结尾,例如:zero? vector? instance?(未强制执行) |
foo! |
不安全操作的常规结尾,例如:set! swap! alter-meta!(未强制执行) |
_ |
未使用的值的常规名称(未强制执行) |
#_ |
忽略下一行代码 |
通用 |
|
缩写 |
|
常用 |
|
示例 |
|
在变量上 | meta with-meta vary-meta alter-meta! reset-meta! doc find-doc test |
绑定形式/解构 | (示例) let fn defn defmacro loop for doseq if-let when-let if-some when-some |
Def 变体 | def defn defn- definline defmacro defmethod defmulti defonce defrecord |
内部变量 | declare intern binding find-var var |
Var 对象 | with-local-vars var-get var-set alter-var-root var? bound? thread-bound? |
Var 验证器 | set-validator! get-validator |
当前 | *ns* |
创建/切换 | (教程) ns in-ns create-ns |
添加 | alias def import intern refer |
查找 | all-ns find-ns |
检查 | ns-name ns-aliases ns-map ns-interns ns-publics ns-refers ns-imports |
从符号 | resolve ns-resolve namespace the-ns (1.10) requiring-resolve |
移除 | ns-unalias ns-unmap remove-ns |
加载库 | (教程) require use import refer |
列出已加载的 | loaded-libs |
加载其他 | load load-file load-reader load-string |
创建 | ref |
检查 | deref @ ( |
事务 | sync dosync io! |
在事务中 | ensure ref-set alter commute |
验证器 | set-validator! get-validator |
历史 | ref-history-count ref-min-history ref-max-history |
通用 | .. doto 类名/ 类名. new bean comparator enumeration-seq import iterator-seq memfn set! class class? bases supers type gen-class gen-interface definterface |
强制类型转换 | boolean byte short char int long float double bigdec bigint num cast biginteger |
异常 | throw try catch finally pst ex-info ex-data Throwable->map (1.9) StackTraceElement->vec (1.10) ex-cause ex-message (clojure.main/) ex-triage ex-str err->msg report-error |
创建 | proxy get-proxy-class construct-proxy init-proxy |
其他 | proxy-mappings proxy-super update-proxy |
创建 | zipper seq-zip vector-zip xml-zip |
获取位置 | up down left right leftmost rightmost |
获取序列 | lefts rights path children |
'改变' | make-node replace edit insert-child insert-left insert-right append-child remove |
移动 | next prev |
其他 | root node branch? end? |
XML | clojure.xml/parse xml-seq |
REPL | *1 *2 *3 *e *print-dup* *print-length* *print-level* *print-meta* *print-readably* |
代码 | *compile-files* *compile-path* *file* *warn-on-reflection* compile loaded-libs test |
其他 | eval force hash name *clojure-version* clojure-version *command-line-args* (1.11) random-uuid |
浏览器/shell | (clojure.java.browse/) browse-url (clojure.java.shell/) sh with-sh-dir with-sh-env |