listAverage

From Second Life Wiki
Revision as of 18:53, 29 September 2011 by Ugleh Ulrik (talk | contribs) (Undo revision 928762 by Ugleh Ulrik (Talk))
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>