code: func (ref Ref) Insert(x *Term, pos int) Ref {
  	if pos == len(ref) {
  		return ref.Append(x)
  	} else if pos > len(ref)+1 {
  		panic("illegal index")
  	}
  	cpy := make(Ref, len(ref)+1)
  	for i := 0; i < pos; i++ {
  		cpy[i] = ref[i]
  	}
  	cpy[pos] = x
  	for i := pos; i < len(ref); i++ {
  		cpy[i+1] = ref[i]
  	}
  	return cpy
  }
docs: // Insert returns a copy of the ref with x inserted at pos. If pos < len(ref),
  // existing elements are shifted to the right. If pos > len(ref)+1 this
  // function panics.