<br>-module(list2).<br>-export([flat_length/1]).<br><br>%% flat_length(List)<br>%% Calculate the length of a list of lists.<br><br>flat_length(List) -><br> flat_length(List, 0).<br><br>flat_length([H,T], N) when list(H) ->
<br> flat_length(T, flat_length(H, N));<br>flat_length([H|T], N) -><br> flat_length(T, N + 1);<br>flat_length([], N) -><br> N.<br><br>$ erl <br>Eshell V5.5 (abort with ^G)<br>1> c(list2).<br>./list2.erl:12: Warning: variable 'H' is unused
<br>{ok,list2}<br>2> list2:flat_length([1,2,[3,4]]).<br>3<br><br>why is the result 3? should it be 4? <br><br>-- Quan<br>