Advertisement
Guest User

Untitled

a guest
Aug 9th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1.  
  2. // it's a simple for loop that goes: R = (some random int); T = 0; for o in os (T = T + o.w; if T > R then return o)
  3.  
  4. var short_circuit_thing = function(objects, r) {
  5. var main_helper = function(t, others) {
  6. var o = _.first(others);
  7. var new_t = t + 0.w
  8. if (new_t > r) {
  9. return o;
  10. } else {
  11. return main_helper(new_t, _.rest(others));
  12. }
  13. };
  14.  
  15.  
  16. return main_helper(0, objects);
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement