void stutter(Node* L) { if(L == NULL) return NULL; else return new Node(L->item, new Node(L->item, stutter(L->next))); }The 'else' case is derived from the second equation as follows. Suppose that L = h:t. So h = head(L) and t = tail(L). The starting point is:
stutter(h : t) = h : (h : stutter(t))Since L = h : t, we can replace h : t by L on the left-hand side.
stutter(L) = h : (h : stutter(t))Remember that A : B is converted to new Node(A, B). So replace h : stutter(t) by new Node(h, stutter(t)). We get
stutter(L) = h : (new Node(h, stutter(t)))Now do a similar replacement of h : (new Node(h, stutter(t))) by new Node(h, new Node(h, stutter(t))).
stutter(L) = new Node(h, (new Node(h, stutter(t))))Remember that h = head(L), and head(L) is written L->item. Also, t = tail(L), and tail(L) is written L->next. So replace h by L->item and t by L->next.
stutter(L) = new Node(L->item, (new Node(L->item, stutter(L->next))))Finally, replace stutter(L) = by return.