beefed up version of osteeles' library: http://osteele.com/sources/javascript/functional/