Here are a couple of examples where I brought tiny functional programming bits into existing code bases. One is an internal API and another is a tiny snapshot testing utility. Maybe for server code At Cypress.io we have an API. This is your typical API with a controller object routing requests to data model layer. […]

# Kliesli composition

Please read Kliesli Compositions in JavaScript by Luis Atencio first. This blog post is just a refactoring of the code for clarity. While Luis does an admirable job showing the composition (a compliment), the final code is not as clear as it could be. We can even say that the code by putting type unwrapping […]

# I can see clearly now

Consider object property access. We mostly think of this as a built-in JavaScript syntax. Reading a value at a given property “foo” happens as soon as we write 1 O.foo // value of property “foo” in object “O” Similarly, as soon as we write the assignment operator we set the value of property “foo” 12 […]

# How To Draw An Owl

Intro I like simple code. I consider functional code simpler than OO code. Yet, I am not an advanced practitioner of functional programming; and I easily get lost when people throw words like “comonads” around. After writing [a lot of blog posts][../tags/functional/] about functional way of writing JavaScript, I only scratch a surface of actually […]

# Fréchet derivative

http://en.wikipedia.org/wiki/Fr%C3%A9chet_derivative the Fréchet derivative is a derivative defined on Banach spaces. Named after Maurice Fréchet, it is commonly used to formalize the concept of the functional derivative used widely in the calculus of variations. Intuitively, it generalizes the idea of linear approximation from functions of one variable to functions on Banach spaces. The Fréchet derivative should be contrasted to the more general Gâteaux derivative which is a generalization of the […]

# Best approximation theorem

Theorem Let X be an inner product space with induced norm, and a non-empty, complete convex subset. Then, for all , there exists a unique best approximation a0 to x in A. Proof Suppose x = 0 (if not the case, consider A − {x} instead) and let . There exists a sequence (an) in Asuch that . We now prove that (an) is a Cauchy sequence. By the parallelogram rule, we get . Since A is convex, so . Hence as which implies as . In other words, (an) is a Cauchy sequence. Since A is complete, […]

# Best approximation theorem

Best approximation theorem Theorem Let X be an inner product space with induced norm, and a non-empty, complete convex subset. Then, for all , there exists a unique best approximation a0 to x in A. Proof Suppose x = 0 (if not the case, consider A − {x} instead) and let . There exists a sequence (an) in Asuch that . We now prove that (an) is a Cauchy sequence. By the parallelogram rule, we get . Since A is convex, so . Hence as which implies as . In other words, (an) is […]

# Fréchet derivative

http://en.wikipedia.org/wiki/Fr%C3%A9chet_derivative the Fréchet derivative is a derivative defined on Banach spaces. Named after Maurice Fréchet, it is commonly used to formalize the concept of the functional derivative used widely in the calculus of variations. Intuitively, it generalizes the idea of linear approximation from functions of one variable to functions on Banach spaces. The Fréchet derivative should be contrasted to the more general Gâteaux derivative which is a generalization of the […]

# Deriving Y Combinator

This is how one can start with factorial function and avoid using assignment operator by deriving and using Y Combinator function. This is based on the excellent and mind bending presentation by Jim Weirich at ScotlandJS. I highly recommend watching the video. This blog post only summarizes the code snippets I was writing as I […]

# Ramda for reactive streams

Take a small Observable example from xstream – it outputs two numbers and completes when a second stream finishes after 5 seconds. It uses Observables and shows filtering and mapping values through the stream: 12345678910111213141516171819 import xs from ‘xstream’// Tick every second incremental numbers,// only pass even numbers, then map them to their square,// and […]