Difference between revisions of "ListAverage"
Jump to navigation
Jump to search
Ugleh Ulrik (talk | contribs) (Blanked the page) |
Ugleh Ulrik (talk | contribs) (Undo revision 928762 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> |
Revision as of 17:53, 29 September 2011
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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>