code: function takeCurve(pred) {
      for(var i=0, n=horizon.length; i<n; ++i) {
        var c = horizon[i]
        if(pred(c)) {
          horizon[i] = horizon[n-1]
          horizon.pop()
          return c
        }
      }
      return null
    }
docs: Finds and remove the first curve in horizon matching predicate