Erlang `now-next` list iteration
===


I am trying to write something similar to the following:

haskell: 

    Prelude> let xs = [1..10]
    Prelude> zip xs (tail xs)
    [(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(8,9),(9,10)]


erlang:

    1> XS = [1,2,3,4,5,6,7,8,9,10].
    [1,2,3,4,5,6,7,8,9,10]
    2> lists:zip(XS, tl(XS)).
    ** exception error: no function clause matching lists:zip("\n",[]) (lists.erl, line 321)
         in function  lists:zip/2 (lists.erl, line 321)
         in call from lists:zip/2 (lists.erl, line 321)
    
    
    now_nxt([X|Tail],XS) -> 
        [Y|_] = Tail,
        now_nxt(Tail, [{X,Y}|XS]);
    now_nxt(_,XS) -> XS.
    
    156>coeffs:now_nxt(XS, []).
    ** exception error: no match of right hand side value []

