title: Rotations of a list in Haskell
body: <p>I want to obtain a list of some of the rotations of the following string "I want to break free tonight". The constraint is that a rotation can not begin with the words "to" or "tonight". So the list of rotations is <code>["I want to break free today", "want to break free tonight I", "break free tonight I want to", "free tonight I want to break"]</code>. </p>
  
  <p>I wrote the following functions:</p>
  
  <pre><code>rotate :: [l] -&gt; [l]
  rotate [] = []
  rotate (x:xs) = (x:xs) ++ head(x:xs)
  
  rotate1 :: [a] -&gt; [[a]]
  rotate1 xs = take (length xs) (iterate rotate xs)
  
  main = do
  print $ rotate1(words("I want to break free tonight"))
  </code></pre>
  
  <p>Running this code, I obtained all possible rotations, but they form a list of lists having elements like <code>["want", "I", "to", "break", "free", "tonight"]</code> which is different from the string <code>"want I to break free tonight"</code>. Also, I would want to see how I can drop the rotations that begin with the words <code>"to"</code>, <code>"tonight"</code>. I tried to use the filter function for the second part but I did not manage to solve the problem. Any help/hint is appreciated. I notice that I am a beginner in Haskell. </p>