2SWAP

Swaps the order of the top two pairs.

Input stack: a b c d

Output stack: c d a b

PumpkinDB> 0x00 0x00 0x10 0x20 2SWAP
0x20 0x10 0x00 0x00

Allocation

None

Errors

EmptyStack error if there are less than four items on the stack

Tests

works : 1 2 3 4 2SWAP STACK [3 4 1 2] EQUAL?.
empty_stack : [2SWAP] TRY UNWRAP 0x04 EQUAL?.
empty_stack_1 : [1 2SWAP] TRY UNWRAP 0x04 EQUAL?.
empty_stack_2 : [2 1 2SWAP] TRY UNWRAP 0x04 EQUAL?.
empty_stack_3 : [3 1 2SWAP] TRY UNWRAP 0x04 EQUAL?.

results matching ""

    No results matching ""