generalize edit_dist to any sequences