-module(gleam@iterator). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([unfold/2, repeatedly/1, repeat/1, from_list/1, transform/3, fold/3, run/1, to_list/1, step/1, take/2, drop/2, map/2, map2/3, append/2, flatten/1, concat/1, flat_map/2, filter/2, filter_map/2, cycle/1, find/2, find_map/2, index/1, iterate/2, take_while/2, drop_while/2, scan/3, zip/2, chunk/2, sized_chunk/2, intersperse/2, any/2, all/2, group/2, reduce/2, last/1, empty/0, once/1, range/2, single/1, interleave/2, fold_until/3, try_fold/3, first/1, at/2, length/1, each/2, yield/2]). -export_type([action/1, iterator/1, step/2, chunk/2, sized_chunk/1]). -type action(DRY) :: stop | {continue, DRY, fun(() -> action(DRY))}. -opaque iterator(DRZ) :: {iterator, fun(() -> action(DRZ))}. -type step(DSA, DSB) :: {next, DSA, DSB} | done. -type chunk(DSC, DSD) :: {another_by, list(DSC), DSD, DSC, fun(() -> action(DSC))} | {last_by, list(DSC)}. -type sized_chunk(DSE) :: {another, list(DSE), fun(() -> action(DSE))} | {last, list(DSE)} | no_more. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 39). -spec stop() -> action(any()). stop() -> stop. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 75). -spec unfold_loop(DSM, fun((DSM) -> step(DSN, DSM))) -> fun(() -> action(DSN)). unfold_loop(Initial, F) -> fun() -> case F(Initial) of {next, X, Acc} -> {continue, X, unfold_loop(Acc, F)}; done -> stop end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 65). -spec unfold(DSH, fun((DSH) -> step(DSI, DSH))) -> iterator(DSI). unfold(Initial, F) -> _pipe = Initial, _pipe@1 = unfold_loop(_pipe, F), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 98). -spec repeatedly(fun(() -> DSR)) -> iterator(DSR). repeatedly(F) -> unfold(nil, fun(_) -> {next, F(), nil} end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 114). -spec repeat(DST) -> iterator(DST). repeat(X) -> repeatedly(fun() -> X end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 129). -spec from_list(list(DSV)) -> iterator(DSV). from_list(List) -> Yield = fun(Acc) -> case Acc of [] -> done; [Head | Tail] -> {next, Head, Tail} end end, unfold(List, Yield). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 140). -spec transform_loop( fun(() -> action(DSY)), DTA, fun((DTA, DSY) -> step(DTB, DTA)) ) -> fun(() -> action(DTB)). transform_loop(Continuation, State, F) -> fun() -> case Continuation() of stop -> stop; {continue, El, Next} -> case F(State, El) of done -> stop; {next, Yield, Next_state} -> {continue, Yield, transform_loop(Next, Next_state, F)} end end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 176). -spec transform(iterator(DTF), DTH, fun((DTH, DTF) -> step(DTI, DTH))) -> iterator(DTI). transform(Iterator, Initial, F) -> _pipe = transform_loop(erlang:element(2, Iterator), Initial, F), {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 212). -spec fold_loop(fun(() -> action(DTP)), fun((DTR, DTP) -> DTR), DTR) -> DTR. fold_loop(Continuation, F, Accumulator) -> case Continuation() of {continue, Elem, Next} -> fold_loop(Next, F, F(Accumulator, Elem)); stop -> Accumulator end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 203). -spec fold(iterator(DTM), DTO, fun((DTO, DTM) -> DTO)) -> DTO. fold(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), fold_loop(_pipe, F, Initial). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 229). -spec run(iterator(any())) -> nil. run(Iterator) -> fold(Iterator, nil, fun(_, _) -> nil end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 248). -spec to_list(iterator(DTU)) -> list(DTU). to_list(Iterator) -> _pipe = Iterator, _pipe@1 = fold(_pipe, [], fun(Acc, E) -> [E | Acc] end), lists:reverse(_pipe@1). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 277). -spec step(iterator(DTX)) -> step(DTX, iterator(DTX)). step(Iterator) -> case (erlang:element(2, Iterator))() of stop -> done; {continue, E, A} -> {next, E, {iterator, A}} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 311). -spec take_loop(fun(() -> action(DUF)), integer()) -> fun(() -> action(DUF)). take_loop(Continuation, Desired) -> fun() -> case Desired > 0 of false -> stop; true -> case Continuation() of stop -> stop; {continue, E, Next} -> {continue, E, take_loop(Next, Desired - 1)} end end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 305). -spec take(iterator(DUC), integer()) -> iterator(DUC). take(Iterator, Desired) -> _pipe = erlang:element(2, Iterator), _pipe@1 = take_loop(_pipe, Desired), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 355). -spec drop_loop(fun(() -> action(DUL)), integer()) -> action(DUL). drop_loop(Continuation, Desired) -> case Continuation() of stop -> stop; {continue, E, Next} -> case Desired > 0 of true -> drop_loop(Next, Desired - 1); false -> {continue, E, Next} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 350). -spec drop(iterator(DUI), integer()) -> iterator(DUI). drop(Iterator, Desired) -> _pipe = fun() -> drop_loop(erlang:element(2, Iterator), Desired) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 390). -spec map_loop(fun(() -> action(DUS)), fun((DUS) -> DUU)) -> fun(() -> action(DUU)). map_loop(Continuation, F) -> fun() -> case Continuation() of stop -> stop; {continue, E, Continuation@1} -> {continue, F(E), map_loop(Continuation@1, F)} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 384). -spec map(iterator(DUO), fun((DUO) -> DUQ)) -> iterator(DUQ). map(Iterator, F) -> _pipe = erlang:element(2, Iterator), _pipe@1 = map_loop(_pipe, F), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 432). -spec map2_loop( fun(() -> action(DVC)), fun(() -> action(DVE)), fun((DVC, DVE) -> DVG) ) -> fun(() -> action(DVG)). map2_loop(Continuation1, Continuation2, Fun) -> fun() -> case Continuation1() of stop -> stop; {continue, A, Next_a} -> case Continuation2() of stop -> stop; {continue, B, Next_b} -> {continue, Fun(A, B), map2_loop(Next_a, Next_b, Fun)} end end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 423). -spec map2(iterator(DUW), iterator(DUY), fun((DUW, DUY) -> DVA)) -> iterator(DVA). map2(Iterator1, Iterator2, Fun) -> _pipe = map2_loop( erlang:element(2, Iterator1), erlang:element(2, Iterator2), Fun ), {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 470). -spec append_loop(fun(() -> action(DVM)), fun(() -> action(DVM))) -> action(DVM). append_loop(First, Second) -> case First() of {continue, E, First@1} -> {continue, E, fun() -> append_loop(First@1, Second) end}; stop -> Second() end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 465). -spec append(iterator(DVI), iterator(DVI)) -> iterator(DVI). append(First, Second) -> _pipe = fun() -> append_loop(erlang:element(2, First), erlang:element(2, Second)) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 498). -spec flatten_loop(fun(() -> action(iterator(DVU)))) -> action(DVU). flatten_loop(Flattened) -> case Flattened() of stop -> stop; {continue, It, Next_iterator} -> append_loop( erlang:element(2, It), fun() -> flatten_loop(Next_iterator) end ) end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 493). -spec flatten(iterator(iterator(DVQ))) -> iterator(DVQ). flatten(Iterator) -> _pipe = fun() -> flatten_loop(erlang:element(2, Iterator)) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 522). -spec concat(list(iterator(DVY))) -> iterator(DVY). concat(Iterators) -> flatten(from_list(Iterators)). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 545). -spec flat_map(iterator(DWC), fun((DWC) -> iterator(DWE))) -> iterator(DWE). flat_map(Iterator, F) -> _pipe = Iterator, _pipe@1 = map(_pipe, F), flatten(_pipe@1). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 582). -spec filter_loop(fun(() -> action(DWK)), fun((DWK) -> boolean())) -> action(DWK). filter_loop(Continuation, Predicate) -> case Continuation() of stop -> stop; {continue, E, Iterator} -> case Predicate(E) of true -> {continue, E, fun() -> filter_loop(Iterator, Predicate) end}; false -> filter_loop(Iterator, Predicate) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 574). -spec filter(iterator(DWH), fun((DWH) -> boolean())) -> iterator(DWH). filter(Iterator, Predicate) -> _pipe = fun() -> filter_loop(erlang:element(2, Iterator), Predicate) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 626). -spec filter_map_loop( fun(() -> action(DWU)), fun((DWU) -> {ok, DWW} | {error, any()}) ) -> action(DWW). filter_map_loop(Continuation, F) -> case Continuation() of stop -> stop; {continue, E, Next} -> case F(E) of {ok, E@1} -> {continue, E@1, fun() -> filter_map_loop(Next, F) end}; {error, _} -> filter_map_loop(Next, F) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 618). -spec filter_map(iterator(DWN), fun((DWN) -> {ok, DWP} | {error, any()})) -> iterator(DWP). filter_map(Iterator, F) -> _pipe = fun() -> filter_map_loop(erlang:element(2, Iterator), F) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 653). -spec cycle(iterator(DXB)) -> iterator(DXB). cycle(Iterator) -> _pipe = repeat(Iterator), flatten(_pipe). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 732). -spec find_loop(fun(() -> action(DXJ)), fun((DXJ) -> boolean())) -> {ok, DXJ} | {error, nil}. find_loop(Continuation, F) -> case Continuation() of stop -> {error, nil}; {continue, E, Next} -> case F(E) of true -> {ok, E}; false -> find_loop(Next, F) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 724). -spec find(iterator(DXF), fun((DXF) -> boolean())) -> {ok, DXF} | {error, nil}. find(Haystack, Is_desired) -> _pipe = erlang:element(2, Haystack), find_loop(_pipe, Is_desired). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 778). -spec find_map_loop( fun(() -> action(DXV)), fun((DXV) -> {ok, DXX} | {error, any()}) ) -> {ok, DXX} | {error, nil}. find_map_loop(Continuation, F) -> case Continuation() of stop -> {error, nil}; {continue, E, Next} -> case F(E) of {ok, E@1} -> {ok, E@1}; {error, _} -> find_map_loop(Next, F) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 770). -spec find_map(iterator(DXN), fun((DXN) -> {ok, DXP} | {error, any()})) -> {ok, DXP} | {error, nil}. find_map(Haystack, Is_desired) -> _pipe = erlang:element(2, Haystack), find_map_loop(_pipe, Is_desired). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 808). -spec index_loop(fun(() -> action(DYG)), integer()) -> fun(() -> action({DYG, integer()})). index_loop(Continuation, Next) -> fun() -> case Continuation() of stop -> stop; {continue, E, Continuation@1} -> {continue, {E, Next}, index_loop(Continuation@1, Next + 1)} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 802). -spec index(iterator(DYD)) -> iterator({DYD, integer()}). index(Iterator) -> _pipe = erlang:element(2, Iterator), _pipe@1 = index_loop(_pipe, 0), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 831). -spec iterate(DYJ, fun((DYJ) -> DYJ)) -> iterator(DYJ). iterate(Initial, F) -> unfold(Initial, fun(Element) -> {next, Element, F(Element)} end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 859). -spec take_while_loop(fun(() -> action(DYO)), fun((DYO) -> boolean())) -> fun(() -> action(DYO)). take_while_loop(Continuation, Predicate) -> fun() -> case Continuation() of stop -> stop; {continue, E, Next} -> case Predicate(E) of false -> stop; true -> {continue, E, take_while_loop(Next, Predicate)} end end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 850). -spec take_while(iterator(DYL), fun((DYL) -> boolean())) -> iterator(DYL). take_while(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), _pipe@1 = take_while_loop(_pipe, Predicate), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 896). -spec drop_while_loop(fun(() -> action(DYU)), fun((DYU) -> boolean())) -> action(DYU). drop_while_loop(Continuation, Predicate) -> case Continuation() of stop -> stop; {continue, E, Next} -> case Predicate(E) of false -> {continue, E, Next}; true -> drop_while_loop(Next, Predicate) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 888). -spec drop_while(iterator(DYR), fun((DYR) -> boolean())) -> iterator(DYR). drop_while(Iterator, Predicate) -> _pipe = fun() -> drop_while_loop(erlang:element(2, Iterator), Predicate) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 935). -spec scan_loop(fun(() -> action(DZB)), fun((DZD, DZB) -> DZD), DZD) -> fun(() -> action(DZD)). scan_loop(Continuation, F, Accumulator) -> fun() -> case Continuation() of stop -> stop; {continue, El, Next} -> Accumulated = F(Accumulator, El), {continue, Accumulated, scan_loop(Next, F, Accumulated)} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 925). -spec scan(iterator(DYX), DYZ, fun((DYZ, DYX) -> DYZ)) -> iterator(DYZ). scan(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), _pipe@1 = scan_loop(_pipe, F, Initial), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 969). -spec zip_loop(fun(() -> action(DZK)), fun(() -> action(DZM))) -> fun(() -> action({DZK, DZM})). zip_loop(Left, Right) -> fun() -> case Left() of stop -> stop; {continue, El_left, Next_left} -> case Right() of stop -> stop; {continue, El_right, Next_right} -> {continue, {El_left, El_right}, zip_loop(Next_left, Next_right)} end end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 964). -spec zip(iterator(DZF), iterator(DZH)) -> iterator({DZF, DZH}). zip(Left, Right) -> _pipe = zip_loop(erlang:element(2, Left), erlang:element(2, Right)), {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1031). -spec next_chunk(fun(() -> action(DZZ)), fun((DZZ) -> EAB), EAB, list(DZZ)) -> chunk(DZZ, EAB). next_chunk(Continuation, F, Previous_key, Current_chunk) -> case Continuation() of stop -> {last_by, lists:reverse(Current_chunk)}; {continue, E, Next} -> Key = F(E), case Key =:= Previous_key of true -> next_chunk(Next, F, Key, [E | Current_chunk]); false -> {another_by, lists:reverse(Current_chunk), Key, E, Next} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1018). -spec chunk_loop(fun(() -> action(DZU)), fun((DZU) -> DZW), DZW, DZU) -> action(list(DZU)). chunk_loop(Continuation, F, Previous_key, Previous_element) -> case next_chunk(Continuation, F, Previous_key, [Previous_element]) of {last_by, Chunk} -> {continue, Chunk, fun stop/0}; {another_by, Chunk@1, Key, El, Next} -> {continue, Chunk@1, fun() -> chunk_loop(Next, F, Key, El) end} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1005). -spec chunk(iterator(DZP), fun((DZP) -> any())) -> iterator(list(DZP)). chunk(Iterator, F) -> _pipe = fun() -> case (erlang:element(2, Iterator))() of stop -> stop; {continue, E, Next} -> chunk_loop(Next, F, F(E), E) end end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1103). -spec next_sized_chunk(fun(() -> action(EAN)), integer(), list(EAN)) -> sized_chunk(EAN). next_sized_chunk(Continuation, Left, Current_chunk) -> case Continuation() of stop -> case Current_chunk of [] -> no_more; Remaining -> {last, lists:reverse(Remaining)} end; {continue, E, Next} -> Chunk = [E | Current_chunk], case Left > 1 of false -> {another, lists:reverse(Chunk), Next}; true -> next_sized_chunk(Next, Left - 1, Chunk) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1082). -spec sized_chunk_loop(fun(() -> action(EAJ)), integer()) -> fun(() -> action(list(EAJ))). sized_chunk_loop(Continuation, Count) -> fun() -> case next_sized_chunk(Continuation, Count, []) of no_more -> stop; {last, Chunk} -> {continue, Chunk, fun stop/0}; {another, Chunk@1, Next_element} -> {continue, Chunk@1, sized_chunk_loop(Next_element, Count)} end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1073). -spec sized_chunk(iterator(EAF), integer()) -> iterator(list(EAF)). sized_chunk(Iterator, Count) -> _pipe = erlang:element(2, Iterator), _pipe@1 = sized_chunk_loop(_pipe, Count), {iterator, _pipe@1}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1164). -spec intersperse_loop(fun(() -> action(EAU)), EAU) -> action(EAU). intersperse_loop(Continuation, Separator) -> case Continuation() of stop -> stop; {continue, E, Next} -> Next_interspersed = fun() -> intersperse_loop(Next, Separator) end, {continue, Separator, fun() -> {continue, E, Next_interspersed} end} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1151). -spec intersperse(iterator(EAR), EAR) -> iterator(EAR). intersperse(Iterator, Elem) -> _pipe = fun() -> case (erlang:element(2, Iterator))() of stop -> stop; {continue, E, Next} -> {continue, E, fun() -> intersperse_loop(Next, Elem) end} end end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1213). -spec any_loop(fun(() -> action(EAZ)), fun((EAZ) -> boolean())) -> boolean(). any_loop(Continuation, Predicate) -> case Continuation() of stop -> false; {continue, E, Next} -> case Predicate(E) of true -> true; false -> any_loop(Next, Predicate) end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1205). -spec any(iterator(EAX), fun((EAX) -> boolean())) -> boolean(). any(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), any_loop(_pipe, Predicate). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1263). -spec all_loop(fun(() -> action(EBD)), fun((EBD) -> boolean())) -> boolean(). all_loop(Continuation, Predicate) -> case Continuation() of stop -> true; {continue, E, Next} -> case Predicate(E) of true -> all_loop(Next, Predicate); false -> false end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1255). -spec all(iterator(EBB), fun((EBB) -> boolean())) -> boolean(). all(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), all_loop(_pipe, Predicate). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1309). -spec update_group_with(EBT) -> fun((gleam@option:option(list(EBT))) -> list(EBT)). update_group_with(El) -> fun(Maybe_group) -> case Maybe_group of {some, Group} -> [El | Group]; none -> [El] end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1300). -spec group_updater(fun((EBL) -> EBM)) -> fun((gleam@dict:dict(EBM, list(EBL)), EBL) -> gleam@dict:dict(EBM, list(EBL))). group_updater(F) -> fun(Groups, Elem) -> _pipe = Groups, gleam@dict:upsert(_pipe, F(Elem), update_group_with(Elem)) end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1291). -spec group(iterator(EBF), fun((EBF) -> EBH)) -> gleam@dict:dict(EBH, list(EBF)). group(Iterator, Key) -> _pipe = Iterator, _pipe@1 = fold(_pipe, maps:new(), group_updater(Key)), gleam@dict:map_values(_pipe@1, fun(_, Group) -> lists:reverse(Group) end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1340). -spec reduce(iterator(EBX), fun((EBX, EBX) -> EBX)) -> {ok, EBX} | {error, nil}. reduce(Iterator, F) -> case (erlang:element(2, Iterator))() of stop -> {error, nil}; {continue, E, Next} -> _pipe = fold_loop(Next, F, E), {ok, _pipe} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1371). -spec last(iterator(ECB)) -> {ok, ECB} | {error, nil}. last(Iterator) -> _pipe = Iterator, reduce(_pipe, fun(_, Elem) -> Elem end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1386). -spec empty() -> iterator(any()). empty() -> {iterator, fun stop/0}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1400). -spec once(fun(() -> ECH)) -> iterator(ECH). once(F) -> _pipe = fun() -> {continue, F(), fun stop/0} end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 679). -spec range(integer(), integer()) -> iterator(integer()). range(Start, Stop) -> case gleam@int:compare(Start, Stop) of eq -> once(fun() -> Start end); gt -> unfold(Start, fun(Current) -> case Current < Stop of false -> {next, Current, Current - 1}; true -> done end end); lt -> unfold(Start, fun(Current@1) -> case Current@1 > Stop of false -> {next, Current@1, Current@1 + 1}; true -> done end end) end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1415). -spec single(ECJ) -> iterator(ECJ). single(Elem) -> once(fun() -> Elem end). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1447). -spec interleave_loop(fun(() -> action(ECP)), fun(() -> action(ECP))) -> action(ECP). interleave_loop(Current, Next) -> case Current() of stop -> Next(); {continue, E, Next_other} -> {continue, E, fun() -> interleave_loop(Next, Next_other) end} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1439). -spec interleave(iterator(ECL), iterator(ECL)) -> iterator(ECL). interleave(Left, Right) -> _pipe = fun() -> interleave_loop(erlang:element(2, Left), erlang:element(2, Right)) end, {iterator, _pipe}. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1492). -spec fold_until_loop( fun(() -> action(ECX)), fun((ECZ, ECX) -> gleam@list:continue_or_stop(ECZ)), ECZ ) -> ECZ. fold_until_loop(Continuation, F, Accumulator) -> case Continuation() of stop -> Accumulator; {continue, Elem, Next} -> case F(Accumulator, Elem) of {continue, Accumulator@1} -> fold_until_loop(Next, F, Accumulator@1); {stop, Accumulator@2} -> Accumulator@2 end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1483). -spec fold_until( iterator(ECT), ECV, fun((ECV, ECT) -> gleam@list:continue_or_stop(ECV)) ) -> ECV. fold_until(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), fold_until_loop(_pipe, F, Initial). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1536). -spec try_fold_loop( fun(() -> action(EDJ)), fun((EDL, EDJ) -> {ok, EDL} | {error, EDM}), EDL ) -> {ok, EDL} | {error, EDM}. try_fold_loop(Continuation, F, Accumulator) -> case Continuation() of stop -> {ok, Accumulator}; {continue, Elem, Next} -> case F(Accumulator, Elem) of {ok, Result} -> try_fold_loop(Next, F, Result); {error, _} = Error -> Error end end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1527). -spec try_fold(iterator(EDB), EDD, fun((EDD, EDB) -> {ok, EDD} | {error, EDE})) -> {ok, EDD} | {error, EDE}. try_fold(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), try_fold_loop(_pipe, F, Initial). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1567). -spec first(iterator(EDR)) -> {ok, EDR} | {error, nil}. first(Iterator) -> case (erlang:element(2, Iterator))() of stop -> {error, nil}; {continue, E, _} -> {ok, E} end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1598). -spec at(iterator(EDV), integer()) -> {ok, EDV} | {error, nil}. at(Iterator, Index) -> _pipe = Iterator, _pipe@1 = drop(_pipe, Index), first(_pipe@1). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1627). -spec length_loop(fun(() -> action(any())), integer()) -> integer(). length_loop(Continuation, Length) -> case Continuation() of stop -> Length; {continue, _, Next} -> length_loop(Next, Length + 1) end. -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1622). -spec length(iterator(any())) -> integer(). length(Iterator) -> _pipe = erlang:element(2, Iterator), length_loop(_pipe, 0). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1652). -spec each(iterator(EED), fun((EED) -> any())) -> nil. each(Iterator, F) -> _pipe = Iterator, _pipe@1 = map(_pipe, F), run(_pipe@1). -file("/Users/louis/src/gleam/stdlib/src/gleam/iterator.gleam", 1678). -spec yield(EEG, fun(() -> iterator(EEG))) -> iterator(EEG). yield(Element, Next) -> {iterator, fun() -> {continue, Element, fun() -> (erlang:element(2, Next()))() end} end}.