FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ReoScript/Source/ReoScript/scripts/array_ext.reo at master · unvell/ReoScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
unvell
/
ReoScript
Public
Notifications
You must be signed in to change notification settings
Fork
35
Star
109
Code
Issues
4
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ReoScript
/
Source
/
ReoScript
/
scripts
/
array_ext.reo
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (45 loc) · 1.39 KB
Breadcrumbs
ReoScript
/
Source
/
ReoScript
/
scripts
/
array_ext.reo
Copy path
File metadata and controls
59 lines (45 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*****************************************************************************
*
* ReoScript - .NET Script Language Engine
*
* https://github.com/unvell/ReoScript
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
* PURPOSE.
*
* This software released under MIT license.
* Copyright (c) 2012-2019 Jingwood, unvell.com, all rights reserved.
*
****************************************************************************/
if (Array != null && Array.prototype != null) {
Array.prototype.sum = function(predicate) {
var arr = (predicate == null) ? this : this.where(predicate);
var total = 0;
for (e in this) {
total += e;
}
return total;
};
Array.prototype.avg = function(predicate) {
var arr = (predicate == null) ? this : this.where(predicate);
return arr.length == 0 ? 0 : (arr.sum() / this.length);
};
Array.prototype.min = function(predicate) {
var arr = (predicate == null) ? this : this.where(predicate);
var min = 0;
for (v in this) {
if (min > v) min = v;
}
return min;
};
Array.prototype.max = function(predicate) {
var arr = (predicate == null) ? this : this.where(predicate);
var max = 0;
for (v in this) {
if (max < v) max = v;
}
return max;
};
}
Back
|
FazBrowse Home
|
New Git URL