Syntactic Note - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Syntactic Note

Description:

none – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 6
Provided by: RowanUni8
Learn more at: http://elvis.rowan.edu
Category:
Tags: elvis | note | syntactic

less

Transcript and Presenter's Notes

Title: Syntactic Note


1
Syntactic Note
  • Scheme excerpts in the The Schemers Guide have a
    slightly different syntax, for example
  • (cond
  • (null? A) ?empty)
  • (null? B) (cons b ?())
  • else ?full)

2
Syntactic Note
  • (cond
  • (null? A) ?empty)
  • (null? B) (cons b ?())
  • else ?full)
  • becomes
  • (cond
  • ((null? A) 'empty)
  • ((null? B) (cons b '()))
  • (else 'full))

3
car/cdr vs. first/rest
  • (define a (list 1 2 3 4))
  • In Schemers Guide
  • (first a) ? 1
  • (rest a) ? '(2 3 4)
  • In Scheme48
  • (car a) ? 1
  • (cdr a) ? '(2 3 4)

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

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
Write a Comment
User Comments (0)
About PowerShow.com