正在加载图片...
Language elements Procedural abstraction Need to capture ways of doing things use procedures parameters (lambda(x)(xx)k body To process something multiply it by itself Special form -creates a procedure and returns it as a value sept.8.2003 16.41016.413 Intro. to scheme Language elements Procedural abstraction Use a lambda expression anywhere you would use a procedure ((lambda (x)(x x))5) Can give it a name (define square(lambda(x x x)) (square 5)3 25 (define(fx y z..))is shorthand (define f(lambda(xy z).) (define (square X)C*XX) sept.8,2003 16.410/16.413 Intro. to scheme 5/ 9 Language elements – Procedural abstraction • use procedures To process something parameters body as a value. Need to capture ways of doing things – multiply it by itself •Special form – creates a procedure and returns it Sept. 8, 2003 16.410 16.413 Intro. to Scheme (lambda (x) (* x x)) Language elements – Procedural abstraction • Use a lambda expression anywhere you would use a procedure ((lambda (x) (* x x)) 5) • Can give it a name – (define square (lambda (x) (* x x))) – (square 5) Æ 25 • (define (f x y z) …)) is shorthand for (define f (lambda (x y z) …)) – (define (square x) (* x x)) Sept. 8, 2003 16.410/16.413 Intro. to Scheme 10 5
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有