Arity & Currying

Blogs, Snippets
This is a series of blogs where I collect some interesting programming concepts, new things I learn Arity represents the number of arguments we pass to a function (or module). Say you may pass N args to a function. Currying is the process of reducing the number of arguments you pass to 1 but increase the number of functions to N. For Eg. To add three variables a, b and c you may write func like below function add (a,b,c){ return a+b+c; } add (45, 46, 47); Currying the same above function is then like below function add (a){ return function add (b){ return function add (c){ return a+b+c; }; }; } add (45) (46) (47); Notice how each function returns another function until the last function does the final…
Read More

Imperative vs Declarative programming paradigm

Blogs, LabVIEW Blog, New Learnings
This is a series of blogs where I collect some interesting programming concepts,┬ánew things I learn As LabVIEWers we're familiar with few programming paradigms like object-oriented (OOP). Have you heard of functional programming?Imperative Programming changes the state of the program. OOP is an imperative programmingDeclarative Programming: doesn't change the state of the program. Functional is a declarative programming Wikipedia has more details on the programming paradigm 2 main principles of Functional Programming Don't mutate. Don't change the state of the program, whatever data comes into the function make a new copy of the function and return the new data without modifying the original data. Keep the function purely independent ie., even if you want to play with the global variables, then pass that global variable as arguments to that function…
Read More