高二升高三暑假参加夏令营让我白嫖的 Kinect2,大材小用当做网络摄像头来用
From Textbook: Mutability
From Textbook: Specifications and Abstractions
Specification of Functions
1 | (** [f x] is ... |
From Textbook: Code Reuse with Modules
Includes
Def: includes
enables a structure to include all the values defined by another structure, or a signature to include all the names declared by another signature.
From Textbook: OCaml Modules
Structures
Semantics
The first letter of a module’s name should be capitalized.
1 | module ModuleName = struct |
From Textbook: Higher Order Programming
Introduction
- higher-order: functions as values, you can pass functions as arguments into other functions, functions at the same level as other variables
- lower-order: languages like C, functions as something higher than other variables
Pipeline is a higher-order function.
1 | let pipeline x f = f x |
From Textbook: Advanced Data Types
Algebraic Data Types
以前我们的 variants 比较像 enum
,但是现在我们更像一个abstract class
From Textbook: Standard Data Types
Lists
Building Lists
The empty list is written
[]
and is pronounced “nil”, a name that comes from Lisp. Given a listlst
and elementelt
, we can prependelt
tolst
by writingelt::lst
. The double-colon operator is pronounced “cons”
From Textbook: Functions
Functions
Definition: let f x1 x2 ... xn = e
(f is the function name; xi is input, and there can be multiple inputs; e is the output)
We can think of t1 -> t2 -> u
as the type of a function that takes two inputs, the first of type t1
and the second of type t2
, and returns an output of type u
. Likewise for a function that takes n
arguments.
A function is already a value (that’s how you assign the value “function” to a variable name), so there is nothing to be evaluated when we evaluate its dynamic semantic.