Command: roll

Synopsis

objn ... obj1 n k roll

roll performs a circular shift of the first n stack levels

by k positions. Before this is done roll removes its arguments

from the stack.

If k is positive each shift consists of moving the contents of level

0 to level n-1 thereby moving elements at levels 1 through n-1 up one

stack level.

If k is negative each shift consists of moving the contents of level

n-1 to level 0 thereby moving elements at levels 1 through n-1 down

one stack level.

Description

roll performs a circular shift of the first n stack levels

by k positions. Before this is done roll removes its arguments

from the stack.

If k is positive each shift consists of moving the contents of level

0 to level n-1 thereby moving elements at levels 1 through n-1 up one

stack level.

If k is negative each shift consists of moving the contents of level

n-1 to level 0 thereby moving elements at levels 1 through n-1 down

one stack level.

File

sli/slistack.cc

Diagnostics

Raises StackUnderflow error if there are less than n+2 objects

on the stack.

(a) (b) (c) 3 1 roll -> (c) (a) (b)

(a) (b) (c) 3 -1 roll -> (b) (c) (a)

(a) (b) (c) 3 0 roll -> (a) (b) (c)

on the stack.

Examples

(a) (b) (c) 3 1 roll -> (c) (a) (b)

(a) (b) (c) 3 -1 roll -> (b) (c) (a)

(a) (b) (c) 3 0 roll -> (a) (b) (c)