On Fri, Sep 12, 2014 at 6:43 PM, Matthias Felleisen <matth...@ccs.neu.edu> wrote:
> On Sep 12, 2014, at 4:40 PM, Daniel Bastos <dbas...@toledo.com> wrote: > > > Again, we start with (2) and apply a series of substitutions. > > > > (f f) > > = (<var> <var>) ;; since f is a <var> > > = (<exp> <exp>) ;; since <var> is a subset of <exp> > > > > However, (<exp> <exp>) is not by definition a value. It is an > > expression which may or may not /have/ a value. We know the > > definition of f, however, which tells us that it behaves like > > the identity function. So the evaluation of that (<exp> <exp>) > > yields a function, which is a value. We end with > > > > = <val> > > > > Therefore (2) is a value > > Is there a difference between the statements > > "Daniel is a hat." > > and > > "Daniel has a hat." > > or do they really mean the same thing? > There's a difference. > In this spirit, is there a difference between the statement > > "(f f) is a value." > > and > > "(f f) has a value." > > or do they really mean the same thing? > There's a difference. The analogy is good. (I do remember having read this analogy in the book, though I can't seem to find it right now.) Here's my final rewrite. Feel free to scrutinize it. (BTW, thanks for your attention.) Exercise 20.1.1. Assume the Definitions window in DrScheme contains (define (f x) x). Identify the values among the following expressions: (1) (cons f empty) (2) (f f) (3) (cons f (cons 10 (cons (f 10) empty))) Explain why they are values and why the remaining expressions are not values. Solution. A value is anything of the form <val> = <boo> | <sym> | <num> | empty | <lst> | <var> (names of defined functions) | <prm> where <lst> is of the form <lst> = empty | (cons <val> <lst>). Now we start with (1) and apply a series of substitutions based on the definitions we have. (cons f empty) = (cons <var> <lst>) ;; since f is a <var> = (cons <var> <lst>) ;; since empty is a <lst> = (cons <val> <lst>) ;; since <var> is a subset of <val> = <lst> ;; definition of <lst> = <val> ;; definition of <val> Therefore (1) is a value. Next we consider (2). Here's a relevant part of the grammar for (2). <exp> = <var> | <prm> | (<exp> <exp> ...<exp>) Start with (2)... (f f) = (<var> <var>) ;; since f is a <var> = (<exp> <exp>) ;; since <var> is a subset of <exp> Now (<exp> <exp>) is not by definition a value. Expressions may have values, but they're not values. (Daniel may have a hat, but Daniel is not a hat.) Therefore (2) is not a value. Now (3). (cons f (cons 10 (cons (f 10) empty))) = (cons <var> (cons <num> (cons (<var> <num>) <lst>))) The whole expression depends on the application (<exp> <exp>), which may or may not have a value. Since we know f, we know it has a value, but it /is not/ a value. Therefore (3) is not a value.
____________________ Racket Users list: http://lists.racket-lang.org/users