Scheme Exercises

back to exercise list       previous     next

Group:     Exercise: 28/48 

median:  median will return the median of a sorted list of numbers

Create the function "median" which will be given a sorted list of numbers (numbers in non-decreasing order) will return the median of the numbers.
IMPORTANT: define your own version of the LENGTH function (don't use LENGTH).
For instance:
(median '(1 2 3)) ; -> 2
(median '(1 2 3 4)) ; -> 2 1/2
(median '(1)) ; -> 1
(median '(1 1 1 3 8)) ; -> 1