def group(merge_func, tokens):
    """
    Group together those of the tokens for which the merge function returns
    true. The merge function should accept two arguments/tokens and should
    return a boolean indicating whether the strings should be merged or not.

    Helper for tokenise(string, ..).
    """
    output = []

    if tokens:
        output.append(tokens[0])

        for token in tokens[1:]:
            prev_token = output[-1]

            if merge_func(prev_token, token):
                output[-1] += token
            else:
                output.append(token)

    return output