-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththe-problem.js
57 lines (42 loc) · 1.17 KB
/
the-problem.js
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
/* AD-LIB #1:
"__ITEM__" (SINGULAR NOUN)
- can be filtered in one or more ways
- has properties that can be read
- there are literally millions of instances
of this thing (like Finnish metal bands)
*/
/* AD-LIB #2:
"__RESULT__" (SINGULAR / PLURAL NOUN)
- results from operating on the
collection of __ITEM__s
- can be a collection
(list of names of bands that sing about programming)
- can be an aggregate
(markdown table of bands, sorted by date of last single)
*/
const every__ITEM__ =
synchronouslyGetEvery__ITEM__(); // <- please don't do this, IRL
const __RESULT__ = every__ITEM__
/* TODO:
build result by chaining maps, filters, reduces
.filter()
.map()
.reduce();
*/
/* Question:
Assuming there were 10 million __ITEM__s, what is the worst-case
performance (ie: all items pass all filters) of this solution?
*/
/* Challenge:
Rewrite the solution to have only 10,000,000 operations,
if there are 10,000,000 items.
Use transduction.
*/
const every__ITEM__ =
synchronouslyGetEvery__ITEM__(); // <- again, please no? For me?
const __RESULT__ = every__ITEM__.reduce(
// Transduce here
);
/* Hint:
See digression.js
*/