2020-12-01から1ヶ月間の記事一覧

アロー関数で再帰

JavaScript アロー関数で再帰 有ろうことか!アロー関数で再帰ができるとは知らなかった。 let func = ((cbFunc = arg=> { ... }) => cbFunc)() const fibonacci = ((fb= n=> n > 1 ? fb(n-2) + fb(n-1): n)=> fb)(); console.log(fibonacci (9));//-> 34 </script>ア…

時間を遅らせてコールバック関数を起動する

時間を遅らせてコールバック関数を起動する class DelayCBFunc { constructor (cbfunc, time = 500 /*ms*/) { this.cbfunc = cbfunc; this.time = time; this.tmid = null; this.disabled = false; } restart (...args) { this.stop (); this.tmid = setTime…

SELECTの連携を今更ながら書いてみた

寺尾で答えてみた https://teratail.com/questions/310078 なぜか面白くない。 提示されたコードは見難い。なので最初から自分で好きなように書いた方が楽。 汚いコードを指摘してあげるより、私はこれが楽だ。 本当の意味でのショートコーディングは奥が深…

PerlinNoise

class PerlinNoise { constructor (random = Math.random) { this.random = random; this.gradient = new Map; } randomGradient (x) { if (! this.gradient.has (x)) this.gradient.set (x, this.random () * 2 -1); return this.gradient.get (x); } noise…

PHP クラスの覚書

PHP クラスの覚書 a = $a; …