/******************************* REXX ********************************/
/* This function receives a list of numbers, adds them, computes */
/* their average, and returns the average to the calling program. */
/*********************************************************************/
ARG numlist /* receive the numbers in a single variable */
sum = 0 /* initialize sum to zero */
DOn=1TOWORDS(numlist) /* Repeat for as many times as there */
/* are numbers */
number = WORD(numlist,n) /* Word #n goes to number */
sum = sum + number /* Sum increases by number */
END
average = sum / WORDS(numlist) /* Compute the average */
RETURN average
Figure 44. Possible Solution
Writing Subroutines and Functions
Chapter 6. Writing Subroutines and Functions 69