diff options
author | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
---|---|---|
committer | href <href@random.sh> | 2021-09-01 10:30:18 +0200 |
commit | 75687711f35355bc30e4829439384aab28fcac6d (patch) | |
tree | 8f3256f472893c39720a684d390e890a152f7303 /lib/util.ex | |
parent | link: post_* callbacks; html & pdftitle. (diff) |
Commit all the changes that hasn't been committed + updates.
Diffstat (limited to 'lib/util.ex')
-rw-r--r-- | lib/util.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/util.ex b/lib/util.ex index 22d1034..d35157b 100644 --- a/lib/util.ex +++ b/lib/util.ex @@ -4,13 +4,15 @@ defmodule Util do def plusminus(0), do: "0" def plusminus(number) when number < 0, do: "#{number}" - def float_paparse(string) do + def float_paparse(float) when is_float(float), do: {float, ""} + def float_paparse(int) when is_integer(int), do: {(int+0.0), ""} + def float_paparse(string) when is_binary(string) do string |> String.replace(",", ".") |> Float.parse() end - def ets_mutate_select_each(ets, table, spec, fun) do + def ets_mutate_select_each(ets, table, spec \\ [{:"$1", [], [:"$1"]}], fun) do ets.safe_fixtable(table, true) first = ets.select(table, spec, 1) do_ets_mutate_select_each(ets, table, fun, first) |