assign element numbers functionally (immutably)