added a truncate function

I think you want to update these to use ```max-1``` instead of ```max```. I think it will be confusing to use zero-indexing for this function.