Loading...
墨滴

逸之

2022/01/03  阅读:39  主题:红绯

About This Book CS3110

About This Book CS3110 关于本书 CS3110

Reporting Errors. If you find an error, please report it! Or if you have a suggestion about how to rewrite some part of the book, let us know. Just go to the page of the book for which you'd like to make a suggestion, click on the Github icon (it looks like a cat) near the top right of the page, and click "open issue" or "suggest edit". The latter is a little heavier weight, because it requires you to fork the textbook repository with Github. But for minor edits that will be appreciated and lead to much quicker uptake of suggestions.

报告错误。如果发现错误,请报告!或者如果你对如何重写这本书的某些部分有什么建议,让我们知道。只需进入你想提建议的书页,点击页面右上角的 Github 图标(看起来像猫) ,然后点击“打开问题”或“建议编辑”。后者的权重稍重一些,因为它要求您使用 Github 为教科书存储库提供支持。但是对于一些小的编辑来说,这将会得到赞赏,并且导致更快地采纳建议。

Background. This book is used at Cornell for a third-semester programming course. Most students have had one semester of introductory programming in Python, followed by one semester of object-oriented programming in Java. Frequent comparisons are therefore made to those two languages. Readers who have studied similar languages should have no difficulty following along. The book does not assume any prior knowledge of functional programming, but it does assume that readers have prior experience programming in some mainstream imperative language. Knowledge of discrete mathematics at the level of a standard first-semester CS course is also assumed.

背景。这本书在康奈尔大学用于第三学期的程序设计课程。大多数学生已经学过一个学期的 Python 编程入门课程,然后是一个学期的 Java 面向对象程序设计。因此,经常对这两种语言进行比较。学过类似语言的读者应该不难跟上。这本书并没有假设任何函数式编程的先验知识,但是它确实假设读者在一些主流命令式语言中有先验的编程经验。在标准的第一学期计算机科学课程水平的离散数学知识也被假定。

Videos. You will find over 200 YouTube videos embedded throughout this book. The videos usually provide an introduction to material, upon which the textbook then expands. These videos were produced during pandemic when the Cornell course that uses this textbook, CS 3110, had to be asynchronous. The student response to them was overwhelmingly positive, so they are now being made public as part of the textbook. But just so you know, they were not produced by a professional A/V team—just a guy in his basement who was learning as he went.

视频。你可以在这本书中找到200多个 YouTube 视频。视频通常提供材料的介绍,然后教科书扩展。这些视频是在大流行期间制作的,当时康奈尔大学的课程使用这本教科书,CS 3110,必须是异步的。学生们对这些内容的反应非常积极,所以这些内容现在已经作为教科书的一部分公开了。但是你要知道,他们不是由一个专业的 a/v 团队制作的,只是一个在地下室边走边学的家伙。

The videos mostly use the versions of OCaml and its ecosystem that were current in Fall 2020. Current versions you are using are likely to look different from the videos, but don't be alarmed: the underlying ideas are the same. The most visible difference is likely to be the VS Code plugin for OCaml. In Fall 2020 the badly-aging "OCaml and Reason IDE" plugin was still being used. It has since been superseded by the "OCaml Platform" plugin.

这些视频大部分使用了 OCaml 的版本和它的生态系统,这些都是2020年秋天流行的。你现在使用的版本可能看起来和视频不同,但是不要惊慌: 基本的想法是一样的。最明显的区别可能是 OCaml 的 VS Code 插件。2020年秋天,老化严重的“ OCaml 和 Reason IDE”插件仍在使用。它已经被“ OCaml 平台”插件所取代。

The order that the textbook covers topics sometimes differs from the order that the videos cover the topics, simply because the videos originate from lectures. The videos are placed in the textbook nearest to the topic they cover, but that does mean sometimes the videos are not in chronological order. To watch them in their original order, start with this YouTube playlist.

教科书涵盖主题的顺序有时与视频涵盖主题的顺序不同,仅仅是因为视频来自讲座。视频被放置在教科书中最接近他们所涵盖的主题,但这确实意味着有时视频不是按时间顺序排列的。要按照原来的顺序观看这些视频,可以从这个 YouTube 播放列表开始。

Collaborative Annotations. At the right margin of each page, you will find an annotation feature provided by hypothes.is. You can use this to highlight and make private notes as you study the text. You can form study groups to share your annotations, or share them publicly. Check out these tips for how to annotate effectively.

协作注释。在每个页面的右边,你会发现一个由 prosist.is 提供的注释特性。你可以在学习文本的时候用它来突出显示和做私人笔记。你可以成立学习小组来分享你的注释,或者公开分享。看看这些如何有效注释的技巧。

Executable Code. Many pages of this book have OCaml code embedded in them. The output of that code is already shown in the book. Here's an example:

可执行代码。这本书的许多页面都嵌入了 OCaml 代码。该代码的输出已经在本书中显示。下面是一个例子:

print_endline "Hello world!"

You can also edit and re-run the code yourself to experiment and check your understanding. Look for the icon near the top right of the page that looks like a rocket ship. In the drop-down menu you'll find two ways to interact with the code:

您还可以自己编辑和重新运行代码,以实验和检查您的理解。在页面的右上角找一个看起来像火箭飞船的图标。在下拉菜单中,你可以找到两种与代码交互的方式:

  • Binder will launch the site mybinder.org, which is a free cloud-based service for "reproducible, interactive, sharable environments for science at scale." All the computation happens in their cloud servers, but the UI is provided through your browser. It will take a little while for the textbook page to open in Binder. Once it does, you can edit and run the code in a Jupyter notebook. Jupyter notebooks are documents (usually ending in the .ipynb extension) that can be viewed in web browsers and used to write narrative content as well as code. They became popular in data science communities (especially Python, R, and Julia) as a way of sharing analyses. Now many languages can run in Jupyter notebooks, including OCaml. Code and text are written in cells in a Jupyter notebook. Look at the "Cell" menu in it for commands to run cells. Note that Shift-Enter is usually a hotkey for running the cell that has focus.

    Binder 将推出网站 mybinder. org,这是一个免费的基于云的服务,用于“可复制的、互动的、共享的科学环境”所有的计算都发生在他们的云服务器上,但用户界面是通过浏览器提供的。教科书在宾代尔打开还需要一段时间。一旦这样做,你可以编辑和运行的代码在一个 Jupyter 笔记本。“木板笔记本”是一种文件(通常以。Ipynb 扩展) ,可以在 web 浏览器中查看,并用于编写叙述性内容以及代码。作为分享分析的一种方式,它们在数据科学社区(尤其是 Python、 r 和 Julia)中变得流行起来。现在,包括 OCaml 在内的许多语言都可以在 Jupyter 的笔记本上运行。代码和文本都写在木星笔记本的单元格里。查看其中的“ Cell”菜单以获取运行单元格的命令。注意,Shift-Enter 通常是运行具有焦点的单元格的热键。

  • Live code will actually do about the same thing, except that instead of leaving the current textbook page and taking you off to Binder, it will modify the code cells on the page to be editable. It takes some time for the connection to be made behind the scenes, during which you will see "Waiting for kernel". After the connection has been made, you can edit all the code cells on the page and re-run them.

    实时代码实际上也可以做同样的事情,只不过它不会离开当前的教科书页面,而是将页面上的代码单元格修改为可编辑的。在幕后建立连接需要一些时间,在此期间您将看到“等待内核”。建立连接之后,您可以编辑页面上的所有代码单元格并重新运行它们。

Try interacting with the cell above now to make it print a string of your choice. How about: "Camels are bae."

尝试与上面的单元格交互,让它打印您选择的字符串。这句话怎么样: “骆驼是勇士。”

When you write "real" OCaml code, this is not the interface you'll be using.
You'll write code in an editor such as Visual Studio Code or Emacs, and you'll
compile it from a terminal. Binder and Live Code are just for interacting
seamlessly with the textbook.

Downloadable Pages. Each page of this book is downloadable in a variety of formats. The download icon is at the top right of each page. You'll always find the original source code of the page, which is usually Markdown—or more precisely MyST Markdown, which is an extension of Markdown for technical writing. Each page is also individually available as PDF, which simply prints from your browser. For the entire book as a PDF, see the paragraph about that below.

可下载网页。这本书的每一页都可以以各种格式下载。下载图标位于每个页面的右上角。你总能找到页面的原始源代码,通常是 Markdown,或者更准确地说是 MyST Markdown,它是 Markdown 在技术写作中的延伸。每个页面都有单独的 PDF 格式,可以从浏览器打印出来。整本书为 PDF 格式,请参阅下面关于这一点的段落。

Pages with OCaml code cells embedded in them can also be downloaded as Jupyter notebooks. To run those locally on your own machine (instead of in the cloud on Binder), you'll need to install Jupyter. The easiest way of doing that is typically to install Anaconda. Then you'll need to install OCaml Jupyter, which requires that you already have OCaml installed. To be clear, there's no need to install Jupyter or to use notebooks. It's just another way to interact with this textbook beyond reading it.

嵌入 OCaml 代码单元的页面也可以作为 Jupyter 笔记本下载。要在您自己的机器上本地运行这些代码(而不是在 Binder 的云中) ,您需要安装 Jupyter。最简单的方法就是安装蟒蛇。然后你需要安装 OCaml Jupyter,这需要你已经安装了 OCaml。需要明确的是,没有必要安装 Jupyter 或使用笔记本。这只是另一种与课本互动的方式,而不仅仅是阅读。

Exercises and Solutions. At the end of each chapter except the first, you will find a section of exercises. The exercises are annotated with a difficulty rating:

练习和解决方法。除了第一章,在每一章的最后,你会发现一部分练习。这些练习有一个难度评级:

  • One star [★]: easy exercises that should take only a minute or two.

    一星级(星级) : 简单的运动,只需要一两分钟。

  • Two stars [★★]: straightforward exercises that should take a few minutes.

    二星级: 简单的锻炼,需要几分钟时间。

  • Three stars [★★★]: exercises that might require anywhere from five to twenty minutes or so.

    三星级体育锻炼: 可能需要五到二十分钟左右的时间。

  • Four [★★★★] or more stars: challenging or time-consuming exercises provided for students who want to dig deeper into the material.

    四星或更多星星: 为希望更深入研究材料的学生提供具有挑战性或耗时的练习。

It's possible we've misjudged the difficulty of a problem from time to time. Let us know if you think an annotation is off.

有时我们可能会错误地判断一个问题的难度。如果您认为注释不正确,请告诉我们。

Please do not post your solutions to the exercises anywhere, especially not in public repositories where they could be found by search engines. {{ solutions }}

请不要在任何地方张贴你的解决方案,特别是不要在搜索引擎可以找到的公共存储库中。{解}

PDF. A full PDF version of this book is available. It does not contain the embedded videos, annotations, or other features that the HTML version has. It might also have typesetting errors. At this time, no tablet (ePub, etc.) version is available, but most tablets will let you import PDFs.

PDF.这本书的完整 PDF 版本可用。它不包含 HTML 版本所具有的嵌入式视频、注释或其他特性。它还可能有排版错误。目前,还没有平板电脑(ePub 等)版本,但大多数平板电脑都允许你导入 pdf 文件。

逸之

2022/01/03  阅读:39  主题:红绯

作者介绍

逸之