Original:

((function(f){return f(f);})(
(function(make_factorial){
return function(n){
return (n===0) ? 1 : n * make_factorial(make_factorial)(n-1);
};
})))(5);

After abstraction:

const op = (x,y) => x*y;    //similar to op in accumulate(op, init, xs)
function gen(n){
return t => op(n,t); //op constructor
}
(f=>f(f))(func =>
n => n === 0
? 1 //base case
: gen(n) //do something at this layer
(func(func)(n - 1))) //wishful thinking
//previous two lines are like op(n, accumulate(the_rest))
(5);

In the program above, gen(n) is used to generate an operator function using function op. …


Problem Description

In the 2015 CS1101S mid-term quiz, it asks whether the following functions exhaust time and/or space resources.

const C = (x => x(x))(x => x(x));
const D = (x => (x(x))(x))(x => x(x));
const E = (x => x(x(x)))(x => x(x));
const F = (x => x(x))(x => x(x(x)));

Background

I had no idea how this works until I read something on *Lambda Calculus*, so I’ll briefly introduce how it works:

Some basic Lambda Calculus

Consider the one of the simplist lambda expression: `λx. x+1`. It means in a blackbox function, it receives one parameter named `x` and outputs the result `x+1`. The `λ` sign…


Main branches

TL;DR: always merge to master, when master is stablized and deployed, merge to stable tagged with a release number.

Image for post
Image for post

The main branch should be considered origin/master and will be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. As a developer, you will be branching and merging from master.

Consider origin/stable to always represent the latest code deployed to production. During day to day development, the stable branch will not be interacted with.

When the source code in the master branch is stable and has been…

Tan Yuanhong

I study computer science. GitHub: https://github.com/le0tan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store