-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, 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(BSY) :: stop | {continue, BSY, fun(() -> action(BSY))}. -opaque iterator(BSZ) :: {iterator, fun(() -> action(BSZ))}. -type step(BTA, BTB) :: {next, BTA, BTB} | done. -type chunk(BTC, BTD) :: {another_by, list(BTC), BTD, BTC, fun(() -> action(BTC))} | {last_by, list(BTC)}. -type sized_chunk(BTE) :: {another, list(BTE), fun(() -> action(BTE))} | {last, list(BTE)} | no_more. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 38). -spec stop() -> action(any()). stop() -> stop. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 43). -spec do_unfold(BTH, fun((BTH) -> step(BTI, BTH))) -> fun(() -> action(BTI)). do_unfold(Initial, F) -> fun() -> case F(Initial) of {next, X, Acc} -> {continue, X, do_unfold(Acc, F)}; done -> stop end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 76). -spec unfold(BTM, fun((BTM) -> step(BTN, BTM))) -> iterator(BTN). unfold(Initial, F) -> _pipe = Initial, _pipe@1 = do_unfold(_pipe, F), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 89). -spec repeatedly(fun(() -> BTR)) -> iterator(BTR). repeatedly(F) -> unfold(nil, fun(_) -> {next, F(), nil} end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 104). -spec repeat(BTT) -> iterator(BTT). repeat(X) -> repeatedly(fun() -> X end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 118). -spec from_list(list(BTV)) -> iterator(BTV). from_list(List) -> Yield = fun(Acc) -> case Acc of [] -> done; [Head | Tail] -> {next, Head, Tail} end end, unfold(List, Yield). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 129). -spec do_transform( fun(() -> action(BTY)), BUA, fun((BUA, BTY) -> step(BUB, BUA)) ) -> fun(() -> action(BUB)). do_transform(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, do_transform(Next, Next_state, F)} end end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 164). -spec transform(iterator(BUF), BUH, fun((BUH, BUF) -> step(BUI, BUH))) -> iterator(BUI). transform(Iterator, Initial, F) -> _pipe = do_transform(erlang:element(2, Iterator), Initial, F), {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 173). -spec do_fold(fun(() -> action(BUM)), fun((BUO, BUM) -> BUO), BUO) -> BUO. do_fold(Continuation, F, Accumulator) -> case Continuation() of {continue, Elem, Next} -> do_fold(Next, F, F(Accumulator, Elem)); stop -> Accumulator end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 201). -spec fold(iterator(BUP), BUR, fun((BUR, BUP) -> BUR)) -> BUR. fold(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), do_fold(_pipe, F, Initial). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 215). -spec run(iterator(any())) -> nil. run(Iterator) -> fold(Iterator, nil, fun(_, _) -> nil end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 233). -spec to_list(iterator(BUU)) -> list(BUU). to_list(Iterator) -> _pipe = Iterator, _pipe@1 = fold(_pipe, [], fun(Acc, E) -> [E | Acc] end), lists:reverse(_pipe@1). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 261). -spec step(iterator(BUX)) -> step(BUX, iterator(BUX)). step(Iterator) -> case (erlang:element(2, Iterator))() of stop -> done; {continue, E, A} -> {next, E, {iterator, A}} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 268). -spec do_take(fun(() -> action(BVC)), integer()) -> fun(() -> action(BVC)). do_take(Continuation, Desired) -> fun() -> case Desired > 0 of false -> stop; true -> case Continuation() of stop -> stop; {continue, E, Next} -> {continue, E, do_take(Next, Desired - 1)} end end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 301). -spec take(iterator(BVF), integer()) -> iterator(BVF). take(Iterator, Desired) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_take(_pipe, Desired), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 307). -spec do_drop(fun(() -> action(BVI)), integer()) -> action(BVI). do_drop(Continuation, Desired) -> case Continuation() of stop -> stop; {continue, E, Next} -> case Desired > 0 of true -> do_drop(Next, Desired - 1); false -> {continue, E, Next} end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 343). -spec drop(iterator(BVL), integer()) -> iterator(BVL). drop(Iterator, Desired) -> _pipe = fun() -> do_drop(erlang:element(2, Iterator), Desired) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 348). -spec do_map(fun(() -> action(BVO)), fun((BVO) -> BVQ)) -> fun(() -> action(BVQ)). do_map(Continuation, F) -> fun() -> case Continuation() of stop -> stop; {continue, E, Continuation@1} -> {continue, F(E), do_map(Continuation@1, F)} end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 374). -spec map(iterator(BVS), fun((BVS) -> BVU)) -> iterator(BVU). map(Iterator, F) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_map(_pipe, F), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 380). -spec do_map2( fun(() -> action(BVW)), fun(() -> action(BVY)), fun((BVW, BVY) -> BWA) ) -> fun(() -> action(BWA)). do_map2(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), do_map2(Next_a, Next_b, Fun)} end end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 421). -spec map2(iterator(BWC), iterator(BWE), fun((BWC, BWE) -> BWG)) -> iterator(BWG). map2(Iterator1, Iterator2, Fun) -> _pipe = do_map2( erlang:element(2, Iterator1), erlang:element(2, Iterator2), Fun ), {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 430). -spec do_append(fun(() -> action(BWI)), fun(() -> action(BWI))) -> action(BWI). do_append(First, Second) -> case First() of {continue, E, First@1} -> {continue, E, fun() -> do_append(First@1, Second) end}; stop -> Second() end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 451). -spec append(iterator(BWM), iterator(BWM)) -> iterator(BWM). append(First, Second) -> _pipe = fun() -> do_append(erlang:element(2, First), erlang:element(2, Second)) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 456). -spec do_flatten(fun(() -> action(iterator(BWQ)))) -> action(BWQ). do_flatten(Flattened) -> case Flattened() of stop -> stop; {continue, It, Next_iterator} -> do_append( erlang:element(2, It), fun() -> do_flatten(Next_iterator) end ) end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 479). -spec flatten(iterator(iterator(BWU))) -> iterator(BWU). flatten(Iterator) -> _pipe = fun() -> do_flatten(erlang:element(2, Iterator)) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 499). -spec concat(list(iterator(BWY))) -> iterator(BWY). concat(Iterators) -> flatten(from_list(Iterators)). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 521). -spec flat_map(iterator(BXC), fun((BXC) -> iterator(BXE))) -> iterator(BXE). flat_map(Iterator, F) -> _pipe = Iterator, _pipe@1 = map(_pipe, F), flatten(_pipe@1). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 530). -spec do_filter(fun(() -> action(BXH)), fun((BXH) -> boolean())) -> action(BXH). do_filter(Continuation, Predicate) -> case Continuation() of stop -> stop; {continue, E, Iterator} -> case Predicate(E) of true -> {continue, E, fun() -> do_filter(Iterator, Predicate) end}; false -> do_filter(Iterator, Predicate) end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 562). -spec filter(iterator(BXK), fun((BXK) -> boolean())) -> iterator(BXK). filter(Iterator, Predicate) -> _pipe = fun() -> do_filter(erlang:element(2, Iterator), Predicate) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 570). -spec do_filter_map( fun(() -> action(BXN)), fun((BXN) -> {ok, BXP} | {error, any()}) ) -> action(BXP). do_filter_map(Continuation, F) -> case Continuation() of stop -> stop; {continue, E, Next} -> case F(E) of {ok, E@1} -> {continue, E@1, fun() -> do_filter_map(Next, F) end}; {error, _} -> do_filter_map(Next, F) end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 605). -spec filter_map(iterator(BXU), fun((BXU) -> {ok, BXW} | {error, any()})) -> iterator(BXW). filter_map(Iterator, F) -> _pipe = fun() -> do_filter_map(erlang:element(2, Iterator), F) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 625). -spec cycle(iterator(BYB)) -> iterator(BYB). cycle(Iterator) -> _pipe = repeat(Iterator), flatten(_pipe). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 671). -spec do_find(fun(() -> action(BYF)), fun((BYF) -> boolean())) -> {ok, BYF} | {error, nil}. do_find(Continuation, F) -> case Continuation() of stop -> {error, nil}; {continue, E, Next} -> case F(E) of true -> {ok, E}; false -> do_find(Next, F) end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 705). -spec find(iterator(BYJ), fun((BYJ) -> boolean())) -> {ok, BYJ} | {error, nil}. find(Haystack, Is_desired) -> _pipe = erlang:element(2, Haystack), do_find(_pipe, Is_desired). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 713). -spec do_index(fun(() -> action(BYN)), integer()) -> fun(() -> action({BYN, integer()})). do_index(Continuation, Next) -> fun() -> case Continuation() of stop -> stop; {continue, E, Continuation@1} -> {continue, {E, Next}, do_index(Continuation@1, Next + 1)} end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 735). -spec index(iterator(BYQ)) -> iterator({BYQ, integer()}). index(Iterator) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_index(_pipe, 0), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 750). -spec iterate(BYT, fun((BYT) -> BYT)) -> iterator(BYT). iterate(Initial, F) -> unfold(Initial, fun(Element) -> {next, Element, F(Element)} end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 757). -spec do_take_while(fun(() -> action(BYV)), fun((BYV) -> boolean())) -> fun(() -> action(BYV)). do_take_while(Continuation, Predicate) -> fun() -> case Continuation() of stop -> stop; {continue, E, Next} -> case Predicate(E) of false -> stop; true -> {continue, E, do_take_while(Next, Predicate)} end end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 784). -spec take_while(iterator(BYY), fun((BYY) -> boolean())) -> iterator(BYY). take_while(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_take_while(_pipe, Predicate), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 793). -spec do_drop_while(fun(() -> action(BZB)), fun((BZB) -> boolean())) -> action(BZB). do_drop_while(Continuation, Predicate) -> case Continuation() of stop -> stop; {continue, E, Next} -> case Predicate(E) of false -> {continue, E, Next}; true -> do_drop_while(Next, Predicate) end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 819). -spec drop_while(iterator(BZE), fun((BZE) -> boolean())) -> iterator(BZE). drop_while(Iterator, Predicate) -> _pipe = fun() -> do_drop_while(erlang:element(2, Iterator), Predicate) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 827). -spec do_scan(fun(() -> action(BZH)), fun((BZJ, BZH) -> BZJ), BZJ) -> fun(() -> action(BZJ)). do_scan(Continuation, F, Accumulator) -> fun() -> case Continuation() of stop -> stop; {continue, El, Next} -> Accumulated = F(Accumulator, El), {continue, Accumulated, do_scan(Next, F, Accumulated)} end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 857). -spec scan(iterator(BZL), BZN, fun((BZN, BZL) -> BZN)) -> iterator(BZN). scan(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_scan(_pipe, F, Initial), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 867). -spec do_zip(fun(() -> action(BZP)), fun(() -> action(BZR))) -> fun(() -> action({BZP, BZR})). do_zip(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}, do_zip(Next_left, Next_right)} end end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 896). -spec zip(iterator(BZU), iterator(BZW)) -> iterator({BZU, BZW}). zip(Left, Right) -> _pipe = do_zip(erlang:element(2, Left), erlang:element(2, Right)), {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 907). -spec next_chunk(fun(() -> action(BZZ)), fun((BZZ) -> CAB), CAB, list(BZZ)) -> chunk(BZZ, CAB). 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("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 925). -spec do_chunk(fun(() -> action(CAF)), fun((CAF) -> CAH), CAH, CAF) -> action(list(CAF)). do_chunk(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() -> do_chunk(Next, F, Key, El) end} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 950). -spec chunk(iterator(CAK), fun((CAK) -> any())) -> iterator(list(CAK)). chunk(Iterator, F) -> _pipe = fun() -> case (erlang:element(2, Iterator))() of stop -> stop; {continue, E, Next} -> do_chunk(Next, F, F(E), E) end end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 970). -spec next_sized_chunk(fun(() -> action(CAP)), integer(), list(CAP)) -> sized_chunk(CAP). 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("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 991). -spec do_sized_chunk(fun(() -> action(CAT)), integer()) -> fun(() -> action(list(CAT))). do_sized_chunk(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, do_sized_chunk(Next_element, Count)} end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1028). -spec sized_chunk(iterator(CAX), integer()) -> iterator(list(CAX)). sized_chunk(Iterator, Count) -> _pipe = erlang:element(2, Iterator), _pipe@1 = do_sized_chunk(_pipe, Count), {iterator, _pipe@1}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1037). -spec do_intersperse(fun(() -> action(CBB)), CBB) -> action(CBB). do_intersperse(Continuation, Separator) -> case Continuation() of stop -> stop; {continue, E, Next} -> Next_interspersed = fun() -> do_intersperse(Next, Separator) end, {continue, Separator, fun() -> {continue, E, Next_interspersed} end} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1076). -spec intersperse(iterator(CBE), CBE) -> iterator(CBE). intersperse(Iterator, Elem) -> _pipe = fun() -> case (erlang:element(2, Iterator))() of stop -> stop; {continue, E, Next} -> {continue, E, fun() -> do_intersperse(Next, Elem) end} end end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1089). -spec do_any(fun(() -> action(CBH)), fun((CBH) -> boolean())) -> boolean(). do_any(Continuation, Predicate) -> case Continuation() of stop -> false; {continue, E, Next} -> case Predicate(E) of true -> true; false -> do_any(Next, Predicate) end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1130). -spec any(iterator(CBJ), fun((CBJ) -> boolean())) -> boolean(). any(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), do_any(_pipe, Predicate). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1138). -spec do_all(fun(() -> action(CBL)), fun((CBL) -> boolean())) -> boolean(). do_all(Continuation, Predicate) -> case Continuation() of stop -> true; {continue, E, Next} -> case Predicate(E) of true -> do_all(Next, Predicate); false -> false end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1179). -spec all(iterator(CBN), fun((CBN) -> boolean())) -> boolean(). all(Iterator, Predicate) -> _pipe = erlang:element(2, Iterator), do_all(_pipe, Predicate). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1187). -spec update_group_with(CBP) -> fun((gleam@option:option(list(CBP))) -> list(CBP)). update_group_with(El) -> fun(Maybe_group) -> case Maybe_group of {some, Group} -> [El | Group]; none -> [El] end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1196). -spec group_updater(fun((CBT) -> CBU)) -> fun((gleam@dict:dict(CBU, list(CBT)), CBT) -> gleam@dict:dict(CBU, list(CBT))). group_updater(F) -> fun(Groups, Elem) -> _pipe = Groups, gleam@dict:update(_pipe, F(Elem), update_group_with(Elem)) end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1218). -spec group(iterator(CCB), fun((CCB) -> CCD)) -> gleam@dict:dict(CCD, list(CCB)). group(Iterator, Key) -> _pipe = Iterator, _pipe@1 = fold(_pipe, gleam@dict:new(), group_updater(Key)), gleam@dict:map_values(_pipe@1, fun(_, Group) -> lists:reverse(Group) end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1248). -spec reduce(iterator(CCH), fun((CCH, CCH) -> CCH)) -> {ok, CCH} | {error, nil}. reduce(Iterator, F) -> case (erlang:element(2, Iterator))() of stop -> {error, nil}; {continue, E, Next} -> _pipe = do_fold(Next, F, E), {ok, _pipe} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1278). -spec last(iterator(CCL)) -> {ok, CCL} | {error, nil}. last(Iterator) -> _pipe = Iterator, reduce(_pipe, fun(_, Elem) -> Elem end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1292). -spec empty() -> iterator(any()). empty() -> {iterator, fun stop/0}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1305). -spec once(fun(() -> CCR)) -> iterator(CCR). once(F) -> _pipe = fun() -> {continue, F(), fun stop/0} end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 650). -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("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1319). -spec single(CCT) -> iterator(CCT). single(Elem) -> once(fun() -> Elem end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1323). -spec do_interleave(fun(() -> action(CCV)), fun(() -> action(CCV))) -> action(CCV). do_interleave(Current, Next) -> case Current() of stop -> Next(); {continue, E, Next_other} -> {continue, E, fun() -> do_interleave(Next, Next_other) end} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1353). -spec interleave(iterator(CCZ), iterator(CCZ)) -> iterator(CCZ). interleave(Left, Right) -> _pipe = fun() -> do_interleave(erlang:element(2, Left), erlang:element(2, Right)) end, {iterator, _pipe}. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1361). -spec do_fold_until( fun(() -> action(CDD)), fun((CDF, CDD) -> gleam@list:continue_or_stop(CDF)), CDF ) -> CDF. do_fold_until(Continuation, F, Accumulator) -> case Continuation() of stop -> Accumulator; {continue, Elem, Next} -> case F(Accumulator, Elem) of {continue, Accumulator@1} -> do_fold_until(Next, F, Accumulator@1); {stop, Accumulator@2} -> Accumulator@2 end end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1400). -spec fold_until( iterator(CDH), CDJ, fun((CDJ, CDH) -> gleam@list:continue_or_stop(CDJ)) ) -> CDJ. fold_until(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), do_fold_until(_pipe, F, Initial). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1409). -spec do_try_fold( fun(() -> action(CDL)), fun((CDN, CDL) -> {ok, CDN} | {error, CDO}), CDN ) -> {ok, CDN} | {error, CDO}. do_try_fold(Continuation, F, Accumulator) -> case Continuation() of stop -> {ok, Accumulator}; {continue, Elem, Next} -> gleam@result:'try'( F(Accumulator, Elem), fun(Accumulator@1) -> do_try_fold(Next, F, Accumulator@1) end ) end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1442). -spec try_fold(iterator(CDT), CDV, fun((CDV, CDT) -> {ok, CDV} | {error, CDW})) -> {ok, CDV} | {error, CDW}. try_fold(Iterator, Initial, F) -> _pipe = erlang:element(2, Iterator), do_try_fold(_pipe, F, Initial). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1465). -spec first(iterator(CEB)) -> {ok, CEB} | {error, nil}. first(Iterator) -> case (erlang:element(2, Iterator))() of stop -> {error, nil}; {continue, E, _} -> {ok, E} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1495). -spec at(iterator(CEF), integer()) -> {ok, CEF} | {error, nil}. at(Iterator, Index) -> _pipe = Iterator, _pipe@1 = drop(_pipe, Index), first(_pipe@1). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1501). -spec do_length(fun(() -> action(any())), integer()) -> integer(). do_length(Continuation, Length) -> case Continuation() of stop -> Length; {continue, _, Next} -> do_length(Next, Length + 1) end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1525). -spec length(iterator(any())) -> integer(). length(Iterator) -> _pipe = erlang:element(2, Iterator), do_length(_pipe, 0). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1547). -spec each(iterator(CEN), fun((CEN) -> any())) -> nil. each(Iterator, F) -> _pipe = Iterator, _pipe@1 = map(_pipe, F), run(_pipe@1). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/iterator.gleam", 1571). -spec yield(CEQ, fun(() -> iterator(CEQ))) -> iterator(CEQ). yield(Element, Next) -> {iterator, fun() -> {continue, Element, erlang:element(2, Next())} end}.