listAverage

From Second Life Wiki
Revision as of 19:52, 25 May 2010 by Ugleh Ulrik (talk | contribs) (Created page with '{{LSL_Function |func=ListAverage |func_desc=when given a list of all integers it will give you the mathematical average of all numbers. |return_type=integer |return_text=which is...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: integer ListAverage( list src );

when given a list of all integers it will give you the mathematical average of all numbers.
Returns an integer which is the mathematical average of a list of numbers.

• list src The list to of integers.

Examples

<lsl>

       list mixed = [1, 2.0, "3", "Four", (key)"8aef4875-6873-0919-f5ab-c9d6b48d18d4"];
       // Prints: 1, 2, 3, 0, 8
       llOwnerSay(llList2CSV(listCast(mixed, TYPE_INTEGER)));
       // Prints: 1.000000, 2.000000, 3.000000, 0.000000, 0.000000
       llOwnerSay(llList2CSV(listCast(mixed, TYPE_FLOAT)));
</lsl>

Implementation

<lsl> list data = [1,2,3,3,3,3,5,3,5,2,3,3]; default {

   state_entry()
   {
   llSay(0,(string)ListAverage(data));

} } </lsl>