课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第1次大作业. 什么是编译 编译就是执行Program->Program'转换的过程,如下图所示: 这个过程需要满足两个条件: The input and output program mean the same thing. The output is executable in a context we care about. 编译执行过程: 不可变数据结构(persistent data…
课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第2大次作业. 比较两个lists的逻辑: let rec cmp l ll = match (l,ll) with | [], [] -> 0 | [],_ -> -1 | _,[] -> 1 | (h::t), (hh::tt) -> if h > hh then 1 else if h < hh then -1 else cmp t tt;; 编程作业 1. 平…
课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第9次大作业. 赋值的副作用:循环元组 下面的代码展示了Python3是如何处理循环列表(print和==): >>> x = [1, 2] >>> x[1] = x >>> print(x) [1, [...]] >>> y = [1, 2] >>> y[1] = y >>> x is y Fa…
课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第8次大作业. First-class function: It treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other…