[erlang-questions] Printed list to Erlang function

lloyd <>
Tue Mar 29 19:52:18 CEST 2016


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





More information about the erlang-questions mailing list