summaryrefslogtreecommitdiff
path: root/lib/util.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-01 10:30:18 +0200
committerhref <href@random.sh>2021-09-01 10:30:18 +0200
commit75687711f35355bc30e4829439384aab28fcac6d (patch)
tree8f3256f472893c39720a684d390e890a152f7303 /lib/util.ex
parentlink: 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.ex6
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)