equal
deleted
inserted
replaced
643 "Modified: 23.1.1997 / 13:35:48 / cg" |
643 "Modified: 23.1.1997 / 13:35:48 / cg" |
644 ! |
644 ! |
645 |
645 |
646 beCurryingBlock |
646 beCurryingBlock |
647 "make myself a currying block; |
647 "make myself a currying block; |
648 thats a block which, if invoked with less-than-expected arguments, |
648 that's a block which, if invoked with less-than-expected arguments, |
649 returns another block which provides the provided argument(s) and expects the remaining args. |
649 returns another block which provides the provided argument(s) and expects the remaining args. |
650 Read any book on functional programming, if you dont understand this." |
650 Read any book on functional programming, if you don't understand this." |
651 |
651 |
652 self changeClassTo:CurryingBlock. |
652 self changeClassTo:CurryingBlock. |
653 ^ self |
653 ^ self |
|
654 |
|
655 " |
|
656 |b b1 b2 b3| |
|
657 |
|
658 b := [:a :b :c | a + b + c] beCurryingBlock. |
|
659 b numArgs. |
|
660 b value:1 value:2 value:3. |
|
661 |
|
662 b1 := b value:10. |
|
663 b1 numArgs. |
|
664 b1 value:2 value:3. |
|
665 |
|
666 b2 := b value:10 value:20. |
|
667 b2 numArgs. |
|
668 b2 value:3. |
|
669 |
|
670 b3 := b1 value:20. |
|
671 b3 numArgs. |
|
672 b3 value:3. |
|
673 " |
|
674 |
|
675 "Modified: / 10-05-2010 / 12:56:20 / cg" |
654 ! |
676 ! |
655 |
677 |
656 beVarArg |
678 beVarArg |
657 "convert myself into a varArg block; |
679 "convert myself into a varArg block; |
658 this one has 1 formal argument, which gets the list |
680 this one has 1 formal argument, which gets the list |
2898 ! ! |
2920 ! ! |
2899 |
2921 |
2900 !Block class methodsFor:'documentation'! |
2922 !Block class methodsFor:'documentation'! |
2901 |
2923 |
2902 version |
2924 version |
2903 ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.176 2010-04-23 13:33:01 mb Exp $' |
2925 ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.177 2010-05-10 10:56:48 cg Exp $' |
2904 ! |
2926 ! |
2905 |
2927 |
2906 version_CVS |
2928 version_CVS |
2907 ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.176 2010-04-23 13:33:01 mb Exp $' |
2929 ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.177 2010-05-10 10:56:48 cg Exp $' |
2908 ! ! |
2930 ! ! |
2909 |
2931 |
2910 Block initialize! |
2932 Block initialize! |