Skip to content

Instantly share code, notes, and snippets.

@jurStv
jurStv / composition_vs_chain.js
Last active April 17, 2017 05:46
From Functional Programming in Javascript book
/*
Here are five different implementations of the same floorSqrt()
functional composition.
They seem to be identical, but they deserve scrutiny.
But there are a few key differences we should go over:
Obviously the first method is verbose and inefficient.
The second method is a nice one-liner, but this approach becomes very unreadable
after only a few functions are applied.
The third approach is a chain of array functions, notably the map function. This works
fairly well, but it is not mathematically correct.