2008-08-01から1ヶ月間の記事一覧

prototype.js分析 Enumerable

all() <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

prototype.js分析 Enumerable

inject 使い方よくわかってないですが。。 <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

prototype.js分析 Enumerable

要素をグループ化して処理を加える eachSlice() <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

prototype.js分析 Enumerable

配列になんらかの処理を加える collect() <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

prototype.js分析 Enumerable

全ての基本は _each() each() <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

JavaScript目次

Prototype.js分析 Enumerable学習法 高階関数の魅力にとりつかれつつあるので、そのスタイルをモノにするべくEnumerableをそらで書けるようになるまでひたすら写経を繰り返す。使い方をよくわかっていないメソッドもあるがコードの流れを体で覚えてしまうの…

デザインパターン目次

GoF本の23パターン AbstractFactory Perl Builder Perl FactoryMethod Perl PHP5 Prototype Perl Singleton Perl Adaptoer Perl Perl(委譲を利用) Bridge Perl Composite Perl Decorator Perl Facade Perl Flyweight Proxy Chain of Responsibility PHP4,5 C…

Chain of Responsibility

ヴァージョン5で。 だらだらと分岐を書くのはいいかげんやめようと。 set(new NotHoge())->set(new NotMoge()); $rs = $chk->execute($str); print "<pre>"; print_r($chk); print_r($rs); //---------------------------------- class InpChk{ var $list; functi</pre>…

prototype.js Enumerable _each each collect map eachSlice

eachSliceをprototype.jsなしの最小構成で実装 eachSliceメソッド内の「this.toArray()」はthis.collect()になる。引数にイテレータが無い場合はPrototype.Kが代入される。引数をそのまま返す関数です <script> Array.prototype._each = function(iterator){ for(var…

prototype.js Element Methods hideの実装

例によってprototype.jsを使わずに最小限で実装してみました。 もっと削っていけば理解も深まると思います。 applyとかをきちんと理解できるかがミソでしょうか。。 <script> function $(element){ if(typeof element == 'string') element = document.getElementByI…

prototype.js Enumerable each inject

グローバル変数が曲者でした。prototypeを使わずにinjectを記述してみます <script> Array.prototype._each = function(iterator){ for(var i=0, l=this.length; i

prototype.js 復習 Enumerable each _each

Gaucheを非常にゆっくりな速度で勉強しているが、それのおかげでプログラミングの考え方とかをきちんと身につけることができている気がする。 以下はprototype.jsの復習。以前に分析したときより自然にコードを読めたので書きとめておきました 1:配列の中身…