From 72de48f9e2a371f28deb7bd41d328d5c41c8e245 Mon Sep 17 00:00:00 2001 From: jingege Date: Mon, 6 Jan 2014 09:30:18 +0800 Subject: [clojure/cn]Wrap some lines to fit the view. --- zh-cn/clojure-cn.html.markdown | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/zh-cn/clojure-cn.html.markdown b/zh-cn/clojure-cn.html.markdown index f65dda9d..d5d8232b 100644 --- a/zh-cn/clojure-cn.html.markdown +++ b/zh-cn/clojure-cn.html.markdown @@ -81,7 +81,7 @@ Clojure是运行在JVM上的Lisp家族中的一员。她比Common Lisp更强调 (seq? '(1 2 3)) ; => true (seq? [1 2 3]) ; => false -; 序列被访问时只需要提供一个值,所以序列可以被懒加载 —— 也就意味着可以定义一个无限序列: +; 序列被访问时只需要提供一个值,所以序列可以被懒加载——也就意味着可以定义一个无限序列: (range 4) ; => (0 1 2 3) (range) ; => (0 1 2 3 4 ...) (无限序列) (take 4 (range)) ; (0 1 2 3) @@ -163,11 +163,13 @@ x ; => 1 ; 哈希表 ;;;;;;;;;; -; 基于hash的map和基于数组的map(即arraymap)实现了相同的接口,hashmap查询起来比较快,但不保证元素的顺序。 +; 基于hash的map和基于数组的map(即arraymap)实现了相同的接口,hashmap查询起来比较快, +; 但不保证元素的顺序。 (class {:a 1 :b 2 :c 3}) ; => clojure.lang.PersistentArrayMap (class (hash-map :a 1 :b 2 :c 3)) ; => clojure.lang.PersistentHashMap -; arraymap在足够大的时候,大多数操作会将其自动转换成hashmap,所以不用担心(对大的arraymap的查询性能)。 +; arraymap在足够大的时候,大多数操作会将其自动转换成hashmap, +; 所以不用担心(对大的arraymap的查询性能)。 ; map支持很多类型的key,但推荐使用keyword类型 ; keyword类型和字符串类似,但做了一些优化。 @@ -275,7 +277,7 @@ keymap ; => {:a 1, :b 2, :c 3} (str/replace "This is a test." #"[a-o]" str/upper-case) ; => "THIs Is A tEst." ; (#""用来表示一个正则表达式) -; 你可以在一个namespace定义里用`:require`的方式来require(或者use,但最好不要用)模块。 +; 你可以在一个namespace定义里用:require的方式来require(或use,但最好不要用)模块。 ; 这样的话你无需引用模块列表。 (ns test (:require @@ -314,12 +316,14 @@ keymap ; => {:a 1, :b 2, :c 3} ; STM ;;;;;;;;;;;;;;;;; -; 软件内存事务(Software Transactional Memory)被clojure用来处理持久化的状态。clojure里内置了一些结构来使用STM。 +; 软件内存事务(Software Transactional Memory)被clojure用来处理持久化的状态。 +; clojure里内置了一些结构来使用STM。 ; atom是最简单的。给它传一个初始值 (def my-atom (atom {})) ; 用`swap!`更新atom。 -; `swap!`会以atom的当前值为第一个参数来调用一个指定的函数,`swap`其余的参数作为该函数的第二个参数。 +; `swap!`会以atom的当前值为第一个参数来调用一个指定的函数, +; `swap`其余的参数作为该函数的第二个参数。 (swap! my-atom assoc :a 1) ; Sets my-atom to the result of (assoc {} :a 1) (swap! my-atom assoc :b 2) ; Sets my-atom to the result of (assoc {:a 1} :b 2) -- cgit v1.2.3