Lasso Soft Inc. > Home

[lp_math_mean]

Linklp_math_mean
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted03 Dec 2005
Updated04 Dec 2005
More by this author...

Description

Returns the mean average value given an array of values.

Note: Requires [lp_decimal_precisionSet]

Sample Usage

lp_math_mean: (:1,2,3,4), 2;

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[

define_tag:'lp_math_mean',
	-description='Returns the mean average value given an array of values.',
	-priority='replace',
	-required='numbers', -type='array',
	-optional='precision';

	// did we get a precision?
	if:!(local_defined:'precision');
		// nope, set it to zero
		local:'precision' = 0;
	/if;

	local:'return' = decimal;
	
	iterate: #numbers, local:'number';
		#return += (decimal: #number);
	/iterate;

	// return the average
	return: (lp_decimal_precisionSet: (decimal:((decimal:#return) / (decimal:(#numbers->size)))), (integer:#precision));

/define_tag;
    
]

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft