Skip to content

jlapeyre/Rotate.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rotate

@rotate(x_1, x_2, ... x_n)

Rotate the values referred to by x_i.

Assign the value of x_1 to x_2, x_2 to x_3, ..., and x_n to x_1. Each argument is interpreted as the left hand side of an assignment.

@rotate is equivalent to (x_1, x_2, ..., x_n) = (x_n, x_1, ..., x_{n-1})

Compare to circshift.

Example

julia> using Rotate

julia> x = 1; y = 2; z = 3; a = [4, 5]; (x, y, z, a[1])
(1, 2, 3, 4)

julia> @rotate(x, y, z, a[1]); (x, y, z, a[1])
(4, 1, 2, 3)

@rotaten(n, x_1, x_2, ... x_n)

Like @rotate, but rotate by n, where n is an integer. Use n = -1 for circular shift left.

About

Cyclic assignment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages