xitij2000
12/8/2011 - 1:52 PM

haXe code to print squares of first 10 numbers.

haXe code to print squares of first 10 numbers.

package;
import js.Dom
class Main { 
       public static function main() {
              new Main();
              js.Lib.document.write(Main.square(10).join(","));
       }
       public static function square(n:Int):Array<Int> {
              var i:Int = 0;
              var result:Array<Int> = new Array<Int>();
              for (i in i...n){
                     result.push(i*i);
              }
              return result;
       }
} 
Main.main = function() {
       new Main();
       js.Lib.document.write(Main.square(10).join(","));
}
Main.square = function(n) {
       var i = 0;
       var result = new Array();
       {
              var _g = i;
              while(_g < n) {
                     var i1 = _g++;
                     result.push(i1 * i1);
              }
       }
       return result;
}