Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Ben Greenman
Here's a version of your code that runs in the Intermediate Student language ("local" isn't part of Beginning Student): (define (maxval lst) (local ((define (aux lst max) (cond [(null? lst) max] [(> (car lst) max) (aux (cdr lst) (car lst))]

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Matthias Felleisen
You may wish to read up on the design recipe and the necessity of ‘local’ definitions in HtDP2e: http://www.ccs.neu.edu/home/matthias/HtDP2e/ > On Feb 13, 2017, at 3:46 PM, Angus Comber wrote: > > But it has to have the signature maxval lst - it is a homework

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Angus Comber
But it has to have the signature maxval lst - it is a homework problem. So I thought I would need max in the helper function. Basically to keep an internal max saved value. Is there another way? On 13 February 2017 at 20:38, Matthias Felleisen wrote: > > Just lift aux

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Matthias Felleisen
Just lift aux out. > On Feb 13, 2017, at 3:18 PM, Angus Comber wrote: > > If I change the code to: > > (define (maxval lst) >(define (aux lst max) > (cond [(null? lst) max] >[(> (car lst) max) (aux (cdr lst) (car lst))] >[#t (aux

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Angus Comber
If I change the code to: (define (maxval lst) (define (aux lst max) (cond [(null? lst) max] [(> (car lst) max) (aux (cdr lst) (car lst))] [#t (aux (cdr lst) max)])) (aux lst 0)) and comment out #lang racket at the top of the file and select Beginning Student as

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-12 Thread Matthias Felleisen
> On Feb 12, 2017, at 3:00 PM, Angus wrote: > > I am a beginner Racket developer by the way. > > Here is my maxval function which is supposed to take a list and return the > largest integer in the list. > > (define (maxval lst) > (define (aux lst max) > (cond

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-12 Thread Jon Zeppieri
On Sun, Feb 12, 2017 at 3:00 PM, Angus wrote: > I am a beginner Racket developer by the way. > > Here is my maxval function which is supposed to take a list and return the > largest integer in the list. > > (define (maxval lst) >(define (aux lst max) > (cond

[racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-12 Thread Angus
I am a beginner Racket developer by the way. Here is my maxval function which is supposed to take a list and return the largest integer in the list. (define (maxval lst) (define (aux lst max) (cond [(null? lst) max] [(car lst) > max (aux (cdr lst) (car lst))] [#t