{
   "id" : "1-4SH",
   "is_private" : null,
   "code" : "(\r\n b = {|x,y|\r\n    var arr = List[];\r\n    case\r\n     {y % x.size == 0} // condition 1\r\n     {\r\n      var per = y / x.size;\r\n      x.size.do{|oo|\r\n       var pp = 1,i = 1;\r\n       arr.add( x[oo] );\r\n       while({i < per},{\r\n        arr.add(0);\r\n        i = i+1;\r\n       });\r\n      }\r\n     }\r\n     {x.size % y == 0} // condition 2\r\n     {\r\n      var pp = x.size / y, i = 0, sz = x.size;\r\n      while({i < sz},{\r\n       if(i % pp == 0)\r\n        { arr.add(x[i]) };\r\n       i=i+1;\r\n      });\r\n     };\r\n    arr\r\n   };\r\n a = [1,1,1,1];\r\n c = b.value(a,16) \r\n          // [ 1, 1, 1, 1 ]\r\n          // becomes\r\n          // [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]\r\n\r\n b.value(c,4); \r\n          // [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]\r\n          // becomes\r\n          // [ 1, 1, 1, 1 ]\r\n)",
   "labels" : [
      "utility",
      "function"
   ],
   "description" : "useful for expanding or reducing arrays by 2^x.\r\nI would like to know if there is a more concise way to write this!\r\nAny suggestions?\r\n\r\n(duplicate post, sorry! forgot to log in!)",
   "ancestor_list" : [],
   "name" : "List expander and contractor function",
   "author" : "moncrey"
}
