Functional programming example written in ruby