CS 61A
文章平均质量分 94
a945882813
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CS 61A FALL 2020 Project-cats
第10题 def fastest_words(game): """Return a list of lists of which words each player typed fastest. Arguments: game: a game data abstraction as returned by time_per_word. Returns: a list of lists containing which words each pla原创 2020-12-20 22:23:48 · 1016 阅读 · 0 评论 -
Composing Programs 1.7 Recursive Functions
1.7.5Example: Partitions 问题:用最大不超过m的正整数来划分n,有多少种方式? 比如,n = 9,m = 6时,划分方式为: 6 = 2 + 4 6 = 1 + 1 + 4 6 = 3 + 3 6 = 1 + 2 + 3 6 = 1 + 1 + 1 + 3 6 = 2 + 2 + 2 6 = 1 + 1 + 2 + 2 6 = 1 + 1 + 1 + 1 + 2 6 = 1 + 1 + 1 + 1 + 1 + 1 9种。我们定义函数count_partit...原创 2020-12-21 16:16:22 · 214 阅读 · 0 评论 -
Composing Programs 2.2 Data Abstraction
伯克利CS 61A的教学用书笔记和一些课程笔记 The general technique of isolating the parts of a program that deal with how data are represented from the parts that deal with how data are manipulated is a powerful design methodology calleddata abstraction. Data abstraction mak.原创 2020-12-18 19:22:07 · 418 阅读 · 1 评论 -
Composing Programs 2.3 Sequence - 01
伯克利CS 61A的笔记,用的2020 Fall版本 2.3.3 Sequence Processing 2.3.3.1 List Comprehensions Many sequence processing operations can be expressed by evaluating a fixed expression for each element in a sequence and collecting the resulting values in a result sequenc原创 2020-12-17 17:26:12 · 394 阅读 · 2 评论 -
Composing Programs 2.3 Sequence - 02
伯克利CS 61A的教学用书笔记和一些课程笔记 一些python笔记 01 关于sum >>> sum([2, 3, 4]) 9 >>> sum([2, 3, 4], 5) # sum最多能有两个参数,第一个为可迭代对象,第二个为起始值 14 >>> [2, 3] + [4] # 首先我们知道这个 [2, 3, 4] >>> sum([[2, 3], [4]], []) # 然后类比上面,从空列表开始加,那么就原创 2020-12-21 16:27:17 · 254 阅读 · 0 评论 -
Composing Programs 2.3 Sequence - 03
伯克利CS 61A的教学用书笔记和一些课程笔记 2.3.7Linked Lists 链表,同样也是一种数据抽象,是一种数据结构。 four = [1, [2, [3, [4, 'empty']]]] 链表包含了一对元素,第一个元素是值,另一个元素是一个链表,最内层的4后是一个"empty" ,表示一个空链表。同样我们开始定义链表,和前面讲到的数据结构一样,首先可以定义构造器(constructor)、选择器(selectors)以及验证器(validator),先借助python的l...原创 2020-12-22 16:35:34 · 275 阅读 · 2 评论 -
Composing Programs 2.4 Mutable Data - 01
伯克利CS 61A的教学用书笔记和一些课程笔记 一些python笔记 01 关于值和函数默认参数值 >>> a = [10] >>> b = a >>> a == b True >>> a.append(20) >>> a == b True >>> a [10, 20] >>> b [10, 20] b被绑定到a,所以a改变了,b也会改变。 >>.原创 2020-12-22 20:54:54 · 213 阅读 · 0 评论 -
Composing Programs 2.4 Mutable Data - 02
伯克利CS 61A的教学用书笔记和一些课程笔记 2.4.4Local State Lists and dictionaries havelocal state: they are changing values that have some particular contents at any point in the execution of a program. The word "state" implies an evolving process in which that state ...原创 2020-12-26 14:40:31 · 306 阅读 · 1 评论 -
Composing Programs 2.4 Mutable Data - 03
2.4.7Iterators python和许多其他编程语言都提供一种按顺序处理容器中元素的方法,叫做迭代器(Iterators)。迭代器是一个对象,它提供对值的顺序访问。(Python and many other programming languages provide a unified way to process elements of a container value sequentially, called an iterator. Aniteratoris an object...原创 2021-01-04 22:13:24 · 215 阅读 · 0 评论 -
Composing Programs 2.4 Mutable Data - 04
伯克利CS 61A的教学用书笔记和一些课程笔记 2.4.11Implementing Lists and Dictionaries python不允许我们访问对list的底层实现,只允许我们访问内置的序列抽象和修改方法(the sequence abstraction and mutation methods)。为了理解如何用带有局部状态的函数来表示可变列表,我们将实现一个可变链表。 我们将用一个将链表作为其局部状态的函数来表示可变链表。首先思考,如果用一个函数来表示一个可变链表,那它的参数是什...原创 2021-01-05 21:52:53 · 243 阅读 · 0 评论 -
Composing Programs 2.4 Mutable Data - 05
伯克利CS 61A的教学用书笔记和一些课程笔记 这一节有点抽象,但是也很有意思。介绍了声明式编程,同时也涉及数据抽象,还有上一篇文章的内容。 2.4.12Dispatch Dictionaries 暂时译为传播约束。 可变数据使我们能够模拟变化的系统,也使我们能够构建新的抽象类型。 这次,我们结合了nonlocal,list和dictionary来构建基于约束的系统(constraint-based system),支持多个方向的计算。 将程序表示为约束是声明式编程(declarative p...原创 2021-01-07 15:55:51 · 313 阅读 · 0 评论
分享