def compose(x, proc1, proc2) 
    proc2.call(proc1.call(x))
end

double = proc { |x| x * 2 }
square = lambda { |x| x * x }
triple = -> (x) { x * 3 }
    
p compose(5, double, square)
p compose(5, square, double)
p compose(5, triple, double)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: