南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)19-More-Scheme

474NS)PROGRAMMING YOU FORGOT TO PUT PARENTHESSS ACTER MAIN. Lecture 20-More Scheme Chris Allsman MAE PARENS. &
Lecture 20 - More Scheme Chris Allsman

Lis(t)P(rocessing) s7% APR CALIFORNIA☑ CAR CDR LEY ENGINEERING 3
Lis(t) P(rocessing)

Scheme List Definition A Scheme list is either: nil Composed of a first element(car)and the rest(cdr)of the Scheme list Value of car is the 2 3 number 1 List terminated with nil car cdr car cdr car cdr cdr contains a pointer to a linked list
Scheme List Definition A Scheme list is either: ● nil ● Composed of a first element (car) and the rest (cdr) of the Scheme list 1 2 3 car cdr car cdr car cdr Value of car is the number 1 cdr contains a pointer to a linked list List terminated with nil

Creating Scheme Lists Demo 2 3 car cdr car cdr car cdr (cons 1 (cons1(cons2 ) (cons 1 (cons 2 (cons 3 nil))
Creating Scheme Lists 1 2 3 car cdr car cdr car cdr (cons 1 __________________________________) (cons 1 (cons 2 _________________________)) (cons 1 (cons 2 (cons 3 nil)) Demo

Scheme Lists vs.Linked Lists Scheme Lists: Linked Lists: (cons a b) Link(a,b) (car Ist) Ist.first (cdr Ist) Ist.rest nil Link.empty (1(23) >
Scheme Lists vs. Linked Lists Scheme Lists: (cons a b) (car lst) (cdr lst) nil (1 (2 3)) Linked Lists: Link(a, b) lst.first lst.rest Link.empty >

Checking Equivalence Demo (equal?e1 e2)checks if el and e2 evaluate to equivalent values ●Like=in Python ●(null?expr)is like(equal?expr ni1) (eq?e1 e2)checks if el and e2 evaluate to identical values ●Like is in Python Only matters for lists (e1 e2)only works for numbers
Checking Equivalence (equal? e1 e2) checks if e1 and e2 evaluate to equivalent values ● Like == in Python ● (null? expr) is like (equal? expr nil) (eq? e1 e2) checks if e1 and e2 evaluate to identical values ● Like is in Python ● Only matters for lists (= e1 e2) only works for numbers Demo

List Constructor Demo If we know each element we want to put in a list,we can use the list constructor The list constructor takes in any number of elements and puts each element as a single element in a list scm> (1ist123) scm>(list 0 (list 1 2 3)) (123) (0(123) 123 123N
List Constructor If we know each element we want to put in a list, we can use the list constructor The list constructor takes in any number of elements and puts each element as a single element in a list scm> (list 1 2 3) (1 2 3) scm> (list 0 (list 1 2 3)) (0 (1 2 3)) 1 2 3 1 2 3 0 Demo

Quoting Demo The quote special form takes in a single argument and returns an unevaluated version of the argument Quoting a symbol gives a symbol back,that symbol can mean something to scheme! Quoting the representation of a list gives a list scm>‘(abc) scm>‘(0(123)) (a b c) (8(123)) 123N
Quoting The quote special form takes in a single argument and returns an unevaluated version of the argument Quoting a symbol gives a symbol back, that symbol can mean something to scheme! Quoting the representation of a list gives a list scm> ‘(a b c) (a b c) scm> ‘(0 (1 2 3)) (0 (1 2 3)) a b c 1 2 3 0 Demo

Example-Add To End Given a scheme list,Ist,and an element,x,add x to the end of Ist (define (add-to-end lst x) scm> (add-to-end nil 1) (1) scm> (add-to-end (1 2)3) (123) scm> (add-to-end‘(123)‘(4)) (123(4))
Example - Add To End Given a scheme list, lst, and an element, x, add x to the end of lst (define (add-to-end lst x) ) scm> (add-to-end nil 1) (1) scm> (add-to-end ‘(1 2) 3) (1 2 3) scm> (add-to-end ‘(1 2 3) ‘(4)) (1 2 3 (4))

Using List Constructors
Using List Constructors
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)18-Scheme.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)17-Interfaces.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)16-Linked Lists & Mutable Trees.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)15-Inheritance.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)14-Object-Oriented Programming.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)13-Iterators & Generators.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)13-Iterators.pdf
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)12-Mutable Functions & Growth.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)11-Mutable-Values.pdf
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)10-Trees.pdf
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)09-Data-Abstractions.pdf
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)08-Containers.pdf
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)07-Recursion Examples.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)06-Recursion.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)05-Higher-Order Functions.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)04-Environment Diagrams.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)03-Control.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)02-Names & Functions.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)01-Introduction(主讲:冯新宇).pptx
- 《计算机科学》相关教学资源(PPT课件讲稿)Modular Verification of Concurrent Assembly Code with Dynamic Thread Creation and Termination.ppt
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)20-Interpreters.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)21-Macros.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)22-Streams.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)23-SQL-I.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)24-SQL-II.pptx
- 南京大学:《计算机程序的构造和解释 Structure and Interpretation of Computer Programs》课程教学资源(PPT课件讲稿)25-Conclusion, and Final Exam Review.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)01 绪论 Introduction(主讲:曹洋).pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)02 傅里叶分析与卷积 Fourier Analysis and Convolution.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)03 数字图像处理基础 Basics of Digital Image Processing.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)04 图像模型 Basics of Image.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)05 空域滤波 Spatial Filtering.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)06 小波变换 Wavelet Analysis.pptx
- CodeIgniter 中国开发者社区:CodeIgniter4 中文手册(版本 4.0.0).pdf
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)07 图像复原 Image Restoration.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)08 自适应滤波 Adaptive Filter.pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)要点复习 Review(主讲:曹洋).pptx
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)09 图像压缩 Image Compression.pptx
- 中国科学技术大学:《计算机视觉》课程教学资源(参考论文)Tour Into the Picture_Using a Spidery Mesh Interface to Make Animation from a Single Image.pdf
- 中国科学技术大学:《计算机视觉》课程教学资源(参考论文)3D photography on your desk.pdf
- 中国科学技术大学:《计算机视觉》课程教学资源(PPT课件讲稿)第一章 绪论 Computer Vison(主讲:曹洋).ppt