Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.8-beta-1
-
None
-
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]