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

There should be a DGM.subsequences method

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.7-rc-1, 1.6.7
    • 1.7-rc-2
    • groovy-jdk
    • None

    Description

      As per mailing list, Groovy should have a subsequences method.
      Once implemented, the following assertions should pass:

      def items = [1, 2, 3]
      assert items.subsequences() == [[1, 2, 3], [1, 3], [2, 3], [1, 2], [1], [2], [3]] as Set
      assert "frog".toList().subsequences() == [
              ['f', 'r', 'o', 'g'],
              ['f', 'r', 'o'],
              ['f', 'r', 'g'],
              ['f', 'o', 'g'],
              ['r', 'o', 'g'],
              ['f', 'g'],
              ['r', 'g'],
              ['o', 'g'],
              ['f', 'o'],
              ['r', 'o'],
              ['f', 'r'],
              ['f'],
              ['r'],
              ['o'],
              ['g']
      ] as Set
      

      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: