I’ve never done a lot of functional programming. Sure, I did a bit of required Scheme in my Programming Languages class in college. Didn’t do anything real though — well, maybe a bit of decent AI stuff, but no actual apps. The point is, I’ve never really worked extensively with functional programming largely because the languages/tools I’ve been working with haven’t been purely functional.
Well, apparently I’ve just been missing it in AS3. It was staring me plainly in the face but hadn’t really thought about it in those terms. Bruce Eckel did, though. He shows how we can use the various Array methods (and add some of our own since Array is dynamic) to work functionally. There’s some very clever stuff in there, particularly the in-line functions that leverage closures to return results to the calling method… very clever use of AS3.
There is quite a bit of noise in the article related to his working with Flex Builder and writing the MXML to display the results of his tests. He also has a very — ahem — interesting code style that I wouldn’t suggest anyone follow if you plan on sharing with other AS3 coders. I’m referring to his mixing of MXML and AS3 (and I’m not talking mx:Script blocks, either). First time I’ve ever seen that…