def assoc(self, pos, el):
        """Returns a new vector that contains el at given position.
        Note, that position must be <= len(vector)
        """
        if pos < 0 or pos > self.length: raise IndexError()
        if pos == self.length: return self.cons(el)
        if pos < self._tailoff():
            up = self.__class__._do_assoc(self.shift, self.root, pos, el)
            return self.__class__(self.length, self.shift, up, self.tail)

        up = self.tail[:]
        up[pos & 0x01f] = el;
        return self.__class__(self.length, self.shift, self.root, up)
dataset/ETHPy150Open kachayev/fn.py/fn/immutable/trie.py/Vector.assoc/original