Changes between Version 44 and Version 45 of squeak_faq
- Timestamp:
- 02/24/2015 10:29:55 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
squeak_faq
v44 v45 716 716 {{{ 717 717 x := #(1 2 3 4 5). 718 b := x conform: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition" 718 b := x allSatisfy: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition" 719 b := x anySatisfy: [:a | a > 42]. "test if any element meets condition" 719 720 y := x select: [:a | a > 2]. "return collection of elements that pass test" 720 721 y := x reject: [:a | a < 2]. "return collection of elements that fail test" … … 722 723 y := x detect: [:a | a > 3] ifNone: []. "find position of first element that passes test" 723 724 sum := x inject: 10 into: [:a :c | a + c]. "sum of elements + 10" 724 sum := fold: [:x :y | x + y ]"sum elements"725 sum := x fold: [:a :b | a + b ] "sum elements" 725 726 }}} 726 727 Beispiele mehrheitlich aus [http://wiki.squeak.org/squeak/5699 Terse Guide to Squeak].