Recursive function to count adjacent duplicates
<p>I want the recursive function to check the value in the current node equals the value in the next node and increment by 1 else don't increment and move on until the end of the list. So for, a list of 1, 2, 2, 3 , 1, 1. It should return 2 as 2, 2 is one adjacent duplicate and 1, 1 is another adjacent duplicate. </p>

<p>I can't figure out how to handle the false case when the value of the current isn't equal to the value of the next. Basically, not incrementing.</p>

<p>This is my code so far...</p>

<pre><code>int fn(Node l) {
    if (l == null)
        return 0;
    else 
        return (l.value == l.next.value) ? (1 + fn(l.next)) : ;
}
</code></pre>
