title: Generating a list which is made by right shifting elements n times
body: <p>I am trying a problem recently. And in this case I am having few problems.</p>
  
  <pre><code>Input: generatingListforRightShifting 2 [1,2,3,4,5,6,7,8]
  Output: [[1,2,3,4,5,6,7,8],[8,1,2,3,4,5,6,7],[7,8,1,2,3,4,5,6]]
  </code></pre>
  
  <p>As you understand this program will shift an element in right direction. The 1st argument indicates how many times it will do shifting.
  As a newbie I am trying solving it few well known list functions. and using recursion. But to me recursion idea is not clear. My code is:</p>
  
  <pre><code>generatingListforRightShifting' _ []=[]
  generatingListforRightShifting' 0 x=x
  generatingListforRightShifting' n xs=   newList where
                          newList=takeWhile(\i-&gt;[1..n] 
                                              &lt;=n)(reverse(take 
                                             i(reverse xs))++reverse(drop i(reverse xs)))
  </code></pre>
  
  <p>I understand that the main mistake I'm doing is in the part takeWhile. But how can I iterate through n times. I have already made a program which directly shows the shifted result such as 
      Input:generatingListforRightShifting 2 [1,2,3,4,5,6,7,8]
      Output: [7,8,1,2,3,4,5,6]
  But when I try to get all previous shifting I cannot.</p>
  
  <p>Can anyone help me out here. I also welcome you if you give me the solving idea.</p>