def build(argmap, data):
    """Builds an array of arguments from the provided map and data.

    The argmap must consist of a mapping of keys to argbuilder functions.

    keys in the argmap are indexed into data, and if they are present, the
    corresponding values are passed to the corresponding argmap function. The
    argmap function returns with one or more array elements to be added to
    the returned array.
    """

    args = []
    for name, fn in argmap.iteritems():
        if name in data:
            args += fn(data[name])
    return args