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 (aux (cdr lst) max)]))
   (aux lst 0))


Using the function always returns the last value in the list

> (maxval (list 1 2 3 5 6 1))
1

The code looks correct to me, but I must be missing something.  What have I 
done wrong?

Angus

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to