-module(erllambda_fibonachi_handler).

%% API
-export([handle/2]).

%%%===================================================================
%%% API
%%%===================================================================

handle(#{<<"sequence">> := Sequence}, _Context) ->
    {ok, #{<<"sequence">> => sequence(Sequence)}}.


%%%===================================================================
%%% Private functions
%%%===================================================================

sequence([])         -> [0];
sequence([0])        -> [0, 1];
sequence([X, Y])     -> [X, Y, X + Y];
sequence([X | Tail]) -> [X | sequence(Tail)].

 API
===================================================================
 API
===================================================================
===================================================================
 Private functions
===================================================================
-module(erllambda_fibonachi_handler).

-export([handle/2]).


handle(#{<<"sequence">> := Sequence}, _Context) ->
    {ok, #{<<"sequence">> => sequence(Sequence)}}.



sequence([])         -> [0];
sequence([0])        -> [0, 1];
sequence([X, Y])     -> [X, Y, X + Y];
sequence([X | Tail]) -> [X | sequence(Tail)].
