[erlang-questions] List Split into [H|T] is not working
Harit Himanshu
harit.subscriptions@REDACTED
Sun Feb 22 00:24:27 CET 2015
Just figured that
_ -> [lists:reverse(Input)] should be
_ -> lists:reverse(Input)
On Sat, Feb 21, 2015 at 3:21 PM, Harit Himanshu <
harit.subscriptions@REDACTED> wrote:
> Hey there,
>
> I am pretty sure I am messing up, but can't figure out really.
>
> Here is what I do
>
> -module(solution).
>
> -export([main/0]).
>
> main() ->
> Input = read_input([]),
> [S | X] = Input,
> io:format("S=~p, X=~p~n", [S, X]),
> repeat(S, X).
>
> read_input(Input) ->
> case io:fread("", "~d") of
> {ok, [N]} -> read_input([N | Input]);
> _ -> [lists:reverse(Input)]
> end.
>
>
> and when I run it, I get
>
> 5> c(solution).
>
> solution.erl:20: Warning: function string_to_integer_list/1 is unused
>
> {ok,solution}
>
> 6> solution:main().
>
> 2
>
> 3
>
> 4
>
> 5
>
> .
>
> S=[2,3,4,5], X=[]
>
> ok
>
> 7>
>
>
> What's wrong here?
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150221/6ba21ea9/attachment.htm>
More information about the erlang-questions
mailing list