|
26 | 26 | // on TimeEngine infinite Sequence |
27 | 27 | // map natural numbers sequence on intervalSeq(1000) |
28 | 28 | const TimerElement = () => __Element(__ |
29 | | - .intervalSeq(Immutable.Range(), 1000) |
30 | | - .__((count) => (__.log.t = count)) //console.log |
31 | | - .__((count) => (<div>{"Timer : "}{count}</div>))); |
| 29 | + .intervalSeq(Immutable.Range(), 1000) |
| 30 | + .__((count) => (__.log.t = count)) //console.log |
| 31 | + .__((count) => (<div>{"Timer : "}{count}</div>))); |
32 | 32 |
|
33 | 33 | // memory leak, performance issue |
34 | 34 | //how about games? memoized_reduce is needed |
|
37 | 37 | const __updn = __(true); //1 or -1 or initially 0 |
38 | 38 | const __seqEl = __([__updn]) |
39 | 39 | .__(([updn]) => (__updn |
40 | | - .reduce((a, b) => (a + b)))) //js Array.reduce |
| 40 | + .reduce((a, b) => (a + b)))) //js Array.reduce |
41 | 41 | .__((count) => (<span>{count}</span>)); |
42 | 42 | const init = () => (__updn.t = 0); //just trigger to view the init |
43 | 43 | const __runNow = __ |
|
48 | 48 | onClick={() => (__updn.t = 1)}>{"Up"}</button> |
49 | 49 | <button |
50 | 50 | onClick={() => (__updn.t = -1)}>{"Down"}</button> |
51 | | - {__Element(__seqEl)} |
| 51 | + {__Element(__seqEl)} |
52 | 52 | </span>); |
53 | 53 | }; |
54 | 54 |
|
|
84 | 84 | onClick={() => (__updn.t = 1)}>{"Up"}</button> |
85 | 85 | <button |
86 | 86 | onClick={() => (__updn.t = -1)}>{"Down"}</button> |
87 | | - {__Element(__seqEl)} |
| 87 | + {__Element(__seqEl)} |
88 | 88 | <button |
89 | 89 | onClick={init}>{"Reset"}</button> |
90 | 90 | </div>); |
|
99 | 99 | const THETA = DEG / 180 * Math.PI; //radian |
100 | 100 | const G = 9.8; //gravity const |
101 | 101 | //t seconds elapsed 0msec time resolution |
102 | | - const t = __ |
103 | | - .intervalSeq(Immutable.Range(), 10) |
104 | | - .__((count) => (count * 10 / 1000)); |
| 102 | + const t = __([__.intervalSeq(Immutable.Range(), 10)]) |
| 103 | + .__(([count]) => (count * 10 / 1000)); |
105 | 104 | const x = __([t]).__(([t]) => V0 * Math.cos(THETA) * t); |
106 | | - const y = __([t]).__(([t]) => V0 * Math.sin(THETA) * t - 1 / 2 * G * Math.pow(t, 2)); |
| 105 | + const y = __([t]).__(([t]) => V0 * Math.sin(THETA) * t - 1 / 2 * G * Math.pow(t, 2)).log(); |
107 | 106 | //================================== |
108 | 107 | const Drawscale = 1; //1 dot = 1 meter |
109 | 108 | const __seqEl = __([x, y]) //atomic update |
110 | 109 | .__(([x, y]) => ( |
111 | | - <div> |
| 110 | + <div> |
112 | 111 | <svg height = "250" width = "100%"> |
113 | 112 | <circle r="2" fill="red" |
114 | 113 | cx = {50 + x * Drawscale} cy = {250 - y * Drawscale}/> |
|
0 commit comments