Passionate Backend developer , AI Engineer & Devops Enthusiast , always keen to learn and explore new things, pursued Software Engineering and Cyber Security.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
That's not always true, though.
In Elm, for example, pipe |> and composition >> have the same order of execution, the difference is that pipe is imediately executed while composition returns a new function: Note: Everything after -- is a comment in Elm
addxy=x+ysubyx=x-ytotalWithPipe=1|>add10|>sub5-- 6totalWithComposition=letcalculateTotal=add10>>sub5-- returns a functionincalculateTotal1-- 6
Not only in Elm, but pipe in fp-ts also works this way:
import{pipe}from'fp-ts/function'constlen=(s:string):number=>s.lengthconstdouble=(n:number):number=>n*2// without pipeassert.strictEqual(double(len('aaa')),6)// with pipeassert.strictEqual(pipe('aaa',len,double),6)
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
I picked the mathematical explanation for function composition:
In abstract algebra, a composite function is a function formed by the composition or successive application of more than one function. To do this, the function closest to the argument is applied to the argument, and the next function is applied to the result of the previous calculation.
You are right.
But the point of my comment is pipe.
This is the one that have different implementations.
I just highlighted that the affirmation βpipe is the same as composition but reversedβ is not always true
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
I just knew pipe and now I know it differs to compose by just order of function execution! Thanks
Anytime π
That's not always true, though.
In Elm, for example, pipe
|>and composition>>have the same order of execution, the difference is that pipe is imediately executed while composition returns a new function:Note: Everything after
--is a comment in ElmNot only in Elm, but pipe in fp-ts also works this way:
That's why the post has the tag #javascript π, either way love the insight! I haven't coded in Elm in ages, actually a good one, absolutely love the no runtime errors π€©
It's sad that it got relatively few support...
Yes, but even in Javascript this concept can be different as you can see in fp-tsβ pipe.
I love coding in Elm! It is my first option when creating a Frontend.
From what I see, it seems some companies are adopting it, so, it seems itβs growing
I picked the mathematical explanation for function composition:
in which case, this will fit in the description:
The implementation details or nuances in Elm (or any other) is a different matter of discussion π
BTW glad to hear Elm it's getting a bit more love!
You are right.
But the point of my comment is
pipe.This is the one that have different implementations.
I just highlighted that the affirmation βpipe is the same as composition but reversedβ is not always true
oh! understood now π my bad