Today’s post is short and sweet, like a peach.
On the odd chance you’re morbidly curious how to fold an array with a function in c++ like myself, you’re in for a pleasant surprise (unless you’re intimately familiar with boost’s lambdas, in which case you will be appalled at how little thought was put into this whimsical hack).
This morning I cleaned up my proj (fork it) utility library and added an Array structure with a foldRight member, and refactored curry to take in either a va_arg parameter list or a mArray of functions.
I make no claims about its stability or memory non-leakiness of the data structure although a hundred million delete and allocation calls had a stable memory footprint.
It all starts with Fptr.h:
the new hotness of mArray.h (I pronounce it emory as in memory)
the test program for folding, sort.cpp (
naming fail now it sorts too):
the test program for curry:
Here’s the scripts I included below: