Below you will find pages that utilize the taxonomy term “functional-programming”
Posts
Currying in functional programming
Currying Currying is an idea of decomposing a function and making the expression more clearer. (Note: it’s just expression decomposition and not execution)
Example In Go: package main import ( "fmt" "strings" ) func main() { fmt.Println(someComplexOperation("hello", "there", "programmer")) fmt.Println(someComplexOperation("hello", "there", "manager")) fmt.Println(someComplexOperation("hello", "there", "CEO")) // Currying this function // By looking at the fuction we see that it can be decomposed, first step of computing from first 2 arguments // can be done and reused.
read morePosts
Loop Iterator variable scope in golang
Per Iteration Vs Per Loop In most of the languages, the loop variable (iterator) has a per iteration scope, meaning in each iteration a new copy of that variable is made. But in golang it’s the same variable that has the scope throughout the loop. All the changes (increments) apply to the same placeholder and if you are temporarily capturing them and spawning go routines or creating a function placeholder (for later execution) you start to see unexpected consequences.
read morePosts
Idea of 'closure' in functional programming
Closure The inner function has access to variables which were in the enclosing scope even after that ’ennclosing scope’ execution is over. (Inner function gets a copy) This is my attempt to understand why is this such an important concept in functional programming, why is it named so and so on… Functions are first class citizens In functional paradigm of programming functions are considered as ‘first class citizens’. This means functions can be
read more