How to increment tuple recursively in Haskell?
<p>I've been asked to create a function that calculates the number of negative, zero and positive numbers on a [Int]. The result should then be written on a tuple (nrOfNeg,nrOfZeros,nrOfPos). </p>

<p>nzp [0,-1,1,2,0,3] = (1,2,3)</p>

<p><strong>However, the list must be covered only once (meaning that tuple should update every element it is evaluated on [Int]).</strong></p>

<p>Something like:</p>

<pre><code>nzp [***0***,-1,1,2,0,3] = (0,1,0)
nzp [0,***-1***,1,2,0,3] = (1,1,0)
nzp [0,-1,***1***,2,0,3] = (1,1,1)
...
</code></pre>

<p>This is what I made so far, but it "uses" 3 times the list to calculate.</p>

<pre><code>nzp :: [Int] -&gt; (Int,Int,Int)
nzp l = (neg,zeros,pos)
        where neg = length (filter (&lt;0) l)
              zeros = length (filter (==0) l)
              pos = length (filter (&gt;0) l)
</code></pre>

<p>Is there any way to increment the tuple specific position while evaluating elements of [Int]?</p>