Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2120

Groovy should have a transpose() method

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1-beta-2
    • Fix Version/s: 1.1-beta-3
    • Component/s: None
    • Labels:
      None

      Description

      Groovy should have a transpose method like:

      Ruby's transpose() method on arrays
      Python's zip() method

      expected behaviour:

      assert [['a', 'b'], [1, 2, 3]].transpose() == [['a', 1], ['b', 2]]
      assert transpose(['a', 'b'], [1, 2, 3]) == [['a', 1], ['b', 2]]
      assert transpose([1, 2, 3], [4, 5, 6]) == [[1, 4], [2, 5], [3, 6]]
      assert transpose([1, 2, 3], [4, 5], [9], [6, 7, 8]) == [[1, 4, 9, 6]]
      assert transpose([1, 2, 3]) == [[1], [2], [3]]
      assert transpose([]) == []

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              paulk Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: