title: Counting occurrences of words using functional programming
body: <h1>Task</h1>
  <p>Given a <em>list of strings</em> that may or may not have one or more words in them, how can I use fuctional programming to create a word-frequency dictionary? By functional programming, I'm explicitly referring to the use of <code>map</code>, <code>filter</code>, or <code>reduce</code>. Additionally, table-comprehensions also fall in the line of functional programming.</p>
  <hr />
  <h2>Code</h2>
  <pre><code>def count_individual_words(word_list):
      word_count = {x: y.count(x) for y in word_list for x in y.split()}
      return word_count
  
  tweets = [&quot;I am a cat&quot;, &quot;cat&quot;, &quot;Who is a good cat&quot;]
  
  for i,v in count_individual_words(tweets).items():
      print(i,v)
  
  #Expected Output (dict)
  # =&gt; {
  # &quot;I&quot;: 1,
  # &quot;am&quot;: 1,
  # &quot;a&quot;: 2,
  # &quot;cat&quot;: 3,
  # &quot;Who&quot;: 1,
  # &quot;is&quot;: 1,
  # &quot;good&quot;: 1 }
  </code></pre>
  <hr />
  <h1>Main Issue</h1>
  <p>The main issue presents itself when counting words that have more than one occurrence such as <em><strong>cat</strong></em> or <em><strong>a</strong></em>. The issue is that, rather than adding one to the current word count, instead it just overwrites the word count with one. Thus, at the end, the dictionary I get shows that all the words only occur once.</p>
  <p>I would highly appreciate any reference to using <code>map</code>, <code>filter</code>, or <code>reduce</code>, as I am curious how one could use any of those given functions to accomplish this task.</p>