📂
CS-NoteBook
  • Introduction
  • CS144
    • concise introduction to Internet
      • 1.1 Networked Applications
      • 1.2 The 4 Layer Internet
      • 1.3 IP
      • 1.4 A Day in the Life of a Packet
      • 1.5 Principle: Packet Switching
      • 1.6 Principle:Layering
      • 1.7 Principle: Encapsulation
      • 1.8 Byte order and packet formats
      • 1.9 name and addresses:IPv4
      • 1.10 Longest Prefix Match for Link Layer
      • 1.11 Address Resolution Protocol(ARP)
      • 1.12 Summary
    • Transport Layer
      • 2.1 The TCP Service Model
      • 2.2 UDP service model
      • 2.3 ICMP(Internet Control Message Protocol 互联网报文控制协议)
      • 2.4 The End-to-End Principle
      • 2.5 Error Detection:3 schemes (Checksum,CRC and MAC)
      • 2.6 Finite State Machines(有限状态机)
      • 2.7 Flow Control
      • 2.8 Sliding window
      • 2.9 Retransmission Strategies
      • 2.10 TCP Header
      • 2.11 TCP Setup and Teardown
      • 2.12 Recap
    • Package Switching
      • 3.1 The history of Internet
      • 3.2 What is packet switching
      • [3.3 End-to-end delay and Queueing delay
      • 3.4 Playback Buffer(回放缓存区)
  • CS 61C
    • 1.4 C Memory Mangement, Usage
    • 1.5 Intro to Assembly Language, MIPS Intro
    • 1.5 extra bits operation
  • CS 61B
  • CS 61A
    • Function
    • Names
    • The Art of the Function
    • Control
    • Higher-Order Function
    • Recursive Function
    • List
    • Non-Local Assignment
    • Iterators
    • Objects
    • Data Abstraction
    • OOP
    • Inheritance
    • Representations
    • Decomposition
    • Scheme
    • Exceptions
    • Calculator
    • Interpreters
    • Declarative_Programming
    • Table
    • Aggregation
      • More_recursion
    • Databases
    • Distributed_Data
    • Tail Recursion
    • Exercises
      • lab00
      • lab01
      • hw01
      • tree Recursion example -- give Change
  • The Web DevelopMent Bootcamp
    • html5
    • css
    • bootstrap3
    • bootstrap4
    • javascript expression
    • javascript function
Powered by GitBook
On this page
  • quote
  • if ,and ,define
  • lambda
  • 注意

Was this helpful?

  1. CS 61A

Scheme

quote

  • 阻止记号被求值

    • 将符号原封不动地传递到程序,而不是求值后的其他内容

      > (+ 2 3)
      5
      > (quote (+ 2 3))
      (+ 2 3)
      > '(+ 2 3)
      (+ 2 3)

      cons ,car ,cdr

  • 一对 pairs 是 cons

  • car 是前面的

  • cdr 是后面的

  • nil 是 empty

if ,and ,define

  • if表达式

    • (if <predicate> <consequent> <alternative>)

  • and 和 or

    • (and <e1> ... <en>), (or <e1> ... <en>)

  • 绑定符号。

    • (define <symbol> <expression>)

  • 新程序。

    • (define (<symbol> <formal parameters>) <body>)

lambda

  • (lambda (<formal-parameters>) <body>)

    • 举例:

      • (define (plus4 x) (+ x 4))

      • (define plus4 (lambda (x) (+ x 4)))

注意

  • scheme 中只有 #f, false, False 代表假值

  • =, eq?, equal?

    • = 只能用于比较数字。

    • eq?在Python中类似于 ==,用于比较两个 non-pairs (数字、布尔运算等)。否则,eq? 的行为就像在Python中的 is 一样。

    • equal? 比较 pairs, 通过比较它们的 cars 是否相等,它们的 cdrs 是否相等。否则,equal? 的行为就像 eq? 一样。

      scm> (eq? '(1 2 3) '(1 2 3))
      #f
      scm> (equal? '(1 2 3) '(1 2 3))
      #t
      scm> (= '(1 2 3) '(1 2 3))
      Traceback (most recent call last):
      0     (= (quote (1 2 3)) (quote (1 2 3)))
      Error: operand 0 ((1 2 3)) is not a number
PreviousDecompositionNextExceptions

Last updated 4 years ago

Was this helpful?