elegance of functional programming

Functional programming allows you to write concise and elegant code. Mainstream languages like Ruby and C# support a lot of functional programming paradigms, and learning them makes you a better programmer. Below is a small example which demonstrates that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#6 lines of ugly code
i = 0
tasks = list.tasks
while(i < tasks.length - 2)
tasks[i].priority.should >= tasks[i + 1].priority
i += 1
end
#3 lines of elegant functional code
list.tasks.each_cons(2).each do |t1, t2|
t1.priority.should >= t2.priority
end

I am currently working on Zammu which makes Automatic Deployment of static websites to Github Pages very easy. I would love to get your feedback on it, Use the invitation code KHAJA