-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasicFunction.js
More file actions
63 lines (56 loc) · 1.87 KB
/
basicFunction.js
File metadata and controls
63 lines (56 loc) · 1.87 KB
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
60
61
62
63
var miscellaneousOperations = require('./Miscellaneous.js');
var basicOperations =
function() {
function isSingleArray(data) {
if (miscellaneousOperations.get_Dimensions(data).length == 2 && miscellaneousOperations.get_Dimensions(data)[0] == 1) {
return true;
}
return false;
}
function hasSingleItem(data) {
if (data.length == 1) {
return true;
} else {
return false;
}
}
function check_all_dimensions_same(firstArray, secondArray) {
var firstSize = miscellaneousOperations.get_Dimensions(firstArray);
var secondSize = miscellaneousOperations.get_Dimensions(secondArray);
if (firstSize.length != secondSize.length) {
return false;
} else {
for (var i = 0; i < firstArray.length; i++) {
if (firstSize[i] != secondSize[i]) {
return false;
}
}
return true;
}
}
function is_first_greater(first_array, second_array) {
first_array_dimension = miscellaneousOperations.get_Dimensions(first_array);
second_array_dimension = miscellaneousOperations.get_Dimensions(second_array);
if (first_array_dimension.length > second_array_dimension.length) {
return true;
} else if (first_array_dimension.length == second_array_dimension.length) {
for (j in first_array_dimension) {
if (second_array_dimension[j] < first_array_dimension[j]) {
return true;
} else if (second_array_dimension[j] > first_array_dimension[j]) {
return false;
}
}
return true;
} else {
return false;
}
}
return {
are_dimensions_same: check_all_dimensions_same,
is_first_greater: is_first_greater,
isSingleArray: isSingleArray,
hasSingleItem: hasSingleItem
}
}
module.exports = basicOperations();