Last active
March 30, 2017 16:05
-
-
Save yotamorimoto/2275601 to your computer and use it in GitHub Desktop.
stream, pattern, and routine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Stream はオブジェクトのストリーム(流れ)で .next メッセージを受け「流れる」 | |
| Pattern はストリームの設計図 | |
| パターンオブジェクトのひとつ Pseries を使って | |
| 0から始まり、2ずつ増える、5個のストリームをつくる | |
| p = Pseries(0, 2, 5).asStream; | |
| p.next; | |
| p.next; | |
| p.next; | |
| p.next; | |
| p.next; | |
| p.next; // 5回目以降は nil が返る | |
| 配列からストリームをつくる | |
| 配列は [ ] でつくる(他の方法は Array クラスのヘルプ参照) | |
| p = Pseq([6, 5, 1, 2.5, -100], inf).asStream; // inf キーワードによって無限に繰り返す | |
| 20.do { p.next.postln; }; // number.do {} で関数を20回実行 | |
| 実践1 | |
| Pgeom, Pbrown, Pwhite を使ってストリームを定義し実行する | |
| 実践2 | |
| Pseq, Pser, Prand, Pxrand, Pwrand, Pshuf と配列を使ってストリームを定義、実行する |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment