summaryrefslogtreecommitdiff
path: root/lib/util.ex
diff options
context:
space:
mode:
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)