Changes to illustrate the principles of functional programming.

Please don't merge, it is just for illustration purpose. Thanks.

!!!!!!!!!!!!!!!!!!!!!