2008 August 26
I was interviewing a UI guy at work today and had to come up with some javascript questions. One geek-out led to another, and I started thinking about how under-utilized functional programming is in AS3 today.
To that end, I've created a FunctionUtils class with a few nifty methods.
1)closurizeEventHander - makes it very easy to create event handlers which appear to take extra parameters.
2)thunkify - allows easy creation of a thunk, which is a function which lets you delay processing until a later point.
3)memoize - creates a wrapper function around any function which caches return values for inputs that have already been seen.
4)memoizeByString - same as memoize, but it uses toString as a value key rather than actual object identity.
Enjoy.
Edit: With feedback from Rob Sampson of calypso88.com, I've fixed a bug or two and improved the ease of use yet again. Same link works.
Related tags: lambda
