SICP-Elements of program

编程语言=组合简单形成复杂的工具

  • 简单的声明和表达式
  • 简单元素之间的组合方式
  • 组合后元素的抽象方式

程序=数据+函数

  • 数据是我们要处理的内容
  • 函数是我们处理数据的方式

函数式与中缀式

  • 函数式不会出现歧义
  • 函数式可以无限嵌套且便于理解

表达式的嵌套

  • 评估运算符和操作数子表达式

    • 若要完成评估则必须完成评估子表达式--递归
  • 将运算符子表达式的值应用于参数(操作数子表达式)

要计算他的根,首先要计算他的分支,所以我们可以想象,各个内部节点的值是由叶子节点开始向上渗透的

纯函数与非纯函数

  • 纯函数:得到一个输入,返回一个输出值,不做其他改变

    • 通过这种方式产生的复合表达式更可靠
    • 更易于测试
  • 非纯函数:得到一个输入值,除了返回值,还产生其他结果
时间: 2024-07-29 08:31:14

SICP-Elements of program的相关文章

OpenCL学习笔记(三):OpenCL安装,编程简介与helloworld

OpenCL安装 安装我不打算花篇幅写,原因是OpenCL实在是可以太多的平台+环境下实现了,包括GPU和FPGA,以及不同的器件支持,在这里我主要把网上可以找到比较不错的经验贴列一下,方便大家,我主要关注了FPGA的,其他GPU的大家网上搜搜吧: altera opencl sdk下载: https://www.altera.com.cn/products/design-software/embedded-software-developers/opencl/overview.html alt

PTA Sort Three Distinct Keys

Suppose you have an array of N elements, containing three distinct keys, "true", "false", and "maybe". Given an O(N)O(N) algorithm to rearrange the list so that all "false" elements precede "maybe" element

E. 2-3-4 Tree

题目链接:http://codeforces.com/gym/102222/problem/E time limit per test 10.0 s memory limit per test 256 MB input standard input output standard output In computer science, a 2-3-4 tree, as a search tree, is a self-balancing data structure that is common

[SICP Notes] 1.1 The Elements of Programming

About the Book To know more about programming, I have decided to start reading the famous Structure and Interpretation of Computer Programs (SICP, or the Wizard Book), which is first published by MIT in 1985. The Wizard Book used MIT Scheme, which is

[转载]Core Elements of a Program

原文链接 http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-1/lecture-2-core-elements-of-a-program/ Check Yourself what is a "type"? Types are classificatio

【SICP练习】122 练习3.53

练习3-53 原文 Exercise 3.53. Without running the program, describe the elements of the stream defined by (define s (cons-stream 1 (add-streams s s))) 分析 s是一串2的幂.也就是1.2.4.8.16.32--

Flink Program Guide (2) -- DataStream API编程指导 -- For Java

v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} 张安 张安 2 1 2016-08-02T10:56:00Z 2016-08-02T10:56:00Z 1 2945 16790 139 39 19696 16.00 false false false false

Program A-归并排序

Description In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. For the input seque

Flink Program Guide (6) -- 窗口 (DataStream API编程指导 -- For Java)

窗口(Window) 本文翻译自文档Windows ----------------------------------- Flink使用窗口的概念,根据element的时间戳或者其他指标,将可能无限的DataStream分割为有限的数据切片(slice).我们在处理无限数据流以及进行聚合element的transformation时需要此种窗口分割. 注意:我们在此文档中讨论的大多是keyed windowing,即window是应用在KeyedStream上的.关键字下的窗口具有一定的优势,

Exception: Operation xx of contract xx specifies multiple request body parameters to be serialized without any wrapper elements.

Operation 'CreateProductCodeStock' of contract 'IChileService' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra bo