title: Removing whitespace from a string and putting each word separated in a list, haskell
body: <p>With thanks to <a href="https://stackoverflow.com/questions/3098877/remove-white-space-from-string">Remove white space from string</a>, I can successfully remove the whitespace in a string, but in my case, I also need to separate the words and put them all in a list like the following example. </p>
  
  <p>Input</p>
  
  <blockquote>
    <p>" A  \t String with many\nspaces."</p>
  </blockquote>
  
  <p>would output</p>
  
  <blockquote>
    <p>["A","String","with","many","spaces."]</p>
  </blockquote>
  
  <p>I am able to output this </p>
  
  <blockquote>
    <p><code>["","A","","","","String","with","many"]</code></p>
  </blockquote>
  
  <p>with the following code</p>
  
  <pre><code>&gt; splitWords :: String -&gt; [String]
  &gt; splitWords [] =[]
  &gt; splitWords as =splitWord "" as
  
  
  &gt; splitWord _ []  = []
  &gt; splitWord word ('\n':as)   = word : splitWord "" as
  &gt; splitWord word ('\t':as)  = word : splitWord "" as
  &gt; splitWord word (' ':as)  = word : splitWord "" as
  &gt; splitWord word (a:as) = splitWord (word ++ [a]) as
  </code></pre>
  
  <p>Since I'm trying to learn haskell, solutions without using other libraries would be ideal!</p>