Open abhayptp opened 7 years ago
You should at least mention something about higher order function which is one of the essential difference between imperative and functional programming. It provides the 'glue' for composing programs from small functions.
On Aug 16, 2017 20:49, "Parv Mor" notifications@github.com wrote:
@parvmor commented on this pull request.
In _posts/2017-08-15-Functional_programming.md https://github.com/pclubiitk/pclub.in/pull/85#discussion_r133481264:
+ Lazy evaluation*: This is one of the wonderful features of FP. It enables us to hold an expression unevaluated unless there is an actual need of using it. It avoids repeated evaluation of same expressions. + +So, In FP, programs are executed by just evaluating expressions(without changing state), not by executing statements(which change global state). For example, +Fibonacci sequence(using imperative style): +```python +def fib1(n, first=0, second=1):
- while n != 0:
- n = n - 1
- first = second
- second = first + second +
+Using functional style(in scala): +
scala +def fib2(n: Int): Int = {- n match {
- case 0 => 0
At least add that stuff. If you want you can also show some examples on lazy evaluation. Since, you are writing it in scala show the effects of declaring a variable as lazy. Along with that you can also show how sometimes laziness needs to be taken care while IO.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pclubiitk/pclub.in/pull/85#discussion_r133481264, or mute the thread https://github.com/notifications/unsubscribe-auth/ABrck18UDWM1syu5ZnwQ-GIihSJEDz0Yks5sYwhrgaJpZM4O33Ni .
@parvmor see if you can add something!