CTFP Ch01 - WinChua/blog GitHub Wiki

概要

摘录

  1. the essence of a category is composition. and the essence of composition is a category.
  2. a category consists of objects and arrows that go between objs. and the arrow compose, which means that if u have a arrow goes from A to B, and a arrow goes from B to C, there must be an arrow goes from A to C.
  3. Function as arrow, the order of composition is right to left, which means that f compose g is g . f.
  4. The composition must satisify two priciples: 4.1 associate: (f . g) . h == f . ( g . h ) 4.2 identity: id_A . a == a . id_B
  5. the usage of identity function: id is handy as the arg , or the retrun of a high order function, who make the symbolic manipulation of funtion possible.
  6. composition is the essence of programming: we decompose a non-trival problem into small problem recursively until every small problem could be solved. then compose the solution of all small problem to solve the original big problem.
  7. but how to decompose the big problem? any standard? the increase of the surface should be slower than the volume. here surface is the information we need to compose the solution of the small problem, while the volume is the information we need to solve the small problem.
  8. we need structure of program not because of the beautiful it looks, but because the structure of program is suitable for out brain to solve. our brain could only remember the most recent 7+-2 chunk of information. by decompose a big problem into smaller ones, our brain could focus on the suitable level of a problem once a time.

随笔

一个问题的解决过程在某个微观层面上一定是某些十分具体的步骤顺序的组合过程,这些具体步骤通常具有的特点应该是:繁杂的,细微的,让人难以记住的,同时也有可能是十分容易出错的。同时,繁杂的步骤也跟我们的大脑结构不匹配,大脑没法同时记住许多信息。因而,人们在解决问题的过程中,通常采用分治的思想,将大问题分解成为小问题,单独解决小问题,并通过组合小问题的解形成了大问题的解。 大问题怎么分解才合适? 两个角度

  1. 解决小问题需要的信息量:volume
  2. 组合小问题的解形成大问题的解的需要的信息量:surface
  3. surface的复杂度要小于volume的复杂度
  4. 小问题的分解还需要保持独立,独立带来的好处就是每一个小问题的解都是无副作用的,也就是一个小问题的解不会影响到另外一个小问题的解,这样,两者在组合的时候,才能够正确地解决一个大问题。

编程的本质就是为了借助计算机来解决问题,因而编程的本质其实是组合,而组合又是范畴研究的范围,或者说范畴的本质也是组合