Thanks Neil for your interesting article.
Sounds as if you may be interested in Ian Hofmann-Hicks youtube channel (search evilsoft on youtube) and his Crocks A.D.T library github.com/evilsoft/crocks
But, of course, you may have encountered his offerings before.
Thanks! I had never heard of him but his content is exactly the kind of stuff I'm interested in. Reminds me of the Fantasy land spec I recently found
I will look forward to further articles from you soon, I hope.
What's the benefit of doing this instead of just using the built in Array.prototype.reduce?
There is not benefit other than exploring it for fun!
I don't understand the pipe one, can you explain it better, or at least say examples of usage?
The pipe takes in an array of functions and "connects" them so that the output of a function within that array is passed as an input to the function after it.
const squareThenIncrement = pipe([x => x * x, x => x + 1])
squareThenIncrement(4); // 17
squareThenIncrement(9); // 82
There are a few medium articles out there explaining it in more detail. I didn't want to make this post too detailed. I just wanted to show how much we could do using just that fold function
Dude. Please stop reinventing the wheel and do start reading the proper documentations.
Your "fold" is not a thing.
You are basically renaming and trying to hijack the credits from Array.prototype.reduce
And in case you didn't know it, the Array object also exposes methods like some(), every() that you called all(), join() etc.
You seem very well-versed in JS array methods. You're right, these functions are already available in the standard API. But why does that have to stop anyone from experimenting for the sake of learning? Relax
You are right, this is a very nice exercise to train.
Array folding should never be this complicated, this was all just me experimenting with the idea. This post (along with most of my other posts) is just a way for me to solidify concepts that I recently learned while also having a way to improve my writing. So I might end up straying in my posts sometimes but that's kinda what makes it fun for me.
Great post and it was very interesting to see the depth you added in the code. Too often people just grab a higher order or a library to do the work without giving it a go to check fundamentals or a new approach. We would never innovate without this curiosity and I applaud your hard work on this and an excellent formed post 👍
What are you talking about? Instead of rambling, come up with an improvement, cause it sounds like you're just full of shit.
Just a little harsh I think!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.