OverN copies N items N items back to the top of the stack. Stack transformation: OverN(1): [... x1 x2 x3] -> [... x1 x2 x3 x2] OverN(2): [... x1 x2 x3 x4] -> [... x1 x2 x3 x4 x1 x2]
(n int32)
| 295 | // OverN(1): [... x1 x2 x3] -> [... x1 x2 x3 x2] |
| 296 | // OverN(2): [... x1 x2 x3 x4] -> [... x1 x2 x3 x4 x1 x2] |
| 297 | func (s *stack) OverN(n int32) error { |
| 298 | if n < 1 { |
| 299 | str := fmt.Sprintf("attempt to perform over on %d stack items", |
| 300 | n) |
| 301 | return scriptError(ErrInvalidStackOperation, str) |
| 302 | } |
| 303 | |
| 304 | // Copy 2n-1th entry to top of the stack. |
| 305 | entry := 2*n - 1 |
| 306 | for ; n > 0; n-- { |
| 307 | so, err := s.PeekByteArray(entry) |
| 308 | if err != nil { |
| 309 | return err |
| 310 | } |
| 311 | s.PushByteArray(so) |
| 312 | } |
| 313 | |
| 314 | return nil |
| 315 | } |
| 316 | |
| 317 | // PickN copies the item N items back in the stack to the top. |
| 318 | // |