So a whileago, wetalkedabouttheLundacalculus, whichis a simplebutpowerfulmathematicaltheoryoffunctions.
Butsomethingwedidn't talkaboutatthetimewastheideaofcurriedfunctions, whichsound a bitspicybutareactuallyveryuseful.
Sothat's whatwe'regonnatalkabouttoday.
Curriedfunctionsasweoftendo.
We'regonnastartoffwith a question, andthequestioniswhatactuallyis a function.
Soforme, a functionsimplytakesaninputononeside, processesinsideandthengivesanoutputontherighthandsidesoyoucanthinkofitasbeing a littleboxorlittlemachinetakesaninputononeside, processesinsidetheboxandthenproducessomeoutputontheotherside.
Andallthenumbersfrom 1 to 10 onMumiscalled a higherorderfunctionbecauseittakes a functionasoneofitsinfamous.
Solet's haveanotherexampleoffsomething a bitmoreinteresting.
Let's thinkabouttheideaoff a functionwhichhasmorethanoneinputormorethanoneparametersowecouldfind a littlefunctioncalledAdon.
We'regonnataketwonumbers x and y asinputs, andthenwe'regoingtosimplyaddthemtogetherontheimportantpointhereisthatwetakethetwonumbers X and Y packageduptogetheras a pairatthesametime.
Soitsays, I don't knowhowtoshow a functionfromintegersintegersorifyouwant a moreslightlycomprehensiblemessages, sayingmaybeyouhaven't applied a functiontoenougharguments.
Okay, sowiththecurrentfunction, whichtakesitsinputoneatthetime, youcanpartiallyapplyitto a subsetoftheinputs.
Sowhatcouldyouactuallydowith a functionlikeaddone?
Well, wedidmoppet, forexample.
Sohereis a wayoffIncrementalthing.
A listofnumberswithoutdefining a customincrementfunction.
Sowhatthisissayingis, ifyouadd a number X, thenwhatyougetis a functionwhichiswaitingfor a secondinput.
Why?
Andthenit's goingtogiveyouback X plus y onthisexpressionontherighthandsidehereiscalled a landerexpression.
It's a namelessfunction, andit's gotthesamekindofanatomyas a normalfunctiondefinition, exceptforthefactthatyoudon't givethefunctioninname.
Sowelookatwhat's goingonhere.
We'retakinganinputparametercalledWhyWe'regivingbacktheresult X plus y.
Butnowhereintheblueboxherehaveweactuallygiventhefunction a name.
It's a namelessfunction, andthenwecanactuallyplaythesamegamewiththeotherinputaswell.
Soratherthanhaving X onthelefthandside, wecanmoveitacrosstotherighthandsideonherewehaveourdefinitionorouradfunctionin a moreprimitiveway, andthisreallyletshisunderstand, in a quitefundamentalway, what's goingonwithcurriedfunctions.