This code works like this. If there is anrray of [1,2,3,4,5] for example it will break it up into [1,2] [3] and [4,5] These are basically head body and tail respectively. The code then goes and rearranges it in form of tail, body, head. I have a Java Version. This is a similar algorithm to shuffling a deck of cards.
alaye13 / deck-pivoted-array-in-prolog Goto Github PK
View Code? Open in Web Editor NEWThis would flip an array from the middle almost like a pivot without reversing it. So an array of (1,2,3,4,5) would be split and appended as [5,4] , [3], [2,1] and written as [5,4,3,2,1]