# Average (J)

### From LiteratePrograms

We want to define a function, named "avr", to find the average of a vector.

<<average.ijs>>=avr=:definition

To get the average we need to sum the elements of the vector, and divide it by the number of elements.

<<definition>>=sum%#

We get the sum by inserting the verb "+" between each pair of elements with the adverb "/"

<<sum>>=+/