def depth_bonacci_rule(depth):
    """rule for generating tribonacci or other arbitrary depth words

    Args:
        depth (int): number of consecutive previous words to concatenate

    Returns:
        lambda w: w[-1] + w[-2] + ... + w[-(depth+1)]
        For example, if depth is 3, you get the tribonacci words.
        (there is already a tribonacci and quadbonacci words method) 
    """
    return lambda w: "".join(w[-1:-depth-1:-1])