1 / 5

Syntactic Note

Syntactic Note. Scheme excerpts in the The Schemer’s Guide have a slightly different syntax, for example: (cond [(null? A) ▿empty) [(null? B) (cons b ▿())] [else ▿full]). Syntactic Note. (cond [(null? A) ▿empty) [(null? B) (cons b ▿())]

rene
Télécharger la présentation

Syntactic Note

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Syntactic Note • Scheme excerpts in the The Schemer’s Guide have a slightly different syntax, for example: (cond [(null? A) ▿empty) [(null? B) (cons b ▿())] [else ▿full]) 0704.315 - Programming Languages

  2. Syntactic Note (cond [(null? A) ▿empty) [(null? B) (cons b ▿())] [else ▿full]) becomes (cond ((null? A) 'empty) ((null? B) (cons b '())) (else 'full)) 0704.315 - Programming Languages

  3. car/cdr vs. first/rest (define a (list 1 2 3 4)) • In Schemer’s Guide: (first a)  1 (rest a)  '(2 3 4) • In Scheme48: (car a)  1 (cdr a)  '(2 3 4) 0704.315 - Programming Languages

  4. car/cdr vs. first/rest • First/rest are synonymous with car/cdr (define first car) (define rest cdr) 0704.315 - Programming Languages

  5. List Processing • Think of the list data structure as a sequence of values (define first-4-integers (list 1 2 3 4)) • We can write functions that operate on sequences: • sum, product, average • Increment-each, square-each 0704.315 - Programming Languages

More Related