-module(glap@utils). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/glap/utils.gleam"). -export([push_back/2, strformat/2, printformat/2]). -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/glap/utils.gleam", 6). ?DOC(false). -spec strformat_aux(list(binary()), list(binary())) -> binary(). strformat_aux(Parts1, Parts2) -> case {Parts1, Parts2} of {[], []} -> <<""/utf8>>; {[S], []} -> S; {[S1, S2 | S_rest], [J1 | J_rest]} -> strformat_aux( [<<<>/binary, S2/binary>> | S_rest], J_rest ); {_, _} -> erlang:error(#{gleam_error => panic, message => <<"wrong number of joiners"/utf8>>, file => <>, module => <<"glap/utils"/utf8>>, function => <<"strformat_aux"/utf8>>, line => 11}) end. -file("src/glap/utils.gleam", 29). ?DOC(false). -spec push_back(list(DUJ), DUJ) -> list(DUJ). push_back(L, X) -> case L of [] -> [X]; [H | T] -> [H | push_back(T, X)] end. -file("src/glap/utils.gleam", 15). ?DOC(false). -spec strformat(binary(), list(binary())) -> binary(). strformat(Template, Fmts) -> strformat_aux(gleam@string:split(Template, <<"{}"/utf8>>), Fmts). -file("src/glap/utils.gleam", 23). ?DOC(false). -spec printformat(binary(), list(binary())) -> nil. printformat(Template, Fmts) -> _pipe = strformat(Template, Fmts), gleam_stdlib:println(_pipe).