I\'m trying to define an anonymous function to do a dot product, I can code this as a private function without any problem but I am struggling with the anonymous function syntax
You could define a module-function called fix, and use it later to define dot (and any other recursing anonymous function):
defmodule A do
def fix(f, x) do
f.(fn(x) -> fix(f, x) end, x)
end
def fix2(f, x, y) do
f.(fn(x, y) -> fix2(f, x, y) end, x, y)
end
end
dot = fn(x, y) ->
A.fix2(fn
dot, [i|input],[w|weights], acc -> dot.(input,weights,i*w+acc)
dot, [],[bias],acc -> acc + bias
end, x, y)
end