for the following function:
(define (update f x v)
(λ ($x)
(display $x)
(newline)
(if (e开发者_如何学JAVAqual? $x x)
v
(f $x))))
what does
$
mean here?where does the
$x
come from?
$
has no particular meaning in Scheme -- it's just a character like any other.
As for part 2: the code
(define (update f x v)
(λ ($x)
(display $x)
(newline)
(if (equal? $x x)
v
(f $x))))
is equivalent to:
(define (update f x v)
(define (DUMMY $x)
(display $x)
(newline)
(if (equal? $x x)
v
(f $x)))
DUMMY) ;; Return the lambda
So $x
is just a parameter to the inner function, nothing special.
From what I can tell, the $
has no syntactic meaning, it's merely part of the parameter's identifier (like a variable name). This appears to create an anonymous function with $x
as its only parameter.
精彩评论