What's the reason for using lambda expressions to define functions in Scheme?

richard.g

I am reading the The Little Schemer book by Daniel Friedman. I don't understand why every function in the book is written with a lambda expression.

(define fun1
  (lambda (x1 x2)
    (+ x1 x2)))

(define (fun2 x1 x2)
  (+ x2 x2))

The two functions do the same thing, but the second one is neater. I am curious about the reasons to use lambda everywhere.

I used DrRacket in this case.

Sylwester
(define (x . a) ...) 

is just an abbreviation for

(define x (lambda a ...))

In the very first scheme report from 1975 you didn't have this abbreviation. In the revised report from 1978 it was introduced.

The little Schemer is just a later edition of The little Lisper from 1974. It predates Scheme and when fixed to follow Scheme they tried to keep is as close to the original as possible. Besides when you use (define x (lambda (arg1) ...)) it's obvious that procedure bindings are not different from other variable bindings other than the object it points to is closure code rather than data.

If you look at the SICP video lectures you'll see that Abelson and Sussman do have students who are confused with this so it's probably best using only one of these and since anonymous procedures are something you need to touch eventually it's obvious you want to teach the form with a explicit lambda instead of the syntactic sugar.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What's the reason of using auto self(shared_from_this()) variable in lambda function?

From Dev

using LinQ without Lambda expressions to define condition on a List type property

From Dev

What does this Scheme code mean? (Definition of 'list' operator using lambda)

From Dev

What does this Scheme code mean? (Definition of 'list' operator using lambda)

From Dev

What is the advantage of "lambda expressions"?

From Dev

Using Lambda Expressions for RoutedEventHandler

From Dev

What's the reason for storing data with .data() instead of using plain variables?

From Dev

What's the reason of using Circular Buffer in iOS Audio Calling APP?

From Dev

What's the reason behind using routes file in modern frameworks?

From Dev

What is the reason define unknown enum in separate class?

From Dev

What is the reason define unknown enum in separate class?

From Dev

using #define in functions

From Dev

What's wrong with this lambda function using petl?

From Java

Scheme Lisp - Using eval for arbitrary arithmetic expressions

From Dev

Lambda Expressions vs Procedural-styled Functions

From Dev

What's the possible reason for this IllegalArgumentException?

From Dev

transform List using lambda expressions

From Dev

Is there a performance gain by using lambda expressions?

From Dev

What is the reason for using ^ in a hashcode method?

From Dev

using lambda functions to unzip archives in S3 is really sloooooow

From Dev

Using Lambda functions in Delphi

From Dev

Using a list as argument names for lambda scheme/racket

From Dev

Using return value from lambda expression scheme?

From Dev

What does wrapping Scala lambda expressions in blocks (using both braces and parentheses) before executing them inline achieve?

From Dev

PostgreSQL: dropping functions using information_scheme

From Dev

MapBox - Define PropertyFactory.iconImage using expressions

From Dev

Was the reason that Haskell had single-argument functions to be like lambda calculus?

From Dev

Is it good style to use lambda functions to define very small helper functions?

From Dev

What is the convention for variable names in lambda expressions?

Related Related

  1. 1

    What's the reason of using auto self(shared_from_this()) variable in lambda function?

  2. 2

    using LinQ without Lambda expressions to define condition on a List type property

  3. 3

    What does this Scheme code mean? (Definition of 'list' operator using lambda)

  4. 4

    What does this Scheme code mean? (Definition of 'list' operator using lambda)

  5. 5

    What is the advantage of "lambda expressions"?

  6. 6

    Using Lambda Expressions for RoutedEventHandler

  7. 7

    What's the reason for storing data with .data() instead of using plain variables?

  8. 8

    What's the reason of using Circular Buffer in iOS Audio Calling APP?

  9. 9

    What's the reason behind using routes file in modern frameworks?

  10. 10

    What is the reason define unknown enum in separate class?

  11. 11

    What is the reason define unknown enum in separate class?

  12. 12

    using #define in functions

  13. 13

    What's wrong with this lambda function using petl?

  14. 14

    Scheme Lisp - Using eval for arbitrary arithmetic expressions

  15. 15

    Lambda Expressions vs Procedural-styled Functions

  16. 16

    What's the possible reason for this IllegalArgumentException?

  17. 17

    transform List using lambda expressions

  18. 18

    Is there a performance gain by using lambda expressions?

  19. 19

    What is the reason for using ^ in a hashcode method?

  20. 20

    using lambda functions to unzip archives in S3 is really sloooooow

  21. 21

    Using Lambda functions in Delphi

  22. 22

    Using a list as argument names for lambda scheme/racket

  23. 23

    Using return value from lambda expression scheme?

  24. 24

    What does wrapping Scala lambda expressions in blocks (using both braces and parentheses) before executing them inline achieve?

  25. 25

    PostgreSQL: dropping functions using information_scheme

  26. 26

    MapBox - Define PropertyFactory.iconImage using expressions

  27. 27

    Was the reason that Haskell had single-argument functions to be like lambda calculus?

  28. 28

    Is it good style to use lambda functions to define very small helper functions?

  29. 29

    What is the convention for variable names in lambda expressions?

HotTag

Archive