Skip to content

Instantly share code, notes, and snippets.

@teffcode
Last active February 23, 2021 05:11
Show Gist options
  • Save teffcode/6a5389e5458ae6ae2499fedd7ee5a7f4 to your computer and use it in GitHub Desktop.
Save teffcode/6a5389e5458ae6ae2499fedd7ee5a7f4 to your computer and use it in GitHub Desktop.

馃憢馃徏 Welcome 馃憢馃徏

Quiz banner

Instagram | Twitter | LinkedIn


Choose your language 馃憛



English version 馃殌


How should I run the following function to get the number 24 as a result of the multiplication: A, B or C?


Click here to see the correct answer and explanation 馃憖
Correct Answer Explanation
B Currying is a process in functional programming in which we can transform a function with multiple arguments (function mul(a, b, c) { return a * b * c }) into a sequence of nesting functions (like the example of this quiz). It returns a new function that expects the next argument inline. To get the result of multiplication of the three numbers 2, 3 and 4, the numbers are passed one after the other, each number prefilling the next function inline for invocation.

Explanation based on 馃憠馃徏 Understanding Currying in JavaScript


Code:

function mul(x) {
	return function(y) {
		return function(z) {
            		return x * y * z;
		};
	};
}


Spanish version 馃殌


驴C贸mo deber铆a ejecutar la siguiente funci贸n para obtener el n煤mero 24 como resultado de la multiplicaci贸n: A, B o C?


Haz click aqu铆 para ver la respuesta correcta y su explicaci贸n 馃憖
Respuesta correcta Explicaci贸n
B Currying es un proceso de programaci贸n funcional en el que podemos transformar una funci贸n con m煤ltiples argumentos (function mul(a, b, c) { return a * b * c }) en una secuencia de funciones anidadas (como el ejemplo de este qu铆z). Este proceso devuelve una nueva funci贸n que espera el siguiente argumento en l铆nea. Para obtener el resultado de la multiplicaci贸n de los tres n煤meros 2, 3 y 4, los n煤meros se pasan uno tras otro, cada n煤mero es pasado previamente a la siguiente funci贸n en l铆nea para su invocaci贸n.

Explicaci贸n basada en 馃憠馃徏 Understanding Currying in JavaScript


C贸digo:

function mul(x) {
	return function(y) {
		return function(z) {
            		return x * y * z;
		};
	};
}


@JMEnciso
Copy link

Wow

@JaviMiot
Copy link

Cada d铆a se aprendo algo nuevo

@Megajjks
Copy link

Muy bueno para aplicarlo en funciones con reactjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment