Difference between revisions of "ListAverage"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 928762 by Ugleh Ulrik (Talk))
(Undo revision 1155234 by Ugleh Ulrik (Talk))
 
Line 1: Line 1:
{{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 the mathematical average of a list of numbers.
|p1_type=list|p1_name=src|p1_desc=The list to of integers.
|mode=user
|cat1=Library
|cat2=User-Defined Functions
|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>

Latest revision as of 18:54, 29 September 2011