title: Map, reduce, filter apply to for loops and while loops
body: <p>I'm new to Julia and learning use of Map, reduce, filter.
  It is becoming very hard for me to comprehend how it can replace for and while loops.
  For ex for below code, I would like to replace for loop</p>
  
  <pre><code>function addMultiplesOf3And5(N::Int)
    sumOfMultiples = 0
    if(N == 3)
      return sumOfMultiples + N
    end
    for i = 3:N-1
      if(i % 3 == 0 &amp;&amp; i % 5 == 0)
        continue
      elseif(i % 3 == 0)
        sumOfMultiples += i
      elseif(i % 5 == 0)
        sumOfMultiples += i
      end
    end
  
    return sumOfMultiples
  end
  </code></pre>
  
  <p>I would really appreciate the help.</p>
  
  <p>Update :
  This is what I did after going through tutorials</p>
  
  <pre><code>function addMultiplesOf3And5(N::Int)
    array = range(1,N-1)
    return reduce(+, map(x -&gt; multiples_of_3_Or_5(x), array))
  end
  
  function multiples_of_3_Or_5(n)
    if(n % 3 == 0 &amp;&amp; n % 5 == 0)
      return 0
    elseif(n % 3 == 0)
      return n
    elseif(n % 5 == 0)
      return n
    else
      return 0
    end
  end
  </code></pre>
  
  <p>Final:</p>
  
  <pre><code>function addMultiplesOf3And5(N::Int)
    array = range(1,N-1)
    return reduce(+, filter(x -&gt; ((x%3==0)$(x%5==0)), array))
  end
  </code></pre>