-module(in17).

-export([f/1]).

-record(cpx,{real, imag}).

f(X) -> 
    {_ = #cpx{real = Real1, imag = Imag1}, #cpx{real = Real2, imag = Imag2}, 
    [H | _]} = {_Fst = #cpx{real = 1, imag = 1}, #cpx{real = 0, imag = 0}, 
        [A+1 || A<-X]},
    case H of
        1 -> Real1+Real2;
        _ -> Imag1+Imag2
    end.

add(_F = #cpx{real = Real1, imag =  Imag1}, 
     #cpx{real = Real2, imag =  Imag2}, [H|_Tail])->
    case H of
        1 ->
            Real1 + Real2;
        _ ->
            Imag1 + Imag2
    end.
