Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate non-Bit Arrays in Julia

Tags:

arrays

julia

Using rol(a,1) on a=BitArray([true,true,false]) yields the following result:

julia> rol(a,1)
3-element BitArray{1}:
true
false
true

How can I rotate non-Bit Arrays? For example I have b=[1,2,3,4] and would like to get the following output: [2,3,4,1].

like image 647
Alejandro Braun Avatar asked Jan 07 '17 02:01

Alejandro Braun


1 Answers

you're looking for circshift:

julia> circshift([1,2,3,4], -1)
4-element Array{Int64,1}:
 2
 3
 4
 1
like image 102
Gnimuc Avatar answered Sep 18 '22 12:09

Gnimuc