Skip to content

13-14 修改语句拗口问题 #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Dec 8, 2020
Merged

13-14 修改语句拗口问题 #631

merged 37 commits into from
Dec 8, 2020

Conversation

andyphone
Copy link
Contributor

13-14 修改语句拗口问题 2


### iterate()

`Stream.iterate()` 产生的流的第一个元素是种子(iterate方法的第一个参数),然后将种子传递给方法(iterate方法的第二个参数)。方法运行的结果被添加到流(作为流的第二个元素),并存储起来作为下次调用 `iterate()`时的第一个参数,以此类推。我们可以利用 `iterate()` 生成一个斐波那契数列。代码示例:
`Stream.iterate()` 产生的流的第一个元素是种子(iterate方法的第一个参数),然后将种子传递给方法(iterate方法的第二个参数)。方法运行的结果被添加到流(作为流的第二个元素),并存储起来在下次调用 `iterate()`方法时作为第一个参数,以此类推。我们可以利用 `iterate()` 生成一个斐波那契数列(上一章已经遇到过Fibonacci)。代码示例:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并存储起来在下次调用 iterate()方法时作为第一个参数,

这个改了之后明显更拗口了吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问问群里的人吧。随便加我进群。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问问群里的人吧。随便加我进群。

qq 名同样么?好久没看群了。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8301是我

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字就是 8301 ?没看到。。如果是 qq 号几位太难找了。。。

@@ -1491,17 +1491,17 @@ public class CurriedIntAdd {
## 纯函数式编程


即使没有函数式支持,像 C 这样的基础语言,也可以按照一定的原则编写纯函数式程序。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。
没有函数式支持的语言,甚至像 C 这样的基础语言,只要多加练习也可以写出纯函数式程序。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个有多加练习的意思么?

It’s possible, with much discipline, to write pure functional programs in languages without functional support, even in a language as primitive as C.

noun
1.
the practice of training people to obey rules or a code of behavior, using punishment to correct disobedience.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

甚至像 C 这样的基础语言

应该翻译成原始语言更好一些

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activity, exercise, or a regimen that develops or improves a skill; training

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activity, exercise, or a regimen that develops or improves a skill; training

这个是哪个词典给的释义

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collinsdictionary

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
「则可以用 Scala(需要遵循一些规则) 或 Clojure (遵循的规则更少)」
看了确实是有这个释义,那这里的翻译也要改掉

@andyphone
Copy link
Contributor Author

andyphone commented Dec 8, 2020 via email


### iterate()

`Stream.iterate()` 产生的流的第一个元素是种子(iterate方法的第一个参数),然后将种子传递给方法(iterate方法的第二个参数)。方法运行的结果被添加到流(作为流的第二个元素),并存储起来作为下次调用 `iterate()`时的第一个参数,以此类推。我们可以利用 `iterate()` 生成一个斐波那契数列。代码示例:
`Stream.iterate()` 产生的流的第一个元素是种子(iterate方法的第一个参数),然后将种子传递给方法(iterate方法的第二个参数)。方法运行的结果被添加到流(作为流的第二个元素),也会被存储起来,作为下次调用 `iterate()`方法时的第一个参数,以此类推。我们可以利用 `iterate()` 生成一个斐波那契数列(上一章已经遇到过Fibonacci)。代码示例:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「会被存储起来,作为下次调用 iterate()方法时的第一个参数」
这里的翻译校准

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

方法运行的结果被添加到流(作为流的第二个元素),也会被存储起来,作为下次调用 iterate()方法时的第一个参数

改成

方法运行的结果被添加到流(成为流的下一个元素),并被存储起来,作为下次调用 iterate()方法时的第一个参数

@@ -1491,17 +1491,17 @@ public class CurriedIntAdd {
## 纯函数式编程


即使没有函数式支持,像 C 这样的基础语言,也可以按照一定的原则编写纯函数式程序。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。
只要多加练习,用没有函数式支持的语言也可以写出纯函数式程序,即使是 C 这样的原始语言。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。

这种情况下,我们可以借助第三方工具[^9],但使用 Scala 或 Clojure 这样的语言可能更简单。因为它们从一开始就是为保持不变性而设计的。你可以采用这些语言来编写你的 Java 项目的一部分。如果必须要用纯函数式编写,则可以用 Scala(需要遵循一些规则) 或 Clojure (遵循的规则更少)。虽然 Java 支持[并发编程](./24-Concurrent-Programming.md),但如果这是你项目的核心部分,你应该考虑在项目部分功能中使用 `Scala` 或 `Clojure` 之类的语言。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「则可以用 Scala(需要遵循一些规则) 或 Clojure (遵循的规则更少)」
这里原文有翻译错误。原文需要改进翻译

@@ -1491,17 +1491,17 @@ public class CurriedIntAdd {
## 纯函数式编程


即使没有函数式支持,像 C 这样的基础语言,也可以按照一定的原则编写纯函数式程序。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。
只要多加练习,用没有函数式支持的语言也可以写出纯函数式程序,即使是 C 这样的原始语言。Java 8 让函数式编程更简单,不过我们要确保一切是 `final` 的,同时你的所有方法和函数没有副作用。因为 Java 在本质上并非是不可变语言,所以编译器对我们犯的错误将无能为力。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只要多加练习,用没有函数式支持的语言也可以写出纯函数式程序(即使是 C 这样的原始语言)

用括号感觉更好一些

@sjsdfg sjsdfg merged commit 4cf57da into lingcoder:master Dec 8, 2020
andyphone added a commit to andyphone/OnJava8 that referenced this pull request Dec 8, 2020
13-14 修改语句拗口问题 (lingcoder#631)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants