Getting lists from ASCII input
Mats Cronqvist
mats.cronqvist@REDACTED
Tue May 16 10:13:52 CEST 2006
Deryk Barker wrote:
> I'm still a (raw) beginner but...
>
> I'm trying to write a program (a client - my students will write the
> server) which needs to allow the user to enter a list in repsonse to a
> prompt.
>
seems like a problem where using the scanner directly would be appropriate.
1> erl_scan:string("hello [a,b,c]").
{ok,[{atom,1,hello},
{'[',1},
{atom,1,a},
{',',1},
{atom,1,b},
{',',1},
{atom,1,c},
{']',1}],
1}
perhaps parse the arg;
1> {ok,[{atom,_,Cmd}|R],_} = erl_scan:string("hello,[a,b,c]"),
2> {ok,Arg}=erl_parse:parse_term(R++[{dot,1}]),
3> {Cmd,Arg}.
{hello,[a,b,c]}
mats
More information about the erlang-questions
mailing list