Erlang workshop and user conference

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Erlang workshop and user conference

James Hague-3
> > cross({V10,V11,V12}, {V20,V21,V22}) when float(V10),
> >    float(V11), float(V12), float(V20), float(V21),
> >    float(V22) ->
> >     {V11*V22-V12*V21,V12*V20-V10*V22,V10*V21-V11*V20}.
>
> I love the speed improvements, but that sure is _verbose_.

Better:

-define(floats(X,Y,Z), float(X), float(Y), float(Z)).

cross({V10,V11,V12}, {V20,V21,V22})
   when ?floats(V10,V11,V12), ?floats(V20,V21,V22) ->
   {V11*V22-V12*V21,V12*V20-V10*V22,V10*V21-V11*V20}.


Now we just need cross added to the math module and implemented in C :)

James