RosettaCodeData/Task/Function-composition/Crystal/function-composition.cr
2024-10-16 18:07:41 -07:00

7 lines
185 B
Crystal

require "math"
def compose(f : Proc(T, _), g : Proc(_, _)) forall T
return ->(x : T) { f.call(g.call(x)) }
end
compose(->Math.sin(Float64), ->Math.asin(Float64)).call(0.5) #=> 0.5