Skip to content

Instantly share code, notes, and snippets.

@emadb
Last active January 20, 2020 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emadb/49551f9c072e348dbd53a4401f07a182 to your computer and use it in GitHub Desktop.
Save emadb/49551f9c072e348dbd53a4401f07a182 to your computer and use it in GitHub Desktop.
Tramp data in Elixir
defmodule Foo do
def execute_command(data, coeff) do
data = prepare_data(data, coeff)
persist(data.name, coeff)
end
def prepare_data(data, coeff) do
w = calculate_w(data.x, data.y, data.z, coeff)
%{
name: "foo",
weight: w
}
end
def calculate_w(x, y, z, coeff) do
x * y * z * coeff
end
def persist(name, w) do
# save data
IO.inspect {name, w}, label: "saving"
:ok
end
def main do
data = %{
name: "foo",
x: 10, y: 20, z: 30
}
# read from ENV
coeff = 5
execute_command(data, coeff)
end
end
Foo.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment