Implementations and practical examples

Photo by JJ Ying on Unsplash

Introduction

const fn = (p1, p2, ..., pN) => f(p1, p2, ..., pN);
const curried = p1 => (p2, ..., pN) => fn(p1, p2, ..., pN);
const curried = p1 => p2 => ... => pN => fn(p1, p2, ..., pN);


How to optimize a function by avoiding computing the same things several times

Photo by Shiro hatori on Unsplash

A simple example


Comment optimiser les performances d’une fonction en évitant de calculer plusieurs fois la même chose

Photo by Shiro hatori on Unsplash

Implémentations et exemples pratiques

Photo by JJ Ying on Unsplash

Introduction

const fn = (p1, p2, ..., pN) => f(p1, p2, ..., pN);
const curried = p1 => (p2, ..., pN) => fn(p1, p2, ..., pN);
const curried = p1 => p2 => ... =>…


Et une façon astucieuse de le faire de façon concise

Photo by Anastasia Dulgier on Unsplash

Problème

const myFunction = fromMethod(MyClass.prototype.myMethod);
myFunction(obj, ...args);
  • en lui passant en premier argument l’objet obj sur lequel nous souhaitons appliquer la fonction.
  • en lui passant ensuite une liste d’arguments correspondant à la signature de la méthode originale.

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