-module(seq).
-compile(nowarn_unused_vars).
-compile(nowarn_unused_function).
-export([s_r_enumeration_already_finished/0, s_r_enumeration_not_started/0, s_r_input_sequence_empty/0, s_r_input_sequence_too_long/0, s_r_key_not_found_alt/0, s_r_not_enough_elements/0, s_r_reset_not_supported/0, enumerator_no_reset/0, enumerator_not_started/0, enumerator_already_finished/0, enumerator_seq_ctor_673_a07_f2/1, enumerator_from_functions_1_ctor_58_c54629/3, enumerator_cast/1, enumerator_concat/1, enumerator_enumerate_then_finally/2, enumerator_generate_while_some/3, enumerator_unfold/2, index_not_found/0, mk_seq/1, of_seq/1, delay/1, concat/1, unfold/2, empty/0, singleton/1, of_array/1, to_array/1, of_list/1, to_list/1, generate/3, generate_indexed/3, append/2, cast/1, choose/2, compare_with/3, contains/3, enumerate_from_functions/3, enumerate_then_finally/2, enumerate_using/2, enumerate_while/2, filter/2, exists/2, exists2/3, exactly_one/1, try_exactly_one/1, try_find/2, find/2, try_find_back/2, find_back/2, try_find_index/2, find_index/2, try_find_index_back/2, find_index_back/2, fold/3, fold_back/3, fold2/4, fold_back2/4, for_all/2, for_all2/3, try_head/1, head/1, initialize/2, initialize_infinite/1, is_empty/1, try_item/2, item/2, iterate/2, iterate2/3, iterate_indexed/2, iterate_indexed2/3, try_last/1, last/1, length/1, map/2, map_indexed/2, indexed/1, map2/3, map_indexed2/3, map3/4, read_only/1, cached_seq_1_ctor_z7_a8347_d4/2, cached_seq_1_clear/1, cache/1, all_pairs/2, map_fold/3, map_fold_back/3, try_pick/2, pick/2, reduce/2, reduce_back/2, replicate/2, reverse/1, scan/3, scan_back/3, skip/2, skip_while/2, tail/1, take/2, take_while/2, truncate/2, zip/2, zip3/3, collect/2, where/2, pairwise/1, split_into/2, windowed/2, transpose/1, sort_with/2, sort/2, sort_by/3, sort_descending/2, sort_by_descending/3, sum/2, sum_by/3, max_by/3, max/2, min_by/3, min/2, average/2, average_by/3, permute/2, chunk_by_size/2, insert_at/3, insert_many_at/3, remove_at/2, remove_many_at/3, update_at/3, random_shuffle_by/2, random_shuffle_with/2, random_shuffle/1, random_choice_by/2, random_choice_with/2, random_choice/1, random_choices_by/3, random_choices_with/3, random_choices/2, random_sample_by/3, random_sample_with/3, random_sample/2]).

s_r_enumeration_already_finished() ->
    <<"Enumeration already finished."/utf8>>
.

s_r_enumeration_not_started() ->
    <<"Enumeration has not started. Call MoveNext."/utf8>>
.

s_r_input_sequence_empty() ->
    <<"The input sequence was empty."/utf8>>
.

s_r_input_sequence_too_long() ->
    <<"The input sequence contains more than one element."/utf8>>
.

s_r_key_not_found_alt() ->
    <<"An index satisfying the predicate was not found in the collection."/utf8>>
.

s_r_not_enough_elements() ->
    <<"The input sequence has an insufficient number of elements."/utf8>>
.

s_r_reset_not_supported() ->
    <<"Reset is not supported on this enumerator."/utf8>>
.

enumerator_no_reset() ->
    erlang:error(#{message => s_r_reset_not_supported()})
.

enumerator_not_started() ->
    erlang:error(#{message => s_r_enumeration_not_started()})
.

enumerator_already_finished() ->
    erlang:error(#{message => s_r_enumeration_already_finished()})
.

enumerator_seq_ctor_673_a07_f2(F) ->
    Ref = erlang:make_ref(),
    erlang:put(Ref, #{field_f => F}),
    erlang:put(Ref, maps:merge(erlang:get(Ref), #{to_string => fun() ->
        I_ref = fable_utils:new_ref(0),
        I_ref_result = begin Str_ref = fable_utils:new_ref(<<"seq ["/utf8>>),
        Str_ref_result = begin E = fable_utils:get_enumerator(Ref),
        try
            begin While_loop_0 = fun While_loop_0() ->
                case case erlang:get(I_ref) < 4 of
                    true ->
                        fable_utils:move_next(E)
                    ;
                    false ->
                        false
                end of
                    true ->
                        case erlang:get(I_ref) > 0 of
                            true ->
                                erlang:put(Str_ref, erlang:iolist_to_binary([erlang:get(Str_ref), <<"; "/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        begin erlang:put(Str_ref, erlang:iolist_to_binary([erlang:get(Str_ref), fable_convert:to_string(fable_utils:get_current(E))])),
                        erlang:put(I_ref, erlang:get(I_ref) + 1) end,
                        While_loop_0()
                    ;
                    false ->
                        ok
                end
end,
            While_loop_0() end,
            begin case fable_comparison:equals(erlang:get(I_ref), 4) of
                true ->
                    erlang:put(Str_ref, erlang:iolist_to_binary([erlang:get(Str_ref), <<"; ..."/utf8>>]))
                ;
                false ->
                    ok
            end,
            erlang:iolist_to_binary([erlang:get(Str_ref), <<"]"/utf8>>]) end
        catch
            _:Exn_reason_1 ->
                erlang:error(Exn_reason_1)
        after
            case erlang:is_map(E) orelse erlang:is_reference(E) of
                true ->
                    fable_utils:safe_dispose(E)
                ;
                false ->
                    ok
            end
        end end,
        erlang:erase(Str_ref),
        Str_ref_result end,
        erlang:erase(I_ref),
        I_ref_result
end, get_enumerator => fun() ->
        (maps:get(field_f, erlang:get(Ref)))(ok)
end, system_collections_i_enumerable_get_enumerator => fun() ->
        (maps:get(field_f, erlang:get(Ref)))(ok)
end})),
    Ref
.

enumerator_from_functions_1_ctor_58_c54629(Current, Next, Dispose) ->
    Ref = erlang:make_ref(),
    erlang:put(Ref, #{field_current => Current, field_next => Next, field_dispose => Dispose}),
    erlang:put(Ref, maps:merge(erlang:get(Ref), #{system_collections_generic_i_enumerator_1_get_current => {getter, fun() ->
        (maps:get(field_current, erlang:get(Ref)))(ok)
end}, system_collections_i_enumerator_get_current => {getter, fun() ->
        (maps:get(field_current, erlang:get(Ref)))(ok)
end}, system_collections_i_enumerator_move_next => fun() ->
        (maps:get(field_next, erlang:get(Ref)))(ok)
end, system_collections_i_enumerator_reset => fun() ->
        enumerator_no_reset()
end, dispose => fun() ->
        (maps:get(field_dispose, erlang:get(Ref)))(ok)
end})),
    Ref
.

enumerator_cast(E) ->
    enumerator_from_functions_1_ctor_58_c54629(fun(UnitVar) ->
        fable_utils:get_current(E)
end, fun(UnitVar_1) ->
        fable_utils:move_next(E)
end, fun(UnitVar_2) ->
        fable_utils:safe_dispose(E)
end)
.

enumerator_concat(Sources) ->
    OuterOpt_ref = fable_utils:new_ref(undefined),
    begin InnerOpt_ref = fable_utils:new_ref(undefined),
    begin Started_ref = fable_utils:new_ref(false),
    begin Finished_ref = fable_utils:new_ref(false),
    begin Curr_ref = fable_utils:new_ref(undefined),
    begin Finish = fun(UnitVar_1) ->
        erlang:put(Finished_ref, true),
        begin case erlang:get(InnerOpt_ref) =/= undefined of
            true ->
                begin Inner = erlang:get(InnerOpt_ref),
                try
                    fable_utils:safe_dispose(Inner)
                catch
                    _:Exn_reason_2 ->
                        erlang:error(Exn_reason_2)
                after
                    erlang:put(InnerOpt_ref, undefined)
                end end
            ;
            false ->
                ok
        end,
        case erlang:get(OuterOpt_ref) =/= undefined of
            true ->
                begin Outer = erlang:get(OuterOpt_ref),
                try
                    fable_utils:safe_dispose(Outer)
                catch
                    _:Exn_reason_3 ->
                        erlang:error(Exn_reason_3)
                after
                    erlang:put(OuterOpt_ref, undefined)
                end end
            ;
            false ->
                ok
        end end
end,
    enumerator_from_functions_1_ctor_58_c54629(fun(UnitVar) ->
        case not erlang:get(Started_ref) of
            true ->
                enumerator_not_started()
            ;
            false ->
                case erlang:get(Finished_ref) of
                    true ->
                        enumerator_already_finished()
                    ;
                    false ->
                        ok
                end
        end,
        case erlang:get(Curr_ref) =/= undefined of
            true ->
                fable_option:value(erlang:get(Curr_ref))
            ;
            false ->
                enumerator_already_finished()
        end
end, fun(UnitVar_3) ->
        case not erlang:get(Started_ref) of
            true ->
                erlang:put(Started_ref, true)
            ;
            false ->
                ok
        end,
        case erlang:get(Finished_ref) of
            true ->
                false
            ;
            false ->
                begin Res_ref = fable_utils:new_ref(undefined),
                Res_ref_result = begin begin While_loop_4 = fun While_loop_4() ->
                    case erlang:get(Res_ref) =:= undefined of
                        true ->
                            OuterOpt_1 = erlang:get(OuterOpt_ref),
                            begin InnerOpt_1 = erlang:get(InnerOpt_ref),
                            case OuterOpt_1 =/= undefined of
                                true ->
                                    case InnerOpt_1 =/= undefined of
                                        true ->
                                            begin Inner_1 = InnerOpt_1,
                                            case fable_utils:move_next(Inner_1) of
                                                true ->
                                                    begin erlang:put(Curr_ref, fable_option:some(fable_utils:get_current(Inner_1))),
                                                    erlang:put(Res_ref, true) end
                                                ;
                                                false ->
                                                    try
                                                        fable_utils:safe_dispose(Inner_1)
                                                    catch
                                                        _:Exn_reason_5 ->
                                                            erlang:error(Exn_reason_5)
                                                    after
                                                        erlang:put(InnerOpt_ref, undefined)
                                                    end
                                            end end
                                        ;
                                        false ->
                                            begin Outer_1 = OuterOpt_1,
                                            case fable_utils:move_next(Outer_1) of
                                                true ->
                                                    begin Ie = fable_utils:get_current(Outer_1),
                                                    erlang:put(InnerOpt_ref, begin CopyOfStruct = Ie,
                                                    fable_utils:get_enumerator(CopyOfStruct) end) end
                                                ;
                                                false ->
                                                    begin Finish(ok),
                                                    erlang:put(Res_ref, false) end
                                            end end
                                    end
                                ;
                                false ->
                                    erlang:put(OuterOpt_ref, fable_utils:get_enumerator(Sources))
                            end end,
                            While_loop_4()
                        ;
                        false ->
                            ok
                    end
end,
                While_loop_4() end,
                erlang:get(Res_ref) end,
                erlang:erase(Res_ref),
                Res_ref_result end
        end
end, fun(UnitVar_4) ->
        case not erlang:get(Finished_ref) of
            true ->
                Finish(ok)
            ;
            false ->
                ok
        end
end) end end end end end
.

enumerator_enumerate_then_finally(F, E) ->
    enumerator_from_functions_1_ctor_58_c54629(fun(UnitVar) ->
        fable_utils:get_current(E)
end, fun(UnitVar_1) ->
        fable_utils:move_next(E)
end, fun(UnitVar_2) ->
        try
            fable_utils:safe_dispose(E)
        catch
            _:Exn_reason_6 ->
                erlang:error(Exn_reason_6)
        after
            F(ok)
        end
end)
.

enumerator_generate_while_some(Openf, Compute, Closef) ->
    Started_ref = fable_utils:new_ref(false),
    begin Curr_ref = fable_utils:new_ref(undefined),
    begin State_ref = fable_utils:new_ref(fable_option:some(Openf(ok))),
    begin Dispose = fun(UnitVar_1) ->
        case erlang:get(State_ref) =/= undefined of
            true ->
                begin X_1 = fable_option:value(erlang:get(State_ref)),
                try
                    Closef(X_1)
                catch
                    _:Exn_reason_7 ->
                        erlang:error(Exn_reason_7)
                after
                    erlang:put(State_ref, undefined)
                end end
            ;
            false ->
                ok
        end
end,
    begin Finish = fun(UnitVar_2) ->
        try
            Dispose(ok)
        catch
            _:Exn_reason_8 ->
                erlang:error(Exn_reason_8)
        after
            erlang:put(Curr_ref, undefined)
        end
end,
    enumerator_from_functions_1_ctor_58_c54629(fun(UnitVar) ->
        case not erlang:get(Started_ref) of
            true ->
                enumerator_not_started()
            ;
            false ->
                ok
        end,
        case erlang:get(Curr_ref) =/= undefined of
            true ->
                fable_option:value(erlang:get(Curr_ref))
            ;
            false ->
                enumerator_already_finished()
        end
end, fun(UnitVar_3) ->
        case not erlang:get(Started_ref) of
            true ->
                erlang:put(Started_ref, true)
            ;
            false ->
                ok
        end,
        case erlang:get(State_ref) =/= undefined of
            true ->
                begin S = fable_option:value(erlang:get(State_ref)),
                begin MatchValue_1 = try
                    Compute(S)
                catch
                    _:Exn_reason_9 ->
                        MatchValue = case Exn_reason_9 of
                            _ when erlang:is_map(Exn_reason_9) ->
                                Exn_reason_9
                            ;
                            _ when erlang:is_reference(Exn_reason_9) ->
                                Exn_reason_9
                            ;
                            _ ->
                                #{message => case Exn_reason_9 of
                                    _ when erlang:is_binary(Exn_reason_9) ->
                                        Exn_reason_9
                                    ;
                                    _ ->
                                        erlang:iolist_to_binary(io_lib:format(erlang:binary_to_list(<<"~p"/utf8>>), [Exn_reason_9]))
                                end}
                        end,
                        Finish(ok),
                        erlang:error(Exn_reason_9)
                end,
                case MatchValue_1 =/= undefined of
                    true ->
                        begin erlang:put(Curr_ref, MatchValue_1),
                        true end
                    ;
                    false ->
                        begin Finish(ok),
                        false end
                end end end
            ;
            false ->
                false
        end
end, Dispose) end end end end
.

enumerator_unfold(F, State) ->
    Curr_ref = fable_utils:new_ref(undefined),
    begin Acc_ref = fable_utils:new_ref(State),
    enumerator_from_functions_1_ctor_58_c54629(fun(UnitVar) ->
        case erlang:get(Curr_ref) =/= undefined of
            true ->
                begin X = erlang:element(1, erlang:get(Curr_ref)),
                begin St = erlang:element(2, erlang:get(Curr_ref)),
                X end end
            ;
            false ->
                enumerator_not_started()
        end
end, fun(UnitVar_1) ->
        erlang:put(Curr_ref, F(erlang:get(Acc_ref))),
        case erlang:get(Curr_ref) =/= undefined of
            true ->
                begin X_1 = erlang:element(1, erlang:get(Curr_ref)),
                begin St_1 = erlang:element(2, erlang:get(Curr_ref)),
                begin erlang:put(Acc_ref, St_1),
                true end end end
            ;
            false ->
                false
        end
end, fun(UnitVar_2) ->
        ok
end) end
.

index_not_found() ->
    erlang:error(#{message => s_r_key_not_found_alt()})
.

mk_seq(F) ->
    enumerator_seq_ctor_673_a07_f2(F)
.

of_seq(Xs) ->
    fable_utils:get_enumerator((fun() -> case Xs of undefined -> erlang:error({badarg, <<"Value cannot be null. Parameter name: ", <<"source"/utf8>>/binary>>}); _ -> Xs end end)())
.

delay(Generator) ->
    mk_seq(fun(UnitVar) ->
        fable_utils:get_enumerator(Generator(ok))
end)
.

concat(Sources) ->
    mk_seq(fun(UnitVar) ->
        enumerator_concat(Sources)
end)
.

unfold(Generator, State) ->
    mk_seq(fun(UnitVar) ->
        enumerator_unfold(Generator, State)
end)
.

empty() ->
    delay(fun(UnitVar_1) ->
        fable_utils:new_ref([])
end)
.

singleton(X) ->
    delay(fun(UnitVar) ->
        fable_utils:new_ref([X])
end)
.

of_array(Arr) ->
    Arr
.

to_array(Xs) ->
    case erlang:is_list(Xs) of
        true ->
            begin A = Xs,
            fable_utils:new_ref(A) end
        ;
        false ->
            fable_utils:new_ref(fable_utils:to_list(Xs))
    end
.

of_list(Xs) ->
    Xs
.

to_list(Xs) ->
    case erlang:is_reference(Xs) andalso erlang:is_list(erlang:get(Xs)) of
        true ->
            begin A = Xs,
            erlang:get(A) end
        ;
        false ->
            case erlang:is_list(Xs) of
                true ->
                    Xs
                ;
                false ->
                    fable_utils:to_list(Xs)
            end
    end
.

generate(Create, Compute, Dispose) ->
    mk_seq(fun(UnitVar) ->
        enumerator_generate_while_some(Create, Compute, Dispose)
end)
.

generate_indexed(Create, Compute, Dispose) ->
    mk_seq(fun(UnitVar) ->
        I_ref = fable_utils:new_ref(-1),
        enumerator_generate_while_some(Create, fun(X) ->
            erlang:put(I_ref, erlang:get(I_ref) + 1),
            Compute(erlang:get(I_ref), X)
end, Dispose)
end)
.

append(Xs, Ys) ->
    concat(fable_utils:new_ref([Xs, Ys]))
.

cast(Xs) ->
    mk_seq(fun(UnitVar) ->
        enumerator_cast(fable_utils:get_enumerator((fun() -> case Xs of undefined -> erlang:error({badarg, <<"Value cannot be null. Parameter name: ", <<"source"/utf8>>/binary>>}); _ -> Xs end end)()))
end)
.

choose(Chooser, Xs) ->
    generate(fun(UnitVar) ->
        of_seq(Xs)
end, fun(E) ->
        Curr_ref = fable_utils:new_ref(undefined),
        Curr_ref_result = begin begin While_loop_10 = fun While_loop_10() ->
            case case erlang:get(Curr_ref) =:= undefined of
                true ->
                    fable_utils:move_next(E)
                ;
                false ->
                    false
            end of
                true ->
                    erlang:put(Curr_ref, Chooser(fable_utils:get_current(E))),
                    While_loop_10()
                ;
                false ->
                    ok
            end
end,
        While_loop_10() end,
        erlang:get(Curr_ref) end,
        erlang:erase(Curr_ref),
        Curr_ref_result
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

compare_with(Comparer, Xs, Ys) ->
    E1 = of_seq(Xs),
    try
        E2 = of_seq(Ys),
        try
            C_ref = fable_utils:new_ref(0),
            C_ref_result = begin B1_ref = fable_utils:new_ref(fable_utils:move_next(E1)),
            B1_ref_result = begin B2_ref = fable_utils:new_ref(fable_utils:move_next(E2)),
            B2_ref_result = begin begin While_loop_11 = fun While_loop_11() ->
                case case case fable_comparison:equals(erlang:get(C_ref), 0) of
                    true ->
                        erlang:get(B1_ref)
                    ;
                    false ->
                        false
                end of
                    true ->
                        erlang:get(B2_ref)
                    ;
                    false ->
                        false
                end of
                    true ->
                        erlang:put(C_ref, Comparer(fable_utils:get_current(E1), fable_utils:get_current(E2))),
                        case fable_comparison:equals(erlang:get(C_ref), 0) of
                            true ->
                                begin erlang:put(B1_ref, fable_utils:move_next(E1)),
                                erlang:put(B2_ref, fable_utils:move_next(E2)) end
                            ;
                            false ->
                                ok
                        end,
                        While_loop_11()
                    ;
                    false ->
                        ok
                end
end,
            While_loop_11() end,
            case not fable_comparison:equals(erlang:get(C_ref), 0) of
                true ->
                    erlang:get(C_ref)
                ;
                false ->
                    case erlang:get(B1_ref) of
                        true ->
                            1
                        ;
                        false ->
                            case erlang:get(B2_ref) of
                                true ->
                                    -1
                                ;
                                false ->
                                    0
                            end
                    end
            end end,
            erlang:erase(B2_ref),
            B2_ref_result end,
            erlang:erase(B1_ref),
            B1_ref_result end,
            erlang:erase(C_ref),
            C_ref_result
        catch
            _:Exn_reason_12 ->
                erlang:error(Exn_reason_12)
        after
            case erlang:is_map(E2) orelse erlang:is_reference(E2) of
                true ->
                    fable_utils:safe_dispose(E2)
                ;
                false ->
                    ok
            end
        end
    catch
        _:Exn_reason_13 ->
            erlang:error(Exn_reason_13)
    after
        case erlang:is_map(E1) orelse erlang:is_reference(E1) of
            true ->
                fable_utils:safe_dispose(E1)
            ;
            false ->
                ok
        end
    end
.

contains(Value, Xs, Comparer) ->
    E = of_seq(Xs),
    try
        Found_ref = fable_utils:new_ref(false),
        Found_ref_result = begin begin While_loop_14 = fun While_loop_14() ->
            case case not erlang:get(Found_ref) of
                true ->
                    fable_utils:move_next(E)
                ;
                false ->
                    false
            end of
                true ->
                    erlang:put(Found_ref, (fable_utils:iface_get(equals, 2, Comparer))(Value, fable_utils:get_current(E))),
                    While_loop_14()
                ;
                false ->
                    ok
            end
end,
        While_loop_14() end,
        erlang:get(Found_ref) end,
        erlang:erase(Found_ref),
        Found_ref_result
    catch
        _:Exn_reason_15 ->
            erlang:error(Exn_reason_15)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

enumerate_from_functions(Create, MoveNext, Current) ->
    generate(Create, fun(X) ->
        case MoveNext(X) of
            true ->
                fable_option:some(Current(X))
            ;
            false ->
                undefined
        end
end, fun(X_1) ->
        MatchValue = X_1,
        case erlang:is_map(MatchValue) orelse erlang:is_reference(MatchValue) of
            true ->
                begin Id = MatchValue,
                fable_utils:safe_dispose(Id) end
            ;
            false ->
                ok
        end
end)
.

enumerate_then_finally(Source, Compensation) ->
    Compensation_1 = Compensation,
    mk_seq(fun(UnitVar_1) ->
        try
            enumerator_enumerate_then_finally(Compensation_1, of_seq(Source))
        catch
            _:Exn_reason_16 ->
                MatchValue = case Exn_reason_16 of
                    _ when erlang:is_map(Exn_reason_16) ->
                        Exn_reason_16
                    ;
                    _ when erlang:is_reference(Exn_reason_16) ->
                        Exn_reason_16
                    ;
                    _ ->
                        #{message => case Exn_reason_16 of
                            _ when erlang:is_binary(Exn_reason_16) ->
                                Exn_reason_16
                            ;
                            _ ->
                                erlang:iolist_to_binary(io_lib:format(erlang:binary_to_list(<<"~p"/utf8>>), [Exn_reason_16]))
                        end}
                end,
                Compensation_1(ok),
                erlang:error(Exn_reason_16)
        end
end)
.

enumerate_using(Resource, Source) ->
    Compensation = fun(UnitVar) ->
        case fable_comparison:equals(Resource, undefined) of
            true ->
                ok
            ;
            false ->
                begin CopyOfStruct = Resource,
                fable_utils:safe_dispose(CopyOfStruct) end
        end
end,
    mk_seq(fun(UnitVar_2) ->
        try
            enumerator_enumerate_then_finally(Compensation, of_seq(Source(Resource)))
        catch
            _:Exn_reason_17 ->
                MatchValue_1 = case Exn_reason_17 of
                    _ when erlang:is_map(Exn_reason_17) ->
                        Exn_reason_17
                    ;
                    _ when erlang:is_reference(Exn_reason_17) ->
                        Exn_reason_17
                    ;
                    _ ->
                        #{message => case Exn_reason_17 of
                            _ when erlang:is_binary(Exn_reason_17) ->
                                Exn_reason_17
                            ;
                            _ ->
                                erlang:iolist_to_binary(io_lib:format(erlang:binary_to_list(<<"~p"/utf8>>), [Exn_reason_17]))
                        end}
                end,
                Compensation(ok),
                erlang:error(Exn_reason_17)
        end
end)
.

enumerate_while(Guard, Xs) ->
    concat(unfold(fun(I) ->
        case Guard(ok) of
            true ->
                {Xs, I + 1}
            ;
            false ->
                undefined
        end
end, 0))
.

filter(F, Xs) ->
    choose(fun(X) ->
        case F(X) of
            true ->
                fable_option:some(X)
            ;
            false ->
                undefined
        end
end, Xs)
.

exists(Predicate, Xs) ->
    E = of_seq(Xs),
    try
        Found_ref = fable_utils:new_ref(false),
        Found_ref_result = begin begin While_loop_18 = fun While_loop_18() ->
            case case not erlang:get(Found_ref) of
                true ->
                    fable_utils:move_next(E)
                ;
                false ->
                    false
            end of
                true ->
                    erlang:put(Found_ref, Predicate(fable_utils:get_current(E))),
                    While_loop_18()
                ;
                false ->
                    ok
            end
end,
        While_loop_18() end,
        erlang:get(Found_ref) end,
        erlang:erase(Found_ref),
        Found_ref_result
    catch
        _:Exn_reason_19 ->
            erlang:error(Exn_reason_19)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

exists2(Predicate, Xs, Ys) ->
    E1 = of_seq(Xs),
    try
        E2 = of_seq(Ys),
        try
            Found_ref = fable_utils:new_ref(false),
            Found_ref_result = begin begin While_loop_20 = fun While_loop_20() ->
                case case case not erlang:get(Found_ref) of
                    true ->
                        fable_utils:move_next(E1)
                    ;
                    false ->
                        false
                end of
                    true ->
                        fable_utils:move_next(E2)
                    ;
                    false ->
                        false
                end of
                    true ->
                        erlang:put(Found_ref, Predicate(fable_utils:get_current(E1), fable_utils:get_current(E2))),
                        While_loop_20()
                    ;
                    false ->
                        ok
                end
end,
            While_loop_20() end,
            erlang:get(Found_ref) end,
            erlang:erase(Found_ref),
            Found_ref_result
        catch
            _:Exn_reason_21 ->
                erlang:error(Exn_reason_21)
        after
            case erlang:is_map(E2) orelse erlang:is_reference(E2) of
                true ->
                    fable_utils:safe_dispose(E2)
                ;
                false ->
                    ok
            end
        end
    catch
        _:Exn_reason_22 ->
            erlang:error(Exn_reason_22)
    after
        case erlang:is_map(E1) orelse erlang:is_reference(E1) of
            true ->
                fable_utils:safe_dispose(E1)
            ;
            false ->
                ok
        end
    end
.

exactly_one(Xs) ->
    E = of_seq(Xs),
    try
        case fable_utils:move_next(E) of
            true ->
                begin V = fable_utils:get_current(E),
                case fable_utils:move_next(E) of
                    true ->
                        erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_input_sequence_too_long(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
                    ;
                    false ->
                        V
                end end
            ;
            false ->
                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_input_sequence_empty(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
        end
    catch
        _:Exn_reason_23 ->
            erlang:error(Exn_reason_23)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

try_exactly_one(Xs) ->
    E = of_seq(Xs),
    try
        case fable_utils:move_next(E) of
            true ->
                begin V = fable_utils:get_current(E),
                case fable_utils:move_next(E) of
                    true ->
                        undefined
                    ;
                    false ->
                        fable_option:some(V)
                end end
            ;
            false ->
                undefined
        end
    catch
        _:Exn_reason_24 ->
            erlang:error(Exn_reason_24)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

try_find(Predicate, Xs) ->
    E = of_seq(Xs),
    try
        Res_ref = fable_utils:new_ref(undefined),
        Res_ref_result = begin begin While_loop_25 = fun While_loop_25() ->
            case case erlang:get(Res_ref) =:= undefined of
                true ->
                    fable_utils:move_next(E)
                ;
                false ->
                    false
            end of
                true ->
                    C = fable_utils:get_current(E),
                    case Predicate(C) of
                        true ->
                            erlang:put(Res_ref, fable_option:some(C))
                        ;
                        false ->
                            ok
                    end,
                    While_loop_25()
                ;
                false ->
                    ok
            end
end,
        While_loop_25() end,
        erlang:get(Res_ref) end,
        erlang:erase(Res_ref),
        Res_ref_result
    catch
        _:Exn_reason_26 ->
            erlang:error(Exn_reason_26)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

find(Predicate, Xs) ->
    MatchValue = try_find(Predicate, Xs),
    case MatchValue =:= undefined of
        true ->
            index_not_found()
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

try_find_back(Predicate, Xs) ->
    Array = to_array(Xs),
    fable_list:try_find_back(Predicate, erlang:get(Array))
.

find_back(Predicate, Xs) ->
    MatchValue = try_find_back(Predicate, Xs),
    case MatchValue =:= undefined of
        true ->
            index_not_found()
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

try_find_index(Predicate, Xs) ->
    E = of_seq(Xs),
    try
        Loop = fun Loop(I) ->
            case fable_utils:move_next(E) of
                true ->
                    case Predicate(fable_utils:get_current(E)) of
                        true ->
                            I
                        ;
                        false ->
                            Loop(I + 1)
                    end
                ;
                false ->
                    undefined
            end
end,
        Loop(0)
    catch
        _:Exn_reason_27 ->
            erlang:error(Exn_reason_27)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

find_index(Predicate, Xs) ->
    MatchValue = try_find_index(Predicate, Xs),
    case MatchValue =:= undefined of
        true ->
            begin index_not_found(),
            -1 end
        ;
        false ->
            MatchValue
    end
.

try_find_index_back(Predicate, Xs) ->
    Array = to_array(Xs),
    fable_list:try_find_index_back(Predicate, erlang:get(Array))
.

find_index_back(Predicate, Xs) ->
    MatchValue = try_find_index_back(Predicate, Xs),
    case MatchValue =:= undefined of
        true ->
            begin index_not_found(),
            -1 end
        ;
        false ->
            MatchValue
    end
.

fold(Folder, State, Xs) ->
    E = of_seq(Xs),
    try
        Acc_ref = fable_utils:new_ref(State),
        Acc_ref_result = begin begin While_loop_28 = fun While_loop_28() ->
            case fable_utils:move_next(E) of
                true ->
                    erlang:put(Acc_ref, Folder(erlang:get(Acc_ref), fable_utils:get_current(E))),
                    While_loop_28()
                ;
                false ->
                    ok
            end
end,
        While_loop_28() end,
        erlang:get(Acc_ref) end,
        erlang:erase(Acc_ref),
        Acc_ref_result
    catch
        _:Exn_reason_29 ->
            erlang:error(Exn_reason_29)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

fold_back(Folder, Xs, State) ->
    fable_list:fold_back(fun(A0) ->
        fun(A1) ->
            Folder(A0, A1)
end
end, erlang:get(to_array(Xs)), State)
.

fold2(Folder, State, Xs, Ys) ->
    E1 = of_seq(Xs),
    try
        E2 = of_seq(Ys),
        try
            Acc_ref = fable_utils:new_ref(State),
            Acc_ref_result = begin begin While_loop_30 = fun While_loop_30() ->
                case case fable_utils:move_next(E1) of
                    true ->
                        fable_utils:move_next(E2)
                    ;
                    false ->
                        false
                end of
                    true ->
                        erlang:put(Acc_ref, Folder(erlang:get(Acc_ref), fable_utils:get_current(E1), fable_utils:get_current(E2))),
                        While_loop_30()
                    ;
                    false ->
                        ok
                end
end,
            While_loop_30() end,
            erlang:get(Acc_ref) end,
            erlang:erase(Acc_ref),
            Acc_ref_result
        catch
            _:Exn_reason_31 ->
                erlang:error(Exn_reason_31)
        after
            case erlang:is_map(E2) orelse erlang:is_reference(E2) of
                true ->
                    fable_utils:safe_dispose(E2)
                ;
                false ->
                    ok
            end
        end
    catch
        _:Exn_reason_32 ->
            erlang:error(Exn_reason_32)
    after
        case erlang:is_map(E1) orelse erlang:is_reference(E1) of
            true ->
                fable_utils:safe_dispose(E1)
            ;
            false ->
                ok
        end
    end
.

fold_back2(Folder, Xs, Ys, State) ->
    Xs_1 = to_array(Xs),
    begin Ys_1 = to_array(Ys),
    begin Len = erlang:min(erlang:length(erlang:get(Xs_1)), erlang:length(erlang:get(Ys_1))),
    begin Acc_ref = fable_utils:new_ref(State),
    Acc_ref_result = begin begin For_loop_33 = fun For_loop_33(I) ->
        case I >= 0 of
            true ->
                erlang:put(Acc_ref, Folder(lists:nth(I + 1, erlang:get(Xs_1)), lists:nth(I + 1, erlang:get(Ys_1)), erlang:get(Acc_ref))),
                For_loop_33(I - 1)
            ;
            false ->
                ok
        end
end,
    For_loop_33(Len - 1) end,
    erlang:get(Acc_ref) end,
    erlang:erase(Acc_ref),
    Acc_ref_result end end end
.

for_all(Predicate, Xs) ->
    not exists(fun(X) ->
        not (Predicate(X))
end, Xs)
.

for_all2(Predicate, Xs, Ys) ->
    not exists2(fun(X, Y) ->
        not (Predicate(X, Y))
end, Xs, Ys)
.

try_head(Xs) ->
    case erlang:is_reference(Xs) andalso erlang:is_list(erlang:get(Xs)) of
        true ->
            begin A = Xs,
            fable_list:try_head(erlang:get(A)) end
        ;
        false ->
            case erlang:is_list(Xs) of
                true ->
                    fable_list:try_head(Xs)
                ;
                false ->
                    begin E = of_seq(Xs),
                    try
                        case fable_utils:move_next(E) of
                            true ->
                                fable_option:some(fable_utils:get_current(E))
                            ;
                            false ->
                                undefined
                        end
                    catch
                        _:Exn_reason_34 ->
                            erlang:error(Exn_reason_34)
                    after
                        case erlang:is_map(E) orelse erlang:is_reference(E) of
                            true ->
                                fable_utils:safe_dispose(E)
                            ;
                            false ->
                                ok
                        end
                    end end
            end
    end
.

head(Xs) ->
    MatchValue = try_head(Xs),
    case MatchValue =:= undefined of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_input_sequence_empty(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

initialize(Count, F) ->
    unfold(fun(I) ->
        case I < Count of
            true ->
                {F(I), I + 1}
            ;
            false ->
                undefined
        end
end, 0)
.

initialize_infinite(F) ->
    initialize(2147483647, F)
.

is_empty(Xs) ->
    case erlang:is_reference(Xs) andalso erlang:is_list(erlang:get(Xs)) of
        true ->
            begin A = Xs,
            (erlang:get(A) =:= []) end
        ;
        false ->
            case erlang:is_list(Xs) of
                true ->
                    begin A_1 = Xs,
                    (A_1 =:= []) end
                ;
                false ->
                    begin E = of_seq(Xs),
                    try
                        not fable_utils:move_next(E)
                    catch
                        _:Exn_reason_35 ->
                            erlang:error(Exn_reason_35)
                    after
                        case erlang:is_map(E) orelse erlang:is_reference(E) of
                            true ->
                                fable_utils:safe_dispose(E)
                            ;
                            false ->
                                ok
                        end
                    end end
            end
    end
.

try_item(Index, Xs) ->
    case erlang:is_reference(Xs) andalso erlang:is_list(erlang:get(Xs)) of
        true ->
            begin A = Xs,
            fable_list:try_item(Index, erlang:get(A)) end
        ;
        false ->
            case erlang:is_list(Xs) of
                true ->
                    fable_list:try_item(Index, Xs)
                ;
                false ->
                    begin E = of_seq(Xs),
                    try
                        Loop = fun Loop(Index_1) ->
                            case not fable_utils:move_next(E) of
                                true ->
                                    undefined
                                ;
                                false ->
                                    case fable_comparison:equals(Index_1, 0) of
                                        true ->
                                            fable_option:some(fable_utils:get_current(E))
                                        ;
                                        false ->
                                            Loop(Index_1 - 1)
                                    end
                            end
end,
                        Loop(Index)
                    catch
                        _:Exn_reason_36 ->
                            erlang:error(Exn_reason_36)
                    after
                        case erlang:is_map(E) orelse erlang:is_reference(E) of
                            true ->
                                fable_utils:safe_dispose(E)
                            ;
                            false ->
                                ok
                        end
                    end end
            end
    end
.

item(Index, Xs) ->
    MatchValue = try_item(Index, Xs),
    case MatchValue =:= undefined of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_not_enough_elements(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

iterate(Action, Xs) ->
    fold(fun(UnitVar, X) ->
        Action(X)
end, ok, Xs)
.

iterate2(Action, Xs, Ys) ->
    fold2(fun(UnitVar, X, Y) ->
        Action(X, Y)
end, ok, Xs, Ys)
.

iterate_indexed(Action, Xs) ->
    fold(fun(I, X) ->
        Action(I, X),
        I + 1
end, 0, Xs),
    ok
.

iterate_indexed2(Action, Xs, Ys) ->
    fold2(fun(I, X, Y) ->
        Action(I, X, Y),
        I + 1
end, 0, Xs, Ys),
    ok
.

try_last(Xs) ->
    E = of_seq(Xs),
    try
        Loop = fun Loop(Acc) ->
            case not fable_utils:move_next(E) of
                true ->
                    Acc
                ;
                false ->
                    Loop(fable_utils:get_current(E))
            end
end,
        case fable_utils:move_next(E) of
            true ->
                fable_option:some(Loop(fable_utils:get_current(E)))
            ;
            false ->
                undefined
        end
    catch
        _:Exn_reason_37 ->
            erlang:error(Exn_reason_37)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

last(Xs) ->
    MatchValue = try_last(Xs),
    case MatchValue =:= undefined of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_not_enough_elements(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

length(Xs) ->
    case erlang:is_reference(Xs) andalso erlang:is_list(erlang:get(Xs)) of
        true ->
            begin A = Xs,
            erlang:length(erlang:get(A)) end
        ;
        false ->
            case erlang:is_list(Xs) of
                true ->
                    begin A_1 = Xs,
                    erlang:length(A_1) end
                ;
                false ->
                    begin E = of_seq(Xs),
                    try
                        Count_ref = fable_utils:new_ref(0),
                        Count_ref_result = begin begin While_loop_38 = fun While_loop_38() ->
                            case fable_utils:move_next(E) of
                                true ->
                                    erlang:put(Count_ref, erlang:get(Count_ref) + 1),
                                    While_loop_38()
                                ;
                                false ->
                                    ok
                            end
end,
                        While_loop_38() end,
                        erlang:get(Count_ref) end,
                        erlang:erase(Count_ref),
                        Count_ref_result
                    catch
                        _:Exn_reason_39 ->
                            erlang:error(Exn_reason_39)
                    after
                        case erlang:is_map(E) orelse erlang:is_reference(E) of
                            true ->
                                fable_utils:safe_dispose(E)
                            ;
                            false ->
                                ok
                        end
                    end end
            end
    end
.

map(Mapping, Xs) ->
    generate(fun(UnitVar) ->
        of_seq(Xs)
end, fun(E) ->
        case fable_utils:move_next(E) of
            true ->
                fable_option:some(Mapping(fable_utils:get_current(E)))
            ;
            false ->
                undefined
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

map_indexed(Mapping, Xs) ->
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case fable_utils:move_next(E) of
            true ->
                fable_option:some(Mapping(I, fable_utils:get_current(E)))
            ;
            false ->
                undefined
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

indexed(Xs) ->
    map_indexed(fun(I, X) ->
        {I, X}
end, Xs)
.

map2(Mapping, Xs, Ys) ->
    generate(fun(UnitVar) ->
        {of_seq(Xs), of_seq(Ys)}
end, fun(TupledArg) ->
        E1 = erlang:element(1, TupledArg),
        begin E2 = erlang:element(2, TupledArg),
        case case fable_utils:move_next(E1) of
            true ->
                fable_utils:move_next(E2)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(Mapping(fable_utils:get_current(E1), fable_utils:get_current(E2)))
            ;
            false ->
                undefined
        end end
end, fun(TupledArg_1) ->
        try
            fable_utils:safe_dispose(erlang:element(1, TupledArg_1))
        catch
            _:Exn_reason_40 ->
                erlang:error(Exn_reason_40)
        after
            fable_utils:safe_dispose(erlang:element(2, TupledArg_1))
        end
end)
.

map_indexed2(Mapping, Xs, Ys) ->
    generate_indexed(fun(UnitVar) ->
        {of_seq(Xs), of_seq(Ys)}
end, fun(I, TupledArg) ->
        E1 = erlang:element(1, TupledArg),
        begin E2 = erlang:element(2, TupledArg),
        case case fable_utils:move_next(E1) of
            true ->
                fable_utils:move_next(E2)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(Mapping(I, fable_utils:get_current(E1), fable_utils:get_current(E2)))
            ;
            false ->
                undefined
        end end
end, fun(TupledArg_1) ->
        try
            fable_utils:safe_dispose(erlang:element(1, TupledArg_1))
        catch
            _:Exn_reason_41 ->
                erlang:error(Exn_reason_41)
        after
            fable_utils:safe_dispose(erlang:element(2, TupledArg_1))
        end
end)
.

map3(Mapping, Xs, Ys, Zs) ->
    generate(fun(UnitVar) ->
        {of_seq(Xs), of_seq(Ys), of_seq(Zs)}
end, fun(TupledArg) ->
        E1 = erlang:element(1, TupledArg),
        begin E2 = erlang:element(2, TupledArg),
        begin E3 = erlang:element(3, TupledArg),
        case case case fable_utils:move_next(E1) of
            true ->
                fable_utils:move_next(E2)
            ;
            false ->
                false
        end of
            true ->
                fable_utils:move_next(E3)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(Mapping(fable_utils:get_current(E1), fable_utils:get_current(E2), fable_utils:get_current(E3)))
            ;
            false ->
                undefined
        end end end
end, fun(TupledArg_1) ->
        try
            fable_utils:safe_dispose(erlang:element(1, TupledArg_1))
        catch
            _:Exn_reason_43 ->
                erlang:error(Exn_reason_43)
        after
            try
                fable_utils:safe_dispose(erlang:element(2, TupledArg_1))
            catch
                _:Exn_reason_42 ->
                    erlang:error(Exn_reason_42)
            after
                fable_utils:safe_dispose(erlang:element(3, TupledArg_1))
            end
        end
end)
.

read_only(Xs) ->
    map(fun(X) ->
        X
end, (fun() -> case Xs of undefined -> erlang:error({badarg, <<"Value cannot be null. Parameter name: ", <<"source"/utf8>>/binary>>}); _ -> Xs end end)())
.

cached_seq_1_ctor_z7_a8347_d4(Cleanup, Res) ->
    Ref = erlang:make_ref(),
    erlang:put(Ref, #{field_cleanup => Cleanup, field_res => Res}),
    erlang:put(Ref, maps:merge(erlang:get(Ref), #{dispose => fun() ->
        (maps:get(field_cleanup, erlang:get(Ref)))(ok)
end, get_enumerator => fun() ->
        fable_utils:get_enumerator(maps:get(field_res, erlang:get(Ref)))
end, system_collections_i_enumerable_get_enumerator => fun() ->
        fable_utils:get_enumerator(maps:get(field_res, erlang:get(Ref)))
end})),
    Ref
.

cached_seq_1_clear(This) ->
    (maps:get(field_cleanup, erlang:get(This)))(ok)
.

cache(Source) ->
    Source_1 = (fun() -> case Source of undefined -> erlang:error({badarg, <<"Value cannot be null. Parameter name: ", <<"source"/utf8>>/binary>>}); _ -> Source end end)(),
    begin Prefix = fable_utils:new_ref([]),
    begin EnumeratorR_ref = fable_utils:new_ref(undefined),
    cached_seq_1_ctor_z7_a8347_d4(fun(UnitVar_1) ->
        (fun(UnitVar_2) ->
            put(Prefix, []),
            begin case erlang:get(EnumeratorR_ref) =/= undefined of
                true ->
                    case fable_option:value(erlang:get(EnumeratorR_ref)) =/= undefined of
                        true ->
                            begin E = fable_option:value(erlang:get(EnumeratorR_ref)),
                            fable_utils:safe_dispose(E) end
                        ;
                        false ->
                            ok
                    end
                ;
                false ->
                    ok
            end,
            erlang:put(EnumeratorR_ref, undefined) end
end)(ok)
end, unfold(fun(I_1) ->
        (fun(UnitVar) ->
            case I_1 < (erlang:length(erlang:get(Prefix))) of
                true ->
                    {lists:nth(I_1 + 1, get(Prefix)), I_1 + 1}
                ;
                false ->
                    begin case I_1 >= (erlang:length(erlang:get(Prefix))) of
                        true ->
                            begin OptEnumerator_2 = case erlang:get(EnumeratorR_ref) =/= undefined of
                                true ->
                                    fable_option:value(erlang:get(EnumeratorR_ref))
                                ;
                                false ->
                                    begin OptEnumerator = fable_utils:get_enumerator(Source_1),
                                    begin erlang:put(EnumeratorR_ref, fable_option:some(OptEnumerator)),
                                    OptEnumerator end end
                            end,
                            case OptEnumerator_2 =:= undefined of
                                true ->
                                    ok
                                ;
                                false ->
                                    begin Enumerator = OptEnumerator_2,
                                    case fable_utils:move_next(Enumerator) of
                                        true ->
                                            put(Prefix, get(Prefix) ++ [fable_utils:get_current(Enumerator)])
                                        ;
                                        false ->
                                            begin fable_utils:safe_dispose(Enumerator),
                                            erlang:put(EnumeratorR_ref, fable_option:some(undefined)) end
                                    end end
                            end end
                        ;
                        false ->
                            ok
                    end,
                    case I_1 < (erlang:length(erlang:get(Prefix))) of
                        true ->
                            {lists:nth(I_1 + 1, get(Prefix)), I_1 + 1}
                        ;
                        false ->
                            undefined
                    end end
            end
end)(ok)
end, 0)) end end
.

all_pairs(Xs, Ys) ->
    YsCache = cache(Ys),
    delay(fun(UnitVar) ->
        concat(map(fun(X) ->
            map(fun(Y) ->
                {X, Y}
end, YsCache)
end, Xs))
end)
.

map_fold(Mapping, State, Xs) ->
    PatternInput = (fun() -> {Mf_list, Mf_state} = fable_list:map_fold(fun(A0) ->
        fun(A1) ->
            Mapping(A0, A1)
end
end, State, erlang:get(to_array(Xs))), {fable_utils:new_ref(Mf_list), Mf_state} end)(),
    {read_only(erlang:element(1, PatternInput)), erlang:element(2, PatternInput)}
.

map_fold_back(Mapping, Xs, State) ->
    PatternInput = (fun() -> {Mf_list, Mf_state} = fable_list:map_fold_back(fun(A0) ->
        fun(A1) ->
            Mapping(A0, A1)
end
end, erlang:get(to_array(Xs)), State), {fable_utils:new_ref(Mf_list), Mf_state} end)(),
    {read_only(erlang:element(1, PatternInput)), erlang:element(2, PatternInput)}
.

try_pick(Chooser, Xs) ->
    E = of_seq(Xs),
    try
        Res_ref = fable_utils:new_ref(undefined),
        Res_ref_result = begin begin While_loop_44 = fun While_loop_44() ->
            case case erlang:get(Res_ref) =:= undefined of
                true ->
                    fable_utils:move_next(E)
                ;
                false ->
                    false
            end of
                true ->
                    erlang:put(Res_ref, Chooser(fable_utils:get_current(E))),
                    While_loop_44()
                ;
                false ->
                    ok
            end
end,
        While_loop_44() end,
        erlang:get(Res_ref) end,
        erlang:erase(Res_ref),
        Res_ref_result
    catch
        _:Exn_reason_45 ->
            erlang:error(Exn_reason_45)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

pick(Chooser, Xs) ->
    MatchValue = try_pick(Chooser, Xs),
    case MatchValue =:= undefined of
        true ->
            index_not_found()
        ;
        false ->
            fable_option:value(MatchValue)
    end
.

reduce(Folder, Xs) ->
    E = of_seq(Xs),
    try
        Loop = fun Loop(Acc) ->
            case fable_utils:move_next(E) of
                true ->
                    Loop(Folder(Acc, fable_utils:get_current(E)))
                ;
                false ->
                    Acc
            end
end,
        case fable_utils:move_next(E) of
            true ->
                Loop(fable_utils:get_current(E))
            ;
            false ->
                erlang:error(s_r_input_sequence_empty())
        end
    catch
        _:Exn_reason_46 ->
            erlang:error(Exn_reason_46)
    after
        case erlang:is_map(E) orelse erlang:is_reference(E) of
            true ->
                fable_utils:safe_dispose(E)
            ;
            false ->
                ok
        end
    end
.

reduce_back(Folder, Xs) ->
    Arr = to_array(Xs),
    case (erlang:length(erlang:get(Arr))) > 0 of
        true ->
            fable_list:reduce_back(fun(A0) ->
                fun(A1) ->
                    Folder(A0, A1)
end
end, erlang:get(Arr))
        ;
        false ->
            erlang:error(s_r_input_sequence_empty())
    end
.

replicate(N, X) ->
    initialize(N, fun(_arg) ->
        X
end)
.

reverse(Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(lists:reverse(erlang:get(Array))))
end)
.

scan(Folder, State, Xs) ->
    delay(fun(UnitVar) ->
        Acc_ref = fable_utils:new_ref(State),
        concat(fable_utils:new_ref([singleton(State), map(fun(X) ->
            erlang:put(Acc_ref, Folder(erlang:get(Acc_ref), X)),
            erlang:get(Acc_ref)
end, Xs)]))
end)
.

scan_back(Folder, Xs, State) ->
    delay(fun(UnitVar) ->
        Arr = to_array(Xs),
        of_array(fable_utils:new_ref(fable_list:scan_back(fun(A0) ->
            fun(A1) ->
                Folder(A0, A1)
end
end, erlang:get(Arr), State)))
end)
.

skip(Count, Source) ->
    mk_seq(fun(UnitVar) ->
        E = of_seq(Source),
        try
            begin For_loop_47 = fun For_loop_47(_For_i_47) ->
                case _For_i_47 =< Count of
                    true ->
                        case not fable_utils:move_next(E) of
                            true ->
                                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_not_enough_elements(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        For_loop_47(_For_i_47 + 1)
                    ;
                    false ->
                        ok
                end
end,
            For_loop_47(1) end,
            enumerator_enumerate_then_finally(fun(UnitVar_1) ->
                ok
end, E)
        catch
            _:Exn_reason_48 ->
                MatchValue = case Exn_reason_48 of
                    _ when erlang:is_map(Exn_reason_48) ->
                        Exn_reason_48
                    ;
                    _ when erlang:is_reference(Exn_reason_48) ->
                        Exn_reason_48
                    ;
                    _ ->
                        #{message => case Exn_reason_48 of
                            _ when erlang:is_binary(Exn_reason_48) ->
                                Exn_reason_48
                            ;
                            _ ->
                                erlang:iolist_to_binary(io_lib:format(erlang:binary_to_list(<<"~p"/utf8>>), [Exn_reason_48]))
                        end}
                end,
                fable_utils:safe_dispose(E),
                erlang:error(Exn_reason_48)
        end
end)
.

skip_while(Predicate, Xs) ->
    delay(fun(UnitVar) ->
        Skipped_ref = fable_utils:new_ref(true),
        filter(fun(X) ->
            case erlang:get(Skipped_ref) of
                true ->
                    erlang:put(Skipped_ref, Predicate(X))
                ;
                false ->
                    ok
            end,
            not erlang:get(Skipped_ref)
end, Xs)
end)
.

tail(Xs) ->
    skip(1, Xs)
.

take(Count, Xs) ->
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case I < Count of
            true ->
                case fable_utils:move_next(E) of
                    true ->
                        fable_option:some(fable_utils:get_current(E))
                    ;
                    false ->
                        erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_not_enough_elements(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
                end
            ;
            false ->
                undefined
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

take_while(Predicate, Xs) ->
    generate(fun(UnitVar) ->
        of_seq(Xs)
end, fun(E) ->
        case case fable_utils:move_next(E) of
            true ->
                Predicate(fable_utils:get_current(E))
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(fable_utils:get_current(E))
            ;
            false ->
                undefined
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

truncate(Count, Xs) ->
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case case I < Count of
            true ->
                fable_utils:move_next(E)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(fable_utils:get_current(E))
            ;
            false ->
                undefined
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

zip(Xs, Ys) ->
    map2(fun(X, Y) ->
        {X, Y}
end, Xs, Ys)
.

zip3(Xs, Ys, Zs) ->
    map3(fun(X, Y, Z) ->
        {X, Y, Z}
end, Xs, Ys, Zs)
.

collect(Mapping, Xs) ->
    delay(fun(UnitVar) ->
        concat(map(Mapping, Xs))
end)
.

where(Predicate, Xs) ->
    filter(Predicate, Xs)
.

pairwise(Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(fable_list:pairwise(erlang:get(Array))))
end)
.

split_into(Chunks, Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(lists:map(fun(Si_x) -> fable_utils:new_ref(Si_x) end, fable_list:split_into(Chunks, erlang:get(Array)))))
end)
.

windowed(WindowSize, Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(lists:map(fun(Wn_x) -> fable_utils:new_ref(Wn_x) end, fable_list:windowed(WindowSize, erlang:get(Array)))))
end)
.

transpose(Xss) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xss),
        Arrays = fable_utils:new_ref(lists:map(fun(Xs_1) ->
            to_array(Xs_1)
end, erlang:get(Array))),
        Array_1 = fable_utils:new_ref(lists:map(fun(Tr_x) -> fable_utils:new_ref(Tr_x) end, fable_list:transpose(lists:map(fun erlang:get/1, erlang:get(Arrays))))),
        of_array(fable_utils:new_ref(lists:map(fun(Arr) ->
            of_array(Arr)
end, erlang:get(Array_1))))
end)
.

sort_with(Comparer, Xs) ->
    delay(fun(UnitVar) ->
        Arr = to_array(Xs),
        begin erlang:put(Arr, fable_list:sort_with(fun(A0) ->
            fun(A1) ->
                Comparer(A0, A1)
end
end, erlang:get(Arr))),
        of_array(Arr) end
end)
.

sort(Xs, Comparer) ->
    sort_with(fun(X, Y) ->
        (fable_utils:iface_get(compare, 2, Comparer))(X, Y)
end, Xs)
.

sort_by(Projection, Xs, Comparer) ->
    sort_with(fun(X, Y) ->
        (fable_utils:iface_get(compare, 2, Comparer))(Projection(X), Projection(Y))
end, Xs)
.

sort_descending(Xs, Comparer) ->
    sort_with(fun(X, Y) ->
        ((fable_utils:iface_get(compare, 2, Comparer))(X, Y)) * (-1)
end, Xs)
.

sort_by_descending(Projection, Xs, Comparer) ->
    sort_with(fun(X, Y) ->
        ((fable_utils:iface_get(compare, 2, Comparer))(Projection(X), Projection(Y))) * (-1)
end, Xs)
.

sum(Xs, Adder) ->
    fold(fun(Acc, X) ->
        (fable_utils:iface_get(add, 2, Adder))(Acc, X)
end, (fable_utils:iface_get(get_zero, 0, Adder))(), Xs)
.

sum_by(F, Xs, Adder) ->
    fold(fun(Acc, X) ->
        (fable_utils:iface_get(add, 2, Adder))(Acc, F(X))
end, (fable_utils:iface_get(get_zero, 0, Adder))(), Xs)
.

max_by(Projection, Xs, Comparer) ->
    reduce(fun(X, Y) ->
        case ((fable_utils:iface_get(compare, 2, Comparer))(Projection(Y), Projection(X))) > 0 of
            true ->
                Y
            ;
            false ->
                X
        end
end, Xs)
.

max(Xs, Comparer) ->
    reduce(fun(X, Y) ->
        case ((fable_utils:iface_get(compare, 2, Comparer))(Y, X)) > 0 of
            true ->
                Y
            ;
            false ->
                X
        end
end, Xs)
.

min_by(Projection, Xs, Comparer) ->
    reduce(fun(X, Y) ->
        case ((fable_utils:iface_get(compare, 2, Comparer))(Projection(Y), Projection(X))) > 0 of
            true ->
                X
            ;
            false ->
                Y
        end
end, Xs)
.

min(Xs, Comparer) ->
    reduce(fun(X, Y) ->
        case ((fable_utils:iface_get(compare, 2, Comparer))(Y, X)) > 0 of
            true ->
                X
            ;
            false ->
                Y
        end
end, Xs)
.

average(Xs, Averager) ->
    Count_ref = fable_utils:new_ref(0),
    begin Total = fold(fun(Acc, X) ->
        erlang:put(Count_ref, erlang:get(Count_ref) + 1),
        (fable_utils:iface_get(add, 2, Averager))(Acc, X)
end, (fable_utils:iface_get(get_zero, 0, Averager))(), Xs),
    case fable_comparison:equals(erlang:get(Count_ref), 0) of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_input_sequence_empty(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
        ;
        false ->
            (fable_utils:iface_get(divide_by_int, 2, Averager))(Total, erlang:get(Count_ref))
    end end
.

average_by(F, Xs, Averager) ->
    Count_ref = fable_utils:new_ref(0),
    begin Total = fold(fun(Acc, X) ->
        erlang:put(Count_ref, erlang:get(Count_ref) + 1),
        (fable_utils:iface_get(add, 2, Averager))(Acc, F(X))
end, (fable_utils:iface_get(get_zero, 0, Averager))(), Xs),
    case fable_comparison:equals(erlang:get(Count_ref), 0) of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([s_r_input_sequence_empty(), <<"\\nParameter name: "/utf8>>]), <<"source"/utf8>>]))
        ;
        false ->
            (fable_utils:iface_get(divide_by_int, 2, Averager))(Total, erlang:get(Count_ref))
    end end
.

permute(F, Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(fable_list:permute(F, erlang:get(Array))))
end)
.

chunk_by_size(ChunkSize, Xs) ->
    delay(fun(UnitVar) ->
        Array = to_array(Xs),
        of_array(fable_utils:new_ref(lists:map(fun(Ck_x) -> fable_utils:new_ref(Ck_x) end, fable_list:chunk_by_size(ChunkSize, erlang:get(Array)))))
end)
.

insert_at(Index, Y, Xs) ->
    IsDone_ref = fable_utils:new_ref(false),
    begin case Index < 0 of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            ok
    end,
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case case case erlang:get(IsDone_ref) of
            true ->
                true
            ;
            false ->
                I < Index
        end of
            true ->
                fable_utils:move_next(E)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(fable_utils:get_current(E))
            ;
            false ->
                case fable_comparison:equals(I, Index) of
                    true ->
                        begin erlang:put(IsDone_ref, true),
                        fable_option:some(Y) end
                    ;
                    false ->
                        begin case not erlang:get(IsDone_ref) of
                            true ->
                                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        undefined end
                end
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end) end
.

insert_many_at(Index, Ys, Xs) ->
    Status_ref = fable_utils:new_ref(-1),
    begin case Index < 0 of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            ok
    end,
    generate_indexed(fun(UnitVar) ->
        {of_seq(Xs), of_seq(Ys)}
end, fun(I, TupledArg) ->
        E1 = erlang:element(1, TupledArg),
        begin E2 = erlang:element(2, TupledArg),
        begin case fable_comparison:equals(I, Index) of
            true ->
                erlang:put(Status_ref, 0)
            ;
            false ->
                ok
        end,
        begin Inserted = case fable_comparison:equals(erlang:get(Status_ref), 0) of
            true ->
                case fable_utils:move_next(E2) of
                    true ->
                        fable_option:some(fable_utils:get_current(E2))
                    ;
                    false ->
                        begin erlang:put(Status_ref, 1),
                        undefined end
                end
            ;
            false ->
                undefined
        end,
        case Inserted =:= undefined of
            true ->
                case fable_utils:move_next(E1) of
                    true ->
                        fable_option:some(fable_utils:get_current(E1))
                    ;
                    false ->
                        begin case erlang:get(Status_ref) < 1 of
                            true ->
                                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        undefined end
                end
            ;
            false ->
                fable_option:some(fable_option:value(Inserted))
        end end end end
end, fun(TupledArg_1) ->
        fable_utils:safe_dispose(erlang:element(1, TupledArg_1)),
        fable_utils:safe_dispose(erlang:element(2, TupledArg_1))
end) end
.

remove_at(Index, Xs) ->
    IsDone_ref = fable_utils:new_ref(false),
    begin case Index < 0 of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            ok
    end,
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case case case erlang:get(IsDone_ref) of
            true ->
                true
            ;
            false ->
                I < Index
        end of
            true ->
                fable_utils:move_next(E)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(fable_utils:get_current(E))
            ;
            false ->
                case case fable_comparison:equals(I, Index) of
                    true ->
                        fable_utils:move_next(E)
                    ;
                    false ->
                        false
                end of
                    true ->
                        begin erlang:put(IsDone_ref, true),
                        case fable_utils:move_next(E) of
                            true ->
                                fable_option:some(fable_utils:get_current(E))
                            ;
                            false ->
                                undefined
                        end end
                    ;
                    false ->
                        begin case not erlang:get(IsDone_ref) of
                            true ->
                                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        undefined end
                end
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end) end
.

remove_many_at(Index, Count, Xs) ->
    case Index < 0 of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            ok
    end,
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case I < Index of
            true ->
                case fable_utils:move_next(E) of
                    true ->
                        fable_option:some(fable_utils:get_current(E))
                    ;
                    false ->
                        erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
                end
            ;
            false ->
                begin case fable_comparison:equals(I, Index) of
                    true ->
                        begin For_loop_49 = fun For_loop_49(_For_i_49) ->
                            case _For_i_49 =< Count of
                                true ->
                                    case not fable_utils:move_next(E) of
                                        true ->
                                            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"count"/utf8>>]))
                                        ;
                                        false ->
                                            ok
                                    end,
                                    For_loop_49(_For_i_49 + 1)
                                ;
                                false ->
                                    ok
                            end
end,
                        For_loop_49(1) end
                    ;
                    false ->
                        ok
                end,
                case fable_utils:move_next(E) of
                    true ->
                        fable_option:some(fable_utils:get_current(E))
                    ;
                    false ->
                        undefined
                end end
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end)
.

update_at(Index, Y, Xs) ->
    IsDone_ref = fable_utils:new_ref(false),
    begin case Index < 0 of
        true ->
            erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
        ;
        false ->
            ok
    end,
    generate_indexed(fun(UnitVar) ->
        of_seq(Xs)
end, fun(I, E) ->
        case case case erlang:get(IsDone_ref) of
            true ->
                true
            ;
            false ->
                I < Index
        end of
            true ->
                fable_utils:move_next(E)
            ;
            false ->
                false
        end of
            true ->
                fable_option:some(fable_utils:get_current(E))
            ;
            false ->
                case case fable_comparison:equals(I, Index) of
                    true ->
                        fable_utils:move_next(E)
                    ;
                    false ->
                        false
                end of
                    true ->
                        begin erlang:put(IsDone_ref, true),
                        fable_option:some(Y) end
                    ;
                    false ->
                        begin case not erlang:get(IsDone_ref) of
                            true ->
                                erlang:error(erlang:iolist_to_binary([erlang:iolist_to_binary([fable_global:s_r_index_out_of_bounds(), <<"\\nParameter name: "/utf8>>]), <<"index"/utf8>>]))
                            ;
                            false ->
                                ok
                        end,
                        undefined end
                end
        end
end, fun(E_1) ->
        fable_utils:safe_dispose(E_1)
end) end
.

random_shuffle_by(Randomizer, Xs) ->
    Arr = to_array(Xs),
    begin begin erlang:put(Arr, fable_list:random_shuffle_by(Randomizer, erlang:get(Arr))), ok end,
    of_array(Arr) end
.

random_shuffle_with(Random, Xs) ->
    random_shuffle_by(fun(UnitVar) ->
        fable_random:next_double(Random)
end, Xs)
.

random_shuffle(Xs) ->
    random_shuffle_with(fable_random:new(), Xs)
.

random_choice_by(Randomizer, Xs) ->
    Source = to_array(Xs),
    fable_list:random_choice_by(Randomizer, erlang:get(Source))
.

random_choice_with(Random, Xs) ->
    Source = to_array(Xs),
    fable_list:random_choice_with(Random, erlang:get(Source))
.

random_choice(Xs) ->
    Source = to_array(Xs),
    fable_list:random_choice(erlang:get(Source))
.

random_choices_by(Randomizer, Count, Xs) ->
    Source = to_array(Xs),
    of_array(fable_utils:new_ref(fable_list:random_choices_by(Randomizer, Count, erlang:get(Source))))
.

random_choices_with(Random, Count, Xs) ->
    random_choices_by(fun(UnitVar) ->
        fable_random:next_double(Random)
end, Count, Xs)
.

random_choices(Count, Xs) ->
    random_choices_with(fable_random:new(), Count, Xs)
.

random_sample_by(Randomizer, Count, Xs) ->
    Source = to_array(Xs),
    of_array(fable_utils:new_ref(fable_list:random_sample_by(Randomizer, Count, erlang:get(Source))))
.

random_sample_with(Random, Count, Xs) ->
    random_sample_by(fun(UnitVar) ->
        fable_random:next_double(Random)
end, Count, Xs)
.

random_sample(Count, Xs) ->
    random_sample_with(fable_random:new(), Count, Xs)
.
