Lasso Soft Inc. > Home

[pk_math_average]

Linkpk_math_average
AuthorPier Kuipers
CategoryMath
Version6.x
LicensePublic Domain
Posted10 Jan 2006
Updated16 Jan 2006
More by this author...

Description

Returns the average of an array of numbers

Sample Usage

[math_average: (Array: 2, 3.51, 4), 2] = 3.17
[math_average: (Array: 2, 3.51, 4)] = 3
[math_average: (Array: 11, 11, 15, 26, 25, 11, 12), 5] = 15.85714
[math_average: (Array: 11, 11, 15, 26, 25, 11, 12)] = 16
[variable: 'myArray' = (Array: 5.82, 12, 365, 3)]
[math_average: $myArray, 2] = 96.45

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.

 get: 1;
			local:'loopcount' = 2;
			loop: ((#number_array -> Size) - 1);
				#number_array_total += (decimal:(#number_array -> get: #loopcount));
				#loopcount += 1;
			/loop;
			local:'average' = (#number_array_total / (#number_array -> Size));
			#average->(setformat: -precision=#precision);
			return: #average;
		/define_tag;
		
	/If;

?>

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