summaryrefslogtreecommitdiffhomepage
path: root/zh-cn
diff options
context:
space:
mode:
Diffstat (limited to 'zh-cn')
-rw-r--r--zh-cn/clojure-cn.html.markdown16
-rw-r--r--zh-cn/go-cn.html.markdown16
-rw-r--r--zh-cn/ruby-cn.html.markdown3
3 files changed, 21 insertions, 14 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)
diff --git a/zh-cn/go-cn.html.markdown b/zh-cn/go-cn.html.markdown
index 7cc9c171..4a87dc21 100644
--- a/zh-cn/go-cn.html.markdown
+++ b/zh-cn/go-cn.html.markdown
@@ -5,6 +5,8 @@ filename: learngo-cn.go
contributors:
- ["Sonia Keys", "https://github.com/soniakeys"]
- ["pantaovay", "https://github.com/pantaovay"]
+ - ["lidashuang", "https://github.com/lidashuang"]
+
---
发明Go语言是出于更好地完成工作的需要。Go不是计算机科学的最新发展潮流,但它却提供了解决现实问题的最新最快的方法。
@@ -30,7 +32,7 @@ import (
)
// 函数声明:Main是程序执行的入口。
-// 不管你喜欢还是不喜欢,反正G就用了花括号来包住函数体。
+// 不管你喜欢还是不喜欢,反正Go就用了花括号来包住函数体。
func main() {
// 往标准输出打印一行。
// 用包名fmt限制打印函数。
@@ -47,7 +49,7 @@ func beyondHello() {
x = 3 // 变量赋值。
// 可以用:=来偷懒,它自动把变量类型、声明和赋值都搞定了。
y := 4
- sum, prod := learnMultiple(x, y) // 多个返回变量的函数
+ sum, prod := learnMultiple(x, y) // 返回多个变量的函数
fmt.Println("sum:", sum, "prod:", prod) // 简单输出
learnTypes() // 少于y分钟,学的更多!
}
@@ -82,7 +84,7 @@ can include line breaks.` // 同样是String类型
var a4 [4] int // 有4个int变量的数组,初始为0
a3 := [...]int{3, 1, 5} // 有3个int变量的数组,同时进行了初始化
- // Slice 有动态大小。Array和Slice各有千秋,但是使用slice的地方更多些。
+ // Slice 可以动态的增删。Array和Slice各有千秋,但是使用slice的地方更多些。
s3 := []int{4, 5, 9} // 和a3相比,这里没有省略号
s4 := make([]int, 4) // 分配一个有4个int型变量的slice,全部被初始化为0
@@ -114,7 +116,7 @@ func learnMemory() (p, q *int) {
s := make([]int, 20) // 给20个int变量分配一块内存
s[3] = 7 // 赋值
r := -2 // 声明另一个局部变量
- return &s[3], &r // & 取址
+ return &s[3], &r // & 取地址
}
func expensiveComputation() int {
@@ -149,7 +151,7 @@ func learnFlowControl() {
// x在这里还是1。为什么?
// for 是go里唯一的循环关键字,不过它有很多变种
- for { // 无限循环
+ for { // 死循环
break // 骗你的
continue // 不会运行的
}
@@ -239,7 +241,7 @@ func learnConcurrency() {
go inc(-805, c)
// 从channel中独处结果并打印。
// 打印出什么东西是不可预知的。
- fmt.Println(<-c, <-c, <-c) // channel在右边的时候,<-是接收操作。
+ fmt.Println(<-c, <-c, <-c) // channel在右边的时候,<-是读操作。
cs := make(chan string) // 操作string的channel
cc := make(chan chan string) // 操作channel的channel
@@ -255,7 +257,7 @@ func learnConcurrency() {
case <-cc: // 空的,还没作好通讯的准备
fmt.Println("didn't happen.")
}
- // 上面c或者cs的值被取到,其中一个goroutine结束,另外一个保持阻塞。
+ // 上面c或者cs的值被取到,其中一个goroutine结束,另外一个一直阻塞。
learnWebProgramming() // Go很适合web编程,我知道你也想学!
}
diff --git a/zh-cn/ruby-cn.html.markdown b/zh-cn/ruby-cn.html.markdown
index 619e6e92..3c47f3f9 100644
--- a/zh-cn/ruby-cn.html.markdown
+++ b/zh-cn/ruby-cn.html.markdown
@@ -6,6 +6,7 @@ contributors:
- ["David Underwood", "http://theflyingdeveloper.com"]
- ["Joel Walden", "http://joelwalden.net"]
- ["Luke Holder", "http://twitter.com/lukeholder"]
+ - ["lidashuang", "https://github.com/lidashuang"]
translators:
- ["Lin Xiangyu", "https://github.com/oa414"]
---
@@ -173,7 +174,7 @@ new_hash = { defcon: 3, action: true}
new_hash.keys #=> [:defcon, :action]
# 小贴士:数组和哈希表都是可枚举的
-# 它们可以共享一些有用的方法,比如each, map, count, 和more
+# 它们可以共享一些有用的方法,比如each, map, count 等等
# 控制流