自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 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 216

原创 Composing Programs 2.4 Mutable Data - 04

伯克利CS 61A的教学用书笔记和一些课程笔记2.4.11Implementing Lists and Dictionariespython不允许我们访问对list的底层实现,只允许我们访问内置的序列抽象和修改方法(the sequence abstraction and mutation methods)。为了理解如何用带有局部状态的函数来表示可变列表,我们将实现一个可变链表。我们将用一个将链表作为其局部状态的函数来表示可变链表。首先思考,如果用一个函数来表示一个可变链表,那它的参数是什...

2021-01-05 21:52:53 185

原创 Composing Programs 2.4 Mutable Data - 03

2.4.7Iteratorspython和许多其他编程语言都提供一种按顺序处理容器中元素的方法,叫做迭代器(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 158

原创 Composing Programs 2.4 Mutable Data - 02

伯克利CS 61A的教学用书笔记和一些课程笔记2.4.4Local StateLists 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 222 1

原创 Composing Programs 2.4 Mutable Data - 01

伯克利CS 61A的教学用书笔记和一些课程笔记一些python笔记01 关于值和函数默认参数值>>> a = [10]>>> b = a>>> a == bTrue>>> a.append(20) >>> a == bTrue>>> a[10, 20]>>> b[10, 20]b被绑定到a,所以a改变了,b也会改变。>>.

2020-12-22 20:54:54 155

原创 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 195 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 184

原创 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 + 19种。我们定义函数count_partit...

2020-12-21 16:16:22 151

原创 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 894

原创 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 299 1

原创 Composing Programs 2.3 Sequence - 01

伯克利CS 61A的笔记,用的2020 Fall版本2.3.3 Sequence Processing2.3.3.1 List ComprehensionsMany 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 299 2

原创 Python笔记——(一)文本编码

写在前面:最近开始学习机器学习,听说机器学习核心是数学原理,但是代码是实现原理的途径,有的东西也很繁琐,所以准备写一些学习的笔记,方便查阅。代码大多基于Python 2.7版本。(一)Python文本编码Python默认的源代码文件是ASCII编码,如果代码中有中文字符串,则会报错,解决方法是:指定编码。如下: # coding = UTF-8可以选择将这句代码放在

2017-11-18 18:14:18 241

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除