[erlang-questions] Printed list to Erlang function

Felix Gallo <>
Tue Mar 29 20:35:58 CEST 2016


why do you want the list in a module, rather than loaded dynamically on
startup?  The list is data, which is probably best kept separate from the
code.

consider, e.g.:

https://gist.github.com/anonymous/7dd00fc5fba177f6dd2041edfe9ad09e

not a ton of code, and loads a list with a string per line.  And you can
change the list without recompiling and re-shipping the code.  A lot to
like about that.

F.



On Tue, Mar 29, 2016 at 10:52 AM, <> wrote:

> Hi zxq9,
>
> As noted by Sergej, the issue for me was how to transform the list on the
> printed page into an Erlang list that I could process further; e.g. how to
> get from the printed list to stopwords/0 with minimum steps along the way.
>
> My efforts were taking from copy into file, read back into binary, convert
> to list, use string:tokens/2 to transform newlines of commas, yada yada...
> until I had a list in the Erlang shell. But, then, how do I move that list
> into module? I could do it with another search and replace, but in all, it
> felt ugly.
>
> Thanks,
>
> LRP
>
>
>
> -----Original Message-----
> From: "zxq9" <>
> Sent: Tuesday, March 29, 2016 1:21pm
> To: 
> Subject: Re: [erlang-questions] Printed list to Erlang function
>
> Wow. Some serious copy-paste snafu my mail client was smart enough to
> render invisible to me, but dumb enough to pass on to the world.
>
> I intended to paste the following:
>
> On 2016年3月30日 水曜日 02:13:00 zxq9 wrote:
> ...
> > :~/Code/erlang$ cat member_example.erl
> > -module(member_example).
> > -export([go/0]).
> >
> > stopwords() ->
> >     ["word1", "word2", "word3"].
> >
> > is_stopword(Word) ->
> >     List = stopwords(),
> >     lists:member(Word, List).
> >
> > go() ->
> >     First = "word2",
> >     Second = "caboose",
> >     ok = io:format("~p is in stopwords: ~p~n", [First,
> is_stopword(First)]),
> >     ok = io:format("~p is in stopwords: ~p~n", [Second,
> is_stopword(Second)]).
> > :~/Code/erlang$ erl
> > Erlang/OTP 18 [erts-7.2] [source] [64-bit] [smp:2:2] [async-threads:10]
> [kernel-poll:false]
> >
> > Eshell V7.2  (abort with ^G)
> > 1> c(member_example).
> > {ok,member_example}
> > 2> member_example:go().
> > "word2" is in stopwords: true
> > "caboose" is in stopwords: false
> > ok
>
> Ugh.
>
> -Craig
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160329/4f552173/attachment.html>


More information about the erlang-questions mailing list