Giter VIP home page Giter VIP logo

Comments (13)

jethrolarson avatar jethrolarson commented on May 21, 2024 3

from functional-programming-jargon.

jethrolarson avatar jethrolarson commented on May 21, 2024 1

Here's a whack at it:

Functional Combinator

A higher-order function, usually curried, which returns a new function changed in some way. Functional combinators are often used in point-free programming to write especially terse programs.

from functional-programming-jargon.

jethrolarson avatar jethrolarson commented on May 21, 2024

You know what you'd like it to say?

from functional-programming-jargon.

hemanth avatar hemanth commented on May 21, 2024

Are you referring to Fixed-point combinator?

from functional-programming-jargon.

hemanth avatar hemanth commented on May 21, 2024

from functional-programming-jargon.

stereobooster avatar stereobooster commented on May 21, 2024

Most known fixed-point combinator is Y combinator, but it will not work in JS, because of order of evaluation. So there is Z combinator to the rescue

// The Y combinator is defined as:
// Y          = λf.(λx.f (x x))(λx.f (x x))
// The Z combinator is defined as:
// Z          = λf.(λx.f (λv.((x x) v))) (λx.f (λv.((x x) v)))

const Z       = f => (x => f (v => ((x (x)) (v)))) (x => f (v => ((x (x)) (v))))

// example of usage: factorial
const factgen = fact => n => n < 2 ? 1 : n * fact(n-1)
const fact    = Z(factgen)

Fixed-point combinator is a function to find fixed point of other function. Simple example of fixed point of function is dotty number e.g. solution of cos(x) = x.

But the most striking thing about fixed-point combinator if it is applied to higher order function e.g. function which returns function, fixed point of higher order function is function too. First time I realized it blowed my mind.

from functional-programming-jargon.

stereobooster avatar stereobooster commented on May 21, 2024

Other idea: we can expand Lambda Calculus section.

A lot of simple Lambda Calculus ideas pretty trivial to demonstrate in JS

//True   = λt.λf.t
//False  = λt.λf.f
//Not    = λb.b False True

const True   = t => f => t
const False  = t => f => f
const Not    = b => b (False) (True)

const toBool = (churchBoolean) => churchBoolean (true) (false)

//Zero   = λf.λx.x
//Succ   = λn.λf.λx.f (n f x)

const Zero   = f => z => z
const Succ   = n => f => z => f (n (f) (z))

const toNumber = (churchNumeral) => churchNumeral((x) => x+1) (0)

But I suppose it can be separate page dedicated to Lambda Calculus.

from functional-programming-jargon.

jethrolarson avatar jethrolarson commented on May 21, 2024

from functional-programming-jargon.

SeanSilke avatar SeanSilke commented on May 21, 2024

It would be nice to see definition of various combinations. The C combinator is rather practical and can be used in everyday coding.

from functional-programming-jargon.

jethrolarson avatar jethrolarson commented on May 21, 2024

from functional-programming-jargon.

SeanSilke avatar SeanSilke commented on May 21, 2024

@jethrolarson Don't sure that i get your question right. Yes C combinator is type of curing.
My knowledge of combinators is rather limited, actually i get it from this great talk of Reginald Braithwaite https://youtu.be/3t75HPU2c44

from functional-programming-jargon.

jethrolarson avatar jethrolarson commented on May 21, 2024

I think if we have functional combinators in the doc we should just have a general definition and not try to teach the details of every combinator. We can link out for that.

from functional-programming-jargon.

stereobooster avatar stereobooster commented on May 21, 2024

Also worth to elaborate a bit more, about why Y combinator does not work. It is because order of evaluation and add link to Lazy evaluation section

from functional-programming-jargon.

Related Issues (20)

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.