^^Curry a multiargument function.

wp/Currying

Currying is related to, but not the same as, partial application. Leggere l'idea.

curry
translate   1 n-arguments-function
           in   a sequence of n 1-argument-functions
uncurry
curry viceversa.
Es: dato x∈X  x→fx:Y→Z, costruisco  (x,y)→fx(y)

In una visione puramente insiemistica, questa riespressione della corrispondenza non mi solleva problemi, ma se mi pongo in analisi sul campo reale, definisco  ga(y):=f(a,y)

dato f:ℝxℝ→ℝ  come trattare la continuita'?

 

Detto in breve: consideriamo una funzione f(x,y) di 2 variabili

bloccando la x ad un fissato valore a, definisce una funzione f(a,y) della sola y

es: f(x,y)= x²+2xy,

fissando x=a=1 produce una fun g2   g1(y)= 1²+2y

fissando x=a=2 produce una fun g3   g2(y)= 2²+2*2y

fissando x=a=a produce una fun ga   ga(y)= a²+2ay

fissando x=a=x produce una fun gx   gx(y)= x²+2xy

Si stabilisce quindi la corrispondenza

x→gx  ad 1 numero corrisponde una funzione

Formalmente

dato f:XxY→Z,  ∀a∈X def:  ga:Y→Z  ga(y):=f(a,y)

e quindi si puo' definire  h:X→(Y→Z)  h(x):=gx

ridetto breve (una volta che si e' capito avendolo detto per esteso)

dato f:XxY→Z,   h:X→(Y→Z)  h(x):=gx  gx(y):=f(x,y)

h(x)(y)=f(x,y)

 

 

Dirlo

  1. translate the evaluation of 1 n-arguments-function into evaluating a sequence of n 1-argument- functions.
  2. 1 n-arguments-function   translated in   a sequence of n 1-argument-functions.

Example,

by currying is translated into

Currying is related to, but not the same as, partial application.

la pagina italiana wp/Applicazione_parziale (13-5-2020) sembra invece confondere i 2 concetti.

Currying is useful in both practical and theoretical settings.

The most general setting for the strict notion of currying and uncurrying

is in the closed monoidal categories,

which underpins a vast generalization of the Curry–Howard correspondence of proofs and programs to a correspondence with many other structures, including quantum mechanics, cobordisms and string theory.

Curry was introduced by Gottlob Frege,

developed by Moses Schönfinkel, and further developed by Haskell Curry.

 

Notation. Dirlo.

X→Y    all functions fron X to Y

the set of functions from the set X to the set Y.

the set of all functions from X to Y.

Rob: io usavo F(X→Y)

f:X→Y  one of them

  Set theory Function spaces
X→Y YX Hom(X,Y)
XxY→Z ZXxY Hom(XxY,Z)
X→(Y→Z) (ZY)X Hom(X,Hom(Y,Z))

Curry

f: XxY→Z   given a funcion f; XxY  prodotto cartesiano di X e Y

h: X→(Y→Z)  curry construct a new function h whose values are functions

h(x):Y→Z  h(x) is a function Y→Z

h(x)(y) = f(x,y)

Curry is the bijection

curry:  Hom(XxY,Z) → Hom(X,Hom(Y,Z))

while uncurrying is the inverse map.

 

Esempio javascript >>>

 

Approfond

 

Diario

ho intrapreso questo approfondimento in relazione a:

che per caso ho trattato a poca distanza di tempo, e che si legavano entrambe a questa tematica.

 

Dis .odg|pdf