[racket] missing solution 20.1.1 ex:sem-funcs

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Sep 8 20:51:37 EDT 2014

On Sep 2, 2014, at 11:45 AM, Daniel Bastos wrote:

> A candidate for a solution.
> 
> 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. First we consider (1). Here's the relevant part of the
> grammar.
> 
>  <lst> = empty | (cons <val> <lst>)
> 
>  <val> = <boo> | <sym> | <num> | empty | <lst>
>  | <var> (names of defined functions)
>  | <prm>
> 
> So (1) is a value because it is <lst> of the form (cons <var> empty),
> where f is <var> because it is a defined function.
> 
> Let's consider (3) before (2). (3) is a list of either <var> or <num>,
> so (3) is <val> as well.

You checked only one half of the value-grammar for lst. Check the other half, too. Report back whether you want to change the answer or not. -- Matthias



Posted on the users mailing list.