This Racket code gives an error, why? (define (maxnode edges) (apply max (map max edges)))
- User
This Racket code gives an error, why? (define (maxnode edges) (apply max (map max edges)))
Assistant
This code gives an error because
maxexpects numbers as arguments to compare, butedgeslikely contains sub-lists or other non-number values that can't be compared directly.Some key points:
-
maxexpects numbers as arguments to find the maximum value. Butedgesprobably contains nested lists or other non-number values. -
map max edgestries to find the max of each sub-list/element inedges. But those sub-lists can't be compared directly withmax. -
apply maxthen tries to pass a list of non-numbers tomax, causing the error.
To fix it, you'd need to:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.