Created
December 8, 2011 13:52
-
-
Save xitij2000/1447050 to your computer and use it in GitHub Desktop.
haXe code to print squares of first 10 numbers.
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
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; | |
} |
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
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment