Additional scheme examples
This presentation is the property of its rightful owner.
Sponsored Links
1 / 4

Additional Scheme examples PowerPoint PPT Presentation


  • 53 Views
  • Uploaded on
  • Presentation posted in: General

Additional Scheme examples. (define f (lambda (x) (lambda (y) (lambda (z) (+ x y z) ) ) ) ) > f #<CLOSURE (x) [email protected] (lambda (y) (lambda (z) (+ x y z)))> > (f 1) #<CLOSURE (y) [email protected] (lambda (z) (+ x y z))> > ((f 1) 2)

Download Presentation

Additional Scheme examples

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Additional scheme examples

Additional Scheme examples

(define f (lambda (x) (lambda (y) (lambda (z) (+ x y z)) ) ) )

> f

#<CLOSURE (x) [email protected] (lambda (y) (lambda (z) (+ x y z)))>

> (f 1)

#<CLOSURE (y) [email protected] (lambda (z) (+ x y z))>

> ((f 1) 2)

#<CLOSURE (z) [email protected] (+ x y z)>

> (((f 1) 2) 3)

6


Additional scheme examples1

Additional Scheme examples

( mapcar '((a b) (c d) (e f)) )

( mapcadr '((a b) (c d) (e f)) )

( map(lambda (x) (cons 0 (list x))) '(a b c d) )


Additional scheme examples2

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)))

) )


Additional scheme examples3

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))))

) )

>

(repeatedElems '(a b c a d e a f g e w c a i))


  • Login