Skip to content

Ch. 5, Purely Relative: Median function doesn't return median  #156

Open
@mikmart

Description

@mikmart

In the Purely Relative section of Chapter 5 you define a function called median to use in an example, but it doesn't actually find the median: it's just returning the average of the first and last values in the array. (Which just coincidentally is also the median in the specific array used in the example.)

Actually defining median inline might be a bit too complicated (as the purpose of the function in the example is just to illustrate the side effects of modifying the array referenced by the closure) so maybe the function should just be renamed? Or alternatively it could be changed to calculate the mean, since that would give the same output in the example, and is simple to define?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions