code: func (s *stack) nipN(idx int32) ([]byte, error) {
  	sz := int32(len(s.stk))
  	if idx < 0 || idx > sz-1 {
  		str := fmt.Sprintf("index %d is invalid for stack size %d", idx,
  			sz)
  		return nil, scriptError(ErrInvalidStackOperation, str)
  	}
  
  	so := s.stk[sz-idx-1]
  	if idx == 0 {
  		s.stk = s.stk[:sz-1]
  	} else if idx == sz-1 {
  		s1 := make([][]byte, sz-1)
  		copy(s1, s.stk[1:])
  		s.stk = s1
  	} else {
  		s1 := s.stk[sz-idx : sz]
  		s.stk = s.stk[:sz-idx-1]
  		s.stk = append(s.stk, s1...)
  	}
  	return so, nil
  }
docs: // nipN is an internal function that removes the nth item on the stack and
  // returns it.
  //
  // Stack transformation:
  // nipN(0): [... x1 x2 x3] -> [... x1 x2]
  // nipN(1): [... x1 x2 x3] -> [... x1 x3]
  // nipN(2): [... x1 x2 x3] -> [... x2 x3]