Open ghost opened 4 years ago
You can add your own functions via the scope:
Abacus.eval("rand() * 10", %{rand: &:rand.normal/0})
{:ok, 4.778221007148446}
I'd rather keep the scope of included functions as low as possible. I could see a global configuration for functions that should be included in the whole project though, something like this:
config :abacus, Abacus, scope: %{
rand: {:rand, :normal, 0},
now: {DateTime, :utc_now, 0}
}
I am suggesting that we add a rand function to the library.