Current section
Files
Jump to
Current section
Files
src/given@internal@lib@optionx.erl
-module(given@internal@lib@optionx).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/given/internal/lib/optionx.gleam").
-export([partition/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/given/internal/lib/optionx.gleam", 26).
?DOC(false).
-spec partition_loop(list(gleam@option:option(FGN)), list(FGN), integer()) -> {list(FGN),
integer()}.
partition_loop(Options, Somes, None_count) ->
{Somes@1, Nones_count} = case Options of
[] ->
{Somes, None_count};
[{some, A} | Rest] ->
partition_loop(Rest, [A | Somes], None_count);
[none | Rest@1] ->
partition_loop(Rest@1, Somes, None_count + 1)
end,
{begin
_pipe = Somes@1,
lists:reverse(_pipe)
end,
Nones_count}.
-file("src/given/internal/lib/optionx.gleam", 22).
?DOC(false).
-spec partition(list(gleam@option:option(FGJ))) -> {list(FGJ), integer()}.
partition(Options) ->
partition_loop(Options, [], 0).