1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Lazy = void 0;
|
4 |
|
5 |
|
6 |
|
7 | class Lazy {
|
8 | constructor(f) {
|
9 | this.f = f;
|
10 | }
|
11 | value() {
|
12 | const res = this.f();
|
13 | delete this.f;
|
14 | this.value = () => res;
|
15 | return res;
|
16 | }
|
17 | map(f) {
|
18 | return new Lazy(() => f(this.value()));
|
19 | }
|
20 | add(b) {
|
21 | return this.map(a => a + b);
|
22 | }
|
23 | minus(b) {
|
24 | return this.map(a => a - b);
|
25 | }
|
26 | mult(b) {
|
27 | return this.map(a => a * b);
|
28 | }
|
29 | rem(b) {
|
30 | return this.map(a => a % b);
|
31 | }
|
32 | div(b) {
|
33 | return this.map(a => a / b);
|
34 | }
|
35 | quot(b) {
|
36 |
|
37 | return this.map(a => (a / b) | 0);
|
38 |
|
39 | }
|
40 | quotRem(b) {
|
41 | return this.map((a) => {
|
42 |
|
43 | return [(a / b) | 0, a % b];
|
44 |
|
45 | });
|
46 | }
|
47 | and(b) {
|
48 | return this.map(a => a && b);
|
49 | }
|
50 | or(b) {
|
51 | return this.map(a => a || b);
|
52 | }
|
53 | not() {
|
54 | return this.map(a => !a);
|
55 | }
|
56 | notnot() {
|
57 | return this.map(a => !!a);
|
58 | }
|
59 | }
|
60 | exports.Lazy = Lazy;
|
61 |
|
\ | No newline at end of file |