Tuck copies the item at the top of the stack and inserts it before the 2nd to top item. Stack transformation: [... x1 x2] -> [... x2 x1 x2]
()
| 182 | // |
| 183 | // Stack transformation: [... x1 x2] -> [... x2 x1 x2] |
| 184 | func (s *stack) Tuck() error { |
| 185 | so2, err := s.PopByteArray() |
| 186 | if err != nil { |
| 187 | return err |
| 188 | } |
| 189 | so1, err := s.PopByteArray() |
| 190 | if err != nil { |
| 191 | return err |
| 192 | } |
| 193 | s.PushByteArray(so2) // stack [... x2] |
| 194 | s.PushByteArray(so1) // stack [... x2 x1] |
| 195 | s.PushByteArray(so2) // stack [... x2 x1 x2] |
| 196 | |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | // DropN removes the top N items from the stack. |
| 201 | // |