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

Groovy should have a transpose() method

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1-beta-2
    • 1.1-beta-3
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: