<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def parse(file_path):
    '''Parse a YAML or JSON file.'''

    _, ext = path.splitext(file_path)

    if ext in ('.yaml', '.yml'):
        func = yaml.load

    elif ext == '.json':
        func = json.load

    else:
        raise ValueError("Unrecognized config file type %s" % ext)

    with open(file_path, 'r') as f:
        return func(f)