[erlang-questions] newbie question

Charles Hixson <>
Thu Nov 6 19:56:27 CET 2014


Given the routine:
-module(chunks).
-export([chunks/1]).
chunks(str)->
     chunks(str, []).

chunks("", lst)->
     list:reverse(lst);
chunks(str, lst)->
     P1 = "^([[:alnum:]]+|[[:space:]]+|[[:punct:]]+|[[:cntrl:]]+|.)",
     [[], M1, T1] = re:split(str, P1, [{return, list}]),
     [M1 | chunks(T1, P1)].

and the shell:
47> c(chunks).
{ok,chunks}

Why do I get:
49> chunks:chunks("Able was I ere I saw Elba.").
** exception error: no function clause matching chunks:chunks("Able was 
I ere I saw Elba.") (chunks.erl, line 15)
(Well, forget the like 15.  I took out a bunch of comments.)


More information about the erlang-questions mailing list