[racket] Looking for feedback on code style
On 9/9/10 3:51 AM, Noel Welsh wrote:
> On Thu, Sep 9, 2010 at 4:35 AM, Scott Hickey<jscotthickey at gmail.com> wrote:
>> I was helping my son with his math homework tonight, working with
>> medians and wrote the following below. As I was looking at it, I was
>> wondering:
> ...
>
> I think this is great code -- very clear.
What!?
Without a purpose statement, contract, or examples, it's difficult to
know what this code is supposed to do, much less say if it is doing
whatever it is supposed to do correctly.
But if I guess at what it's supposed to do (bad idea), then there's
still a free reference to `middle-ref'. Supposing that should be
`middle-position', the amended code blows up on the first example I tried:
(median (list 1))
list-ref: expects type <non-negative exact integer> as 2nd argument,
given: -1; other arguments were: (1)
David