-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeid_GET.sc
More file actions
89 lines (87 loc) · 2.44 KB
/
feid_GET.sc
File metadata and controls
89 lines (87 loc) · 2.44 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// NONE --> GET_INDEX_2D
GET_INDEX_2D = LAMBDA(lookup_value, array, [return_as_order],
LET(
return_as_order, IF(
ISOMITTED(return_as_order),
FALSE,
return_as_order
),
nrows, ROWS(array),
ncols, COLUMNS(array),
size, nrows * ncols,
array_flatten, TOCOL(array, , TRUE),
index_sequence, SEQUENCE(nrows, ncols, 1, 1),
rows_sequence, MAKEARRAY(nrows, ncols, LAMBDA(x, y, x)),
columns_sequence, MAKEARRAY(nrows, ncols, LAMBDA(x, y, y)),
rows_flatten, TOCOL(rows_sequence, , TRUE),
columns_flatten, TOCOL(columns_sequence, , TRUE),
index_flatten, TOCOL(index_sequence, , TRUE),
lookup_table, HSTACK(index_flatten, rows_flatten, columns_flatten),
lookup_result, FILTER(lookup_table, array_flatten = lookup_value),
IF(return_as_order, CHOOSECOLS(lookup_result, 1), lookup_result)
)
);
// _RECURSIVE_LOOKUP --> _RECURSIVE_LOOKUP
_RECURSIVE_LOOKUP = LAMBDA(
ntry,
lookup_value,
lookup_vector,
return_array,
[if_not_found],
[match_mode],
[search_mode],
LET(
lookup_value, TOCOL(lookup_value),
LET(
selected_value, VALUE(
ARRAYTOTEXT(CHOOSEROWS(lookup_value, ntry))
),
result, XLOOKUP(
selected_value,
lookup_vector,
return_array,
if_not_found,
match_mode,
search_mode
),
IF(
ntry = 1,
result,
VSTACK(
_RECURSIVE_LOOKUP(
ntry - 1,
lookup_value,
lookup_vector,
return_array,
if_not_found,
match_mode,
search_mode
),
result
)
)
)
)
);
// _RECURSIVE_LOOKUP --> GET_XLOOKUP
GET_XLOOKUP = LAMBDA(
lookup_value,
lookup_vector,
return_array,
[if_not_found],
[match_mode],
[search_mode],
LET(
lookup_value, TOCOL(lookup_value),
ntry, ROWS(lookup_value),
_RECURSIVE_LOOKUP(
ntry,
lookup_value,
lookup_vector,
return_array,
if_not_found,
match_mode,
search_mode
)
)
);