3 ms·
`createspecialString` is seven lines long though.
by LudwigNagasena 2y ago
`createspecialString` is seven lines long though.
- ninetyninenine 2y agoThen split it. All pure functions are easily decomposed into the most primitive units so even the most dogmatic ass hole can't talk shit. createSpecialString = createFormattedString . createNewString createFormattedString = Capitalizefirstletter . MakealllowerCase . AddNumberSuffix . createNewString(y) = removeLetterA . removeLetterB . ConcatwithWord(x) Or put it all on one line. createspecialString(y) = Capitalizefirstletter . MakealllowerCase . AddNumberSuffix . removeLetterA . removeLetterB . ConcatwithWord(x) The amount of lines becomes off topic once you get into this style. It's a completely orthoganol concept as it's completely irrelevant to readability and modularity. Lines doesn't makes sense for pure non imperative functions. Lines ONLY make sense for imperative functions because each line represents an instruction.
- TeMPOraL 2y agoWell, the most interesting thing about purely functional composition would be the ability to un(de)compose them, inlining the bodies until the resulting function is large enough to be worth the effort of reading it.
- ninetyninenine 2y agoExactly you have the lowest level primitives. You can arbitrarily compose them however you want forming arbitrary layers of abstraction from a tree of compositions. In the first example there is one layer. In the second there is 2 layers of abstraction formed by composing the primitives into a tree.