Implemented the hom functor
Direct translation of the code at https://jscategory.wordpress.com/source-code/