Guest User

Untitled

a guest
Jun 10th, 2010
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function range(from, to){
  2.     var arr = [];
  3.     for(var i=from; i!=to; i+=from<to ? 1 : -1){
  4.         arr.push(i);
  5.     }
  6.     return arr;
  7. };
  8.  
  9. Array.prototype.foreach = function(func){
  10.     for(var i=0; i<this.length; i++){
  11.         func.apply(this[i]);
  12.     }
  13. };
  14.  
  15. function print(s){
  16.     console.log(s)
  17. };
  18.  
  19. function mod_range(i){
  20.     return i%2 ? range(1, i+1) : range(i, 0);
  21. };
  22.  
  23. range(1,11).foreach(function(){
  24.   print(mod_range(this).join("-"));
  25. });
RAW Paste Data