-module(textx). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/textx.gleam"). -export([reverse/1, is_palindrome/1, capitalize/1, word_count/1]). -file("src/textx.gleam", 4). -spec reverse(binary()) -> binary(). reverse(Word) -> gleam@string:reverse(Word). -file("src/textx.gleam", 8). -spec is_palindrome(binary()) -> boolean(). is_palindrome(Word) -> Cleaned = string:lowercase(Word), Cleaned =:= reverse(Cleaned). -file("src/textx.gleam", 13). -spec capitalize(binary()) -> binary(). capitalize(Word) -> case gleam_stdlib:string_pop_grapheme(Word) of {error, _} -> <<""/utf8>>; {ok, {First, Rest}} -> <<(string:uppercase(First))/binary, (string:lowercase(Rest))/binary>> end. -file("src/textx.gleam", 20). -spec word_count(binary()) -> integer(). word_count(Text) -> _pipe = Text, _pipe@1 = gleam@string:split(_pipe, <<" "/utf8>>), _pipe@2 = gleam@list:filter(_pipe@1, fun(Word) -> Word /= <<""/utf8>> end), erlang:length(_pipe@2).