Details

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

      Description

      It would be useful to support something like F#'s compose '>>' operator for Closures, e.g.:

      def twice = { a -> a * 2 }
      def inc = { b -> b + 1 }
      def f = inc >> twice
      def g = { x -> twice(inc(x)) } // longhand equivalent
      assert f(10) == 22
      assert g(10) == 22
      
      def string2char = { it.chars[0] }
      def p = Integer.&toHexString >> string2char >> Character.&toUpperCase
      assert p(15) == 'F'
      
      def multiply = { a, b -> a * b }
      def identity = { a -> [a, a] }
      def sq = identity >> multiply
      assert (1..5).collect{ sq(it) } == [1, 4, 9, 16, 25]
      

        Activity

        paulk@asert.com.au created issue -
        Paul King made changes -
        Field Original Value New Value
        Attachment groovy4322_ClosureComposition.patch [ 50291 ]
        Paul King made changes -
        Attachment groovy4322_ClosureComposition_B.patch [ 50434 ]
        Paul King made changes -
        Attachment groovy4322_ClosureComposition.patch [ 50291 ]
        Paul King made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733264 ] Default workflow, editable Closed status [ 12744997 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12970815 ] Default workflow, editable Closed status [ 12978587 ]
        Mark Thomas made changes -
        Reporter Paul King [ paulk@asert.com.au ] Paul King [ paulk ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development