Latest Changes

Differences between version #20109 and #20113

1,16d0
< ====== _ (underscore) ======
< 
< HaXe 3.0 provides an intuitive language construct for partial function application, also known as currying. Call a function with an underscore character in place of one or more argument values, and it will return a wrapper function that takes only those "fill-in-the-blank" arguments. Then when you call this wrapper function, it will call the original function and automatically insert the values for the other arguments you specified.
< 
< <code haxe>
< public function sumXplusY(x:Int, y:Int) {return x + y;}
< public static function main(){
< 	var sumXplus2 = sumXplusY( _, 2 );
< 	var sum4plusY = sumXplusY( 4, _ );
< 	trace(sumXplus2(3)); // traces 5
< 	trace(sum4plusY(3)); // traces 7
< }
< </code>
< 
< Currently this syntatic sugar requires the //-D haxe3// compiler switch, otherwise you must use the more verbose style described below.
< 
47,59c31
< </code>
< 
< With the new syntax you can also do this:
< 
< <code haxe>
< // calculate the squares of each element of an array
< trace(Lambda.map( [10,2,36,4,5], Math.pow(_, 2)));
< 
< // which is the same as this:
< trace(Lambda.map( [10,2,36,4,5], function(x) { return Math.pow(x, 2);}));
< 
< // this cannot be done with the old callback() syntax
< </code>
---
> </code>
\ No newline at end of file

	
Ver Date Entry Lg User Action
#20122 2014-05-24 12:52:26 com/libs/cocktail/cocktail_web_app_demo en codam View | Diff
#20121 2014-05-22 20:00:15 doc/libraries en Confidant View | Diff
#20120 2014-05-22 19:49:58 doc/libraries en Confidant View | Diff
#20119 2014-05-22 11:25:38 manual/macros kr papapang View | Diff
#20118 2014-05-22 11:25:38 manual/macros kr papapang Set title to macros (매크로)
#20117 2014-05-22 07:16:17 doc/glossary en vitalyo View | Diff
#20116 2014-05-21 19:35:43 doc/libraries en Confidant View | Diff
#20115 2014-05-21 15:17:54 doc/libraries en Confidant View | Diff
#20114 2014-05-21 15:16:44 doc/libraries en Confidant View | Diff
#20113 2014-05-21 13:13:34 ref/callback en Simn View | Diff
#20112 2014-05-20 19:48:30 doc/libraries en Confidant View | Diff
#20111 2014-05-20 19:47:59 doc/libraries en Confidant View | Diff
#20110 2014-05-20 19:18:18 doc/libraries en Confidant View | Diff
#20109 2014-05-17 18:07:43 ref/callback en galundin View | Diff
#20108 2014-05-17 18:05:56 ref/callback en galundin View | Diff
#20107 2014-05-17 17:51:30 ref/callback en galundin View | Diff
#20106 2014-05-11 22:04:20 ref/oop en Chax0 View | Diff
#20105 2014-05-11 22:02:31 ref/oop en Chax0 View | Diff
#20104 2014-05-09 04:42:48 doc/java/lwjgl en JLM View | Diff
#20103 2014-05-08 13:52:07 doc/java/lwjgl en JLM View | Diff

Previous | Next