A function which takes a function as it's argument, spawning it in new process, waiting for it's result, then returning the result.
I can't get the syntax right.
2> FooAsync = fun(Infun) -> Parent = self(), spawn( fun() -> X = Infun(), Parent ! X end ) , ok end .
#Fun<erl_eval.6.82930912>
3> FooAsync = fun(Infun) -> Parent = self(), spawn( fun() -> X = "foo" , Parent ! X end ) , receive Y -> Y end .
* 2: syntax error before: '.'
3> FooAsync = fun(Infun) -> Parent = self(), spawn( fun() -> X = "foo" , Parent ! X end ) , Res = receive Y -> Y, Res end .
* 2: syntax error before: '.'
5> fun(Infun) -> Parent = self(), spawn( fun() -> X = Infun(), Parent ! X end ) , ok end .
#Fun<erl_eval.6.82930912>