Differences between procedures with and without brackets?

(define (procedere1) (lambda () 2))
(define procedure2 (lambda () 2))

      

Both of them can be compiled. But I am confused about the difference between the above two procedures.

+3


source to share


2 answers


The first is a procedure that returns a procedure. The second is a procedure that returns the number 2.

In particular, the first one is equivalent to the following:



(define procedure1
  (lambda ()
    (lambda () 2)))

      

+4


source


Generally

(define (name arg1 arg2 arg3 ...)
  body)

      



is shorthand for

(define name
  (lambda (arg1 arg2 arg3 ...) 
    body))

      

+2


source







All Articles