Skip to content

Instantly share code, notes, and snippets.

@xitij2000
Created December 8, 2011 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xitij2000/1447050 to your computer and use it in GitHub Desktop.
Save xitij2000/1447050 to your computer and use it in GitHub Desktop.
haXe code to print squares of first 10 numbers.
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;
}
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