~statianzo/sevenlangs

a2b6b78630d6f10d9a6e63aa07253aa25acbebde — Jason Staten 1 year, 10 months ago 3700af5
recursive word count
1 files changed, 9 insertions(+), 0 deletions(-)

A erlang/words.erl
A erlang/words.erl => erlang/words.erl +9 -0
@@ 0,0 1,9 @@
-module(words).
-export([count/1]).

count(S) -> count(S, true, 0).

count("", _, Total) -> Total;
count([$ |Tail], _, Total) -> count(Tail, true, Total);
count([_|Tail], false, Total) -> count(Tail, false, Total);
count([_|Tail], true, Total) -> count(Tail, false, Total + 1).
\ No newline at end of file