Packages

A simple module to check if something is a numerical digit similar to std::is_digit in C++

Current section

Files

Jump to
glisdigit src glisdigit.erl
Raw

src/glisdigit.erl

-module(glisdigit).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([is_digit_10/1, is_digit/2]).
-spec is_digit_10(binary()) -> boolean().
is_digit_10(To_check) ->
case gleam@int:base_parse(To_check, 10) of
{error, nil} ->
false;
_ ->
true
end.
-spec is_digit(binary(), integer()) -> boolean().
is_digit(To_check, Base) ->
case gleam@int:base_parse(To_check, Base) of
{error, nil} ->
false;
_ ->
true
end.