All pastes #739409 Raw Edit

Something

public text v1 · immutable
·published 2007-10-17 03:47 UTC
rendered paste body
parse_array(Type, Binary) ->
    {ok, N, Rest} = parse(u30, Binary),
    case N of
        0 ->
            %% XXX: Lame.
            {ok, [], Rest};
        N when N > 0 ->
            parse_array_loop(Type, Rest, N - 1, [])
    end.

parse_array_loop(Type, Binary, 0, Acc) ->
    {ok, lists:reverse(Acc), Binary};
parse_array_loop(Type, Binary, N, Acc) when N > 0 ->
    {ok, Val, Rest} = parse(Type, Binary),
    parse_array_loop(Type, Rest, N - 1, [Val | Acc]).