I am trying to split this list
List = [[<<"5">>, <<"54">>], [<<"00">>], [<<"35">>, <<"54">>, <<"45">>, <<"55">>], [<<"00">>],[ <<"5">>]]
into
List = [[<<"5">>, <<"54">>], [<<"35">>, <<"54">>, <<"45">>, <<"55">>], [<<"5">>]]
Basically based on the <<"00">>
What is the best BIF to go about this, I have some code, but its sloppy, and Im trying to learn.
Thanks
EDIT:
Tried the following, does not work
Done2 = lists:splitwith( [<<"00">>], Done1),
EDIT: This Line works!
7> lists:splitwith(fun(A) -> A == [<<"00">>] end, List).
{[],
[[<<"5">>,<<"54">>],
[<<"00">>],
[<<"35">>,<<"54">>,<<"45">>,<<"55">>],
[<<"00">>],
[<<"5">>]]}
However I need something a little more complicated: like when the delim is [<<"00">>,<<"23">>]
9> List = [[<<"5">>,<<"54">>], [<<"00">>,<<"23">>], [<<"35">>,<<"54">>], [<<"5">
>], [<<"00">>, <<"23">>]].
[[<<"5">>,<<"54">>],
[<<"00">>,<<"23">>],
[<<"35">>,<<"54">>],
[<<"5">>],
[<<"00">>,<<"23">>]]
10> lists:splitwith(fun(A) -> A == [<<"00">>] end, List).
{[],
[[<<"5">>,<<"54">>],
[<<"00">>,<<"23">>],
[<<"35">>,<<"54">>],
[<<"5">>],
[<<"00">>,<<"23">>]]}
11> lists:splitwith(fun(A) -> A == [<<"00">>,<<"23">>] end, List).
{[],
[[<<"5">>,<<"54">>],
[<<"00">>,<<"23">>],
[<<"35">>,<<"54">>],
[<<"5">>],
[<<"00">>,<<"23">>]]}
12>
No luck there