script evaluateFunction
set {theFunction, theValue} to current application's NSApp's passedValue() as list
set theValue to current application's NSExpression's expressionForConstantValue_(theValue)
set theExpression to current application's NSExpression's expressionForFunction_arguments_(theFunction, {theValue})
return theExpression's expressionValueWithObject_context_(missing value, missing value)
end script
-- return the sum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"sum:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
-- return the average of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"average:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
-- return the minimum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"min:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
-- return the maximum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"max:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
-- return the median of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"median:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
-- return the standard deviation of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"stddev:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned
:-)