Created simple functional pattern matching construct.

Please consider this contribution.
Should we be trying to make functions total and return Option<B> here?