Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » Functions

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

average

average(numberList)

Value returned: number equal to the arithmetic average of the comma- separated list of numbers


Examples

average(1,2,3,4,5,6,7,8,9,10)

repeat with N = 1 the number of lines of field "Number Data"
  put line N of field "Number Data" into item N of theNumbers
end repeat
put average(theNumbers)

Demo Script

on onAverage
  repeat with numLine = 1 to the number of lines of me
    put the number of words of line numLine of me into¬
    item numLine of wordsInEachLine
  end repeat
  put "There are an average of" && average(wordsInEachLine) && ¬
  "words in each line of this field." into sayIt
  answer sayIt
end onAverage

Placeholders

numberList
A comma-separated list of numbers.
1,2,3,4,5
"1.2,2.2,3.2"
In AppleScript, the list must be enclosed in brackets:
{1,2,3,4,5}


Related Topics

« atan | HyperTalk Reference | charToNum »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View