CSI 3125, Scheme, page 1 - PowerPoint PPT Presentation

About This Presentation
Title:

CSI 3125, Scheme, page 1

Description:

CLOSURE (z) #_at_lambda ( x y z) (((f 1) 2) 3) 6. CSI 3125, Scheme, page 2 ... (a b) (c d) (e f)) ) ( map. cadr '((a b) (c d) (e f)) ) ( map (lambda (x) (cons ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 5
Provided by: alanwi8
Category:
Tags: csi | courses | page | scheme

less

Transcript and Presenter's Notes

Title: CSI 3125, Scheme, page 1


1
Additional Scheme examples
  • (define f (lambda (x) (lambda (y)
    (lambda (z) ( x y z)) ) )
    )
  • gt f
  • ltCLOSURE (x) _at_lambda (lambda (y) (lambda (z) (
    x y z)))gt
  • gt (f 1)
  • ltCLOSURE (y) _at_lambda (lambda (z) ( x y z))gt
  • gt ((f 1) 2)
  • ltCLOSURE (z) _at_lambda ( x y z)gt
  • gt (((f 1) 2) 3)
  • 6

2
Additional Scheme examples
  • ( map car '((a b) (c d) (e f)) )
  • ( map cadr '((a b) (c d) (e f)) )
  • ( map (lambda (x) (cons 0 (list x))) '(a b
    c d) )

3
Additional Scheme examples
  • (define (repeatedElems L)
  • (if (list? L)
  • (doRepeatedElems L)
  • 'repeated_elems_not_a_list)
  • )
  • (define (doRepeatedElems L)
  • (cond
  • ((null? L) ())
  • ((member (car L) (cdr L))
  • (cons (car L)
  • (doRepeatedElems
  • (deleteAll (car L) (cdr L)))
  • ) )
  • (else (doRepeatedElems (cdr L)))
  • ) )

4
Additional Scheme examples
  • (define (deleteAll L Ls)
  • (cond
  • ((null? Ls) ())
  • ((equal? (car Ls) L)
  • (deleteAll L (cdr Ls)))
  • (else
  • (cons (car Ls) (deleteAll L (cdr Ls))))
  • ) )
  • gt
  • (repeatedElems '(a b c a d e a f g e w c a i))
Write a Comment
User Comments (0)
About PowerShow.com