Github user tillrohrmann commented on the pull request:

    https://github.com/apache/flink/pull/1220#issuecomment-146474169
  
    A more scalaesque solution for the `partitionBox` method without using vars 
and for loops would be
    
    ```
    def partitionBox(center: Vector, width: Vector): Seq[Vector] = {
        def partitionHelper(box: Seq[Vector], dim: Int): Seq[Vector] = {
          if (dim >= width.size) {
            box
          } else {
            val newBox = box.flatMap {
              vector =>
                val (up, down) = (vector.copy, vector)
                up.update(dim, up(dim) - width(dim) / 4)
                down.update(dim, down(dim) + width(dim) / 4)
    
                Seq(up, down)
            }
            partitionHelper(newBox, dim + 1)
          }
        }
    
        partitionHelper(Seq(center), 0)
      }
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to