Giter VIP home page Giter VIP logo

functional-programming-jargons's Introduction

Functional Programming Jargons

The whole idea of this repos is to try and define jargons from combinatorics and category theory jargons that are used in functional programming in a easier fashion.

Let's try and define these with examples, this is a WIP please feel free to send PR ;)

Arity

The number of arguments a function takes.

const sum = (a, b) => a + b;

const arity = sum.length;
console.log(arity);
// => 2
// The arity of sum is 2

Higher Order Functions (HOF)

A function for which both the input and the output are functions.

let greet = (name) => () => `Hello ${name}!`;
greet("HOF")(); // Hello HOF!

Partial Application

The process of getting a function with lesser arity compared to the original function by fixing the number of arguments is known as partial application.

let sum = (a, b) => a + b;

// partially applying `a` to `40`
let partial = sum.bind(null, 40);

// Invoking it with `b`
partial(2); //=> 42

Currying

The process of converting a function with multiple arity into the same function with less arity.

let sum = (a,b) => a+b;

let curriedSum = (a) => (b) => a + b;

curriedSum(40)(2) // 42.

Purity

A function is said to be pure if the return value is only determined by its input values, without any side effects.

let greet = "yo";

greet.toUpperCase(); // YO;

greet // yo;

Side effects

A function or expression is said to have a side effect if apart from returning a value, it modifies some state or has an observable interaction with external functions.

console.log("IO is a side effect!");

Idempotency

A function is said to be idempotent if it has no side-effects on multiple executions with the the same input parameters.

f(f(x)) = f(x)

Math.abs(Math.abs(10))


Point Free

A function whose definition does not include information regarding its arguments.

let abs = Math.abs


Contracts


Guarded Functions


Categories


Functor

Structure that can be mapped over.

Simplest functor in javascript is an Array

[2,3,4].map( n => n * 2 ); // [4,6,8]

Referential Transparency

An expression that can be replaced with its value without changing the behaviour of the program is said to be referential transparent.

Say we have function greet:

let greet = () => "Hello World!";

Any invocation of greet() can be replaced with Hello World! hence greet is referential transparent.


Equational Reasoning


Lazy evalution

aka call-by-need is an evaluation machanism which delays the evaluation of an expression until its value is needed.

let rand = function*() {
    while(1<2) {
        yield Math.random();
    }
}
let randIter = random();
randIter.next(); // Each exectuion gives a random value, expression is evluated on need.

Monoid


Monad


##Comonad

Applicative Functor


Morphism


Setoid


Semigroup


Chain


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.